sbt/project/Settings.scala

79 lines
2.1 KiB
Scala
Raw Normal View History

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}
2017-04-02 21:51:11 +02:00
import com.typesafe.sbt.pgp._
2018-10-17 14:18:03 +02:00
import coursier.ShadingPlugin.autoImport.{Shading, shadingNamespace}
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
2018-09-28 17:55:42 +02:00
def scala212 = "2.12.7"
2017-04-02 21:51:11 +02:00
2018-10-17 14:18:03 +02:00
def sbt10Version = "1.0.2"
2017-04-02 21:51:11 +02:00
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"
2018-10-17 14:18:03 +02:00
)
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(
scriptedLaunchOpts ++= Seq(
"-Xmx1024M",
"-Dplugin.name=" + name.value,
2017-04-02 21:51:11 +02:00
"-Dplugin.version=" + version.value,
"-Dsbttest.base=" + (sourceDirectory.value / "sbt-test").getAbsolutePath
),
scriptedBufferLog := false,
2018-09-28 17:55:42 +02:00
sbtPlugin := true,
sbtVersion.in(pluginCrossBuild) := sbt10Version
2017-04-02 21:51:11 +02:00
)
lazy val shading =
2018-10-17 14:18:03 +02:00
inConfig(Shading)(PgpSettings.projectSettings) ++
2018-02-22 11:30:51 +01:00
// Why does this have to be repeated here?
2017-10-24 17:47:29 +02:00
// Can't figure out why configuration gets lost without this in particular...
2018-10-17 14:18:03 +02:00
coursier.ShadingPlugin.projectSettings ++
2017-04-02 21:51:11 +02:00
Seq(
shadingNamespace := "coursier.shaded",
publish := publish.in(Shading).value,
publishLocal := publishLocal.in(Shading).value,
PgpKeys.publishSigned := PgpKeys.publishSigned.in(Shading).value,
PgpKeys.publishLocalSigned := PgpKeys.publishLocalSigned.in(Shading).value
)
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
}