2017-04-02 21:51:11 +02:00
|
|
|
|
2019-02-18 11:31:37 +01:00
|
|
|
import java.util.Locale
|
|
|
|
|
|
2017-04-02 21:51:11 +02:00
|
|
|
import sbt._
|
|
|
|
|
import sbt.Keys._
|
2018-10-17 14:18:03 +02:00
|
|
|
import sbt.ScriptedPlugin.autoImport.{scriptedBufferLog, scriptedLaunchOpts}
|
2020-06-09 14:18:32 +02:00
|
|
|
import sbtcompatibility.SbtCompatibilityPlugin.autoImport._
|
2020-06-09 14:23:02 +02:00
|
|
|
import sbtevictionrules.EvictionRulesPlugin.autoImport._
|
2017-04-02 21:51:11 +02:00
|
|
|
|
2019-09-28 15:27:58 +02:00
|
|
|
import com.jsuereth.sbtpgp._
|
2017-04-02 21:51:11 +02:00
|
|
|
|
2017-05-15 15:32:47 +02:00
|
|
|
object Settings {
|
2017-04-02 21:51:11 +02:00
|
|
|
|
2021-03-09 11:45:32 +01:00
|
|
|
def scala212 = "2.12.13"
|
2021-03-08 15:11:40 +01:00
|
|
|
def scala213 = "2.13.5"
|
2017-04-02 21:51:11 +02:00
|
|
|
|
2020-02-05 19:10:28 +01:00
|
|
|
def targetSbtVersion = "1.2.8"
|
2017-04-02 21:51:11 +02:00
|
|
|
|
2019-10-18 13:39:03 +02:00
|
|
|
private lazy val isAtLeastScala213 = Def.setting {
|
|
|
|
|
import Ordering.Implicits._
|
|
|
|
|
CrossVersion.partialVersion(scalaVersion.value).exists(_ >= (2, 13))
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-17 14:18:03 +02:00
|
|
|
lazy val shared = Seq(
|
2018-10-17 14:18:03 +02:00
|
|
|
resolvers += Resolver.sonatypeRepo("releases"),
|
2018-09-28 17:55:42 +02:00
|
|
|
crossScalaVersions := Seq(scala212),
|
|
|
|
|
scalaVersion := scala212,
|
2018-03-12 11:18:19 +01:00
|
|
|
scalacOptions ++= Seq(
|
|
|
|
|
"-feature",
|
|
|
|
|
"-deprecation",
|
|
|
|
|
"-language:higherKinds",
|
|
|
|
|
"-language:implicitConversions"
|
2019-10-18 13:39:03 +02:00
|
|
|
),
|
|
|
|
|
libraryDependencies ++= {
|
|
|
|
|
if (isAtLeastScala213.value) Nil
|
|
|
|
|
else Seq(compilerPlugin("org.scalamacros" % s"paradise" % "2.1.1" cross CrossVersion.full))
|
|
|
|
|
},
|
|
|
|
|
scalacOptions ++= {
|
|
|
|
|
if (isAtLeastScala213.value) Seq("-Ymacro-annotations")
|
|
|
|
|
else Nil
|
2020-06-09 14:18:32 +02:00
|
|
|
},
|
2020-06-16 14:16:10 +02:00
|
|
|
compatibilityRules ++= Seq(
|
2020-06-09 14:18:32 +02:00
|
|
|
"com.eed3si9n" %% "gigahorse-*" % "semver",
|
|
|
|
|
"org.scala-lang.modules" % "*" % "semver",
|
|
|
|
|
"org.scala-sbt" % "*" % "semver",
|
2020-06-16 14:16:10 +02:00
|
|
|
"com.typesafe" %% "ssl-config-core" % "semver",
|
|
|
|
|
"net.java.dev.jna" % "jna*" % "always"
|
2020-06-09 14:18:32 +02:00
|
|
|
),
|
2020-06-09 14:23:02 +02:00
|
|
|
compatibilityIgnored += "com.swoval" % "apple-file-events",
|
|
|
|
|
evictionRules ++= Seq(
|
|
|
|
|
"com.eed3si9n" %% "gigahorse-*" % "semver",
|
|
|
|
|
"org.scala-lang.modules" %% "*" % "semver"
|
|
|
|
|
)
|
2019-02-18 11:31:37 +01:00
|
|
|
) ++ {
|
|
|
|
|
val prop = sys.props.getOrElse("publish.javadoc", "").toLowerCase(Locale.ROOT)
|
|
|
|
|
if (prop == "0" || prop == "false")
|
|
|
|
|
Seq(
|
|
|
|
|
sources in (Compile, doc) := Seq.empty,
|
|
|
|
|
publishArtifact in (Compile, packageDoc) := false
|
|
|
|
|
)
|
|
|
|
|
else
|
|
|
|
|
Nil
|
|
|
|
|
}
|
2017-04-02 21:51:11 +02:00
|
|
|
|
|
|
|
|
lazy val plugin =
|
2018-09-28 17:55:42 +02:00
|
|
|
shared ++
|
2017-04-02 21:51:11 +02:00
|
|
|
Seq(
|
2019-09-21 16:50:13 +02:00
|
|
|
// https://github.com/sbt/sbt/issues/5049#issuecomment-528960415
|
2020-02-05 19:10:28 +01:00
|
|
|
dependencyOverrides := "org.scala-sbt" % "sbt" % targetSbtVersion :: Nil,
|
2017-04-02 21:51:11 +02:00
|
|
|
scriptedLaunchOpts ++= Seq(
|
|
|
|
|
"-Xmx1024M",
|
2018-11-20 11:18:44 +01:00
|
|
|
"-Dplugin.name=" + name.value,
|
2017-04-02 21:51:11 +02:00
|
|
|
"-Dplugin.version=" + version.value,
|
2019-03-04 16:56:32 +01:00
|
|
|
"-Dsbttest.base=" + (sourceDirectory.value / "sbt-test").getAbsolutePath,
|
|
|
|
|
"-Dcoursier.sbt-launcher.add-plugin=false"
|
2017-04-02 21:51:11 +02:00
|
|
|
),
|
|
|
|
|
scriptedBufferLog := false,
|
2018-09-28 17:55:42 +02:00
|
|
|
sbtPlugin := true,
|
2020-02-05 19:10:28 +01:00
|
|
|
sbtVersion.in(pluginCrossBuild) := targetSbtVersion
|
2017-04-02 21:51:11 +02:00
|
|
|
)
|
|
|
|
|
|
2018-12-12 11:19:05 +01:00
|
|
|
lazy val generatePropertyFile =
|
|
|
|
|
resourceGenerators.in(Compile) += Def.task {
|
|
|
|
|
import sys.process._
|
|
|
|
|
|
|
|
|
|
val dir = classDirectory.in(Compile).value / "coursier"
|
|
|
|
|
val ver = version.value
|
|
|
|
|
|
|
|
|
|
val f = dir / "sbtcoursier.properties"
|
|
|
|
|
dir.mkdirs()
|
|
|
|
|
|
|
|
|
|
val p = new java.util.Properties
|
|
|
|
|
|
|
|
|
|
p.setProperty("version", ver)
|
|
|
|
|
p.setProperty("commit-hash", Seq("git", "rev-parse", "HEAD").!!.trim)
|
|
|
|
|
|
|
|
|
|
val w = new java.io.FileOutputStream(f)
|
|
|
|
|
p.store(w, "sbt-coursier properties")
|
|
|
|
|
w.close()
|
|
|
|
|
|
|
|
|
|
state.value.log.info(s"Wrote $f")
|
|
|
|
|
|
|
|
|
|
Seq(f)
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-02 21:51:11 +02:00
|
|
|
}
|