2023-01-08 17:13:31 +08:00
|
|
|
/*
|
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
|
* license agreements; and to You under the Apache License, version 2.0:
|
|
|
|
|
*
|
|
|
|
|
* https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* This file is part of the Apache Pekko project, derived from Akka.
|
|
|
|
|
*/
|
|
|
|
|
|
2018-12-09 05:13:11 +08:00
|
|
|
/*
|
2022-02-04 12:36:44 +01:00
|
|
|
* Copyright (C) 2018-2022 Lightbend Inc. <https://www.lightbend.com>
|
2018-12-09 05:13:11 +08:00
|
|
|
*/
|
2019-01-02 18:55:26 +08:00
|
|
|
|
2018-12-09 05:13:11 +08:00
|
|
|
package sbt
|
2019-01-16 11:44:07 +01:00
|
|
|
import Keys.baseDirectory
|
2018-12-09 05:13:11 +08:00
|
|
|
|
2022-11-12 10:21:24 +01:00
|
|
|
import org.apache.pekko.ProjectFileIgnoreSupport
|
2018-12-09 05:13:11 +08:00
|
|
|
import sbt.Keys.unmanagedSources
|
|
|
|
|
|
2019-01-16 11:44:07 +01:00
|
|
|
trait ScalafixSupport {
|
|
|
|
|
private val ignoreConfigFileName: String = ".scalafix.conf"
|
|
|
|
|
private val descriptor: String = "scalafix"
|
2018-12-09 05:13:11 +08:00
|
|
|
|
2019-01-12 01:41:54 +08:00
|
|
|
protected def ignore(configKey: ConfigKey): Def.Setting[Task[Seq[File]]] = {
|
|
|
|
|
import scalafix.sbt.ScalafixPlugin.autoImport._
|
2019-01-16 11:44:07 +01:00
|
|
|
|
2021-05-25 12:50:51 +02:00
|
|
|
configKey / scalafix / unmanagedSources := {
|
2020-12-09 15:20:13 +07:00
|
|
|
val ignoreSupport =
|
2021-05-25 12:50:51 +02:00
|
|
|
new ProjectFileIgnoreSupport((ThisBuild / baseDirectory).value / ignoreConfigFileName, descriptor)
|
2019-01-16 11:44:07 +01:00
|
|
|
|
2021-05-25 12:50:51 +02:00
|
|
|
(configKey / scalafix / unmanagedSources).value.filterNot(file => ignoreSupport.isIgnoredByFileOrPackages(file))
|
2019-01-16 11:44:07 +01:00
|
|
|
}
|
2018-12-09 05:13:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
import sbt.Keys._
|
|
|
|
|
|
|
|
|
|
def addProjectCommandsIfAbsent(alias: String, value: String): Def.Setting[Seq[Command]] = {
|
|
|
|
|
commands := {
|
|
|
|
|
val currentCommands = commands.value.collect {
|
|
|
|
|
case command: SimpleCommand => command.name
|
|
|
|
|
}.toSet
|
|
|
|
|
val isPresent = currentCommands(alias)
|
|
|
|
|
if (isPresent)
|
|
|
|
|
commands.value
|
|
|
|
|
else
|
2020-12-09 15:20:13 +07:00
|
|
|
commands.value :+ BasicCommands.newAlias(name = alias, value = value)
|
2018-12-09 05:13:11 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def updateProjectCommands(alias: String, value: String): Def.Setting[Seq[Command]] = {
|
|
|
|
|
commands := {
|
2022-11-03 09:46:22 +01:00
|
|
|
commands.value.filterNot {
|
2018-12-09 05:13:11 +08:00
|
|
|
case command: SimpleCommand => command.name == alias
|
2020-12-09 15:20:13 +07:00
|
|
|
case _ => false
|
2022-11-03 09:46:22 +01:00
|
|
|
} :+ BasicCommands.newAlias(name = alias, value = value)
|
2018-12-09 05:13:11 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-09 15:20:13 +07:00
|
|
|
|
|
|
|
|
object ScalafixSupport {
|
2022-12-02 04:53:48 -08:00
|
|
|
def fixTestScope: Boolean = System.getProperty("pekko.scalafix.fixTestScope", "false").toBoolean
|
2020-12-09 15:20:13 +07:00
|
|
|
}
|