sbt/build.sbt

486 lines
11 KiB
Plaintext
Raw Normal View History

2017-04-02 21:51:11 +02:00
import Aliases._
2017-05-15 15:32:47 +02:00
import Settings._
2017-04-02 21:51:11 +02:00
import Publish._
2017-04-02 21:51:11 +02:00
parallelExecution.in(Global) := false
2016-08-31 21:23:11 +02:00
lazy val core = crossProject
2017-04-02 21:51:11 +02:00
.jvmConfigure(_.enablePlugins(ShadingPlugin))
2017-02-28 14:42:28 +01:00
.jvmSettings(
2017-04-02 21:51:11 +02:00
shading,
quasiQuotesIfNecessary,
scalaXmlIfNecessary,
libs ++= Seq(
Deps.fastParse % "shaded",
2017-05-10 02:06:47 +02:00
Deps.jsoup % "shaded"
),
shadeNamespaces ++= Set(
"org.jsoup",
"fastparse",
"sourcecode"
2017-04-02 21:51:11 +02:00
),
generatePropertyFile
2017-02-28 14:42:28 +01:00
)
.jsSettings(
2017-04-02 21:51:11 +02:00
libs ++= Seq(
CrossDeps.fastParse.value,
CrossDeps.scalaJsDom.value
)
2017-02-28 14:42:28 +01:00
)
.settings(
2017-04-02 21:51:11 +02:00
shared,
2016-01-31 20:55:18 +01:00
name := "coursier",
2017-04-02 21:51:11 +02:00
libs += CrossDeps.scalazCore.value,
Mima.previousArtifacts,
Mima.coreFilters
)
lazy val coreJvm = core.jvm
lazy val coreJs = core.js
lazy val `fetch-js` = project
.enablePlugins(ScalaJSPlugin)
.dependsOn(coreJs)
.settings(
2017-04-02 21:51:11 +02:00
shared,
dontPublish,
coursierPrefix
)
lazy val tests = crossProject
.dependsOn(core)
2017-04-02 21:51:11 +02:00
.jvmConfigure(_.dependsOn(cache % "test"))
.jsConfigure(_.dependsOn(`fetch-js` % "test"))
.jsSettings(
2017-04-02 21:51:11 +02:00
scalaJSStage.in(Global) := FastOptStage
)
.configs(Integration)
.settings(
shared,
dontPublish,
hasITs,
coursierPrefix,
libs += Deps.scalaAsync.value,
utest,
sharedTestResources
)
2017-04-02 21:51:11 +02:00
lazy val testsJvm = tests.jvm
lazy val testsJs = tests.js
lazy val `proxy-tests` = project
.dependsOn(testsJvm % "test->test")
.configs(Integration)
.settings(
shared,
dontPublish,
hasITs,
coursierPrefix,
libs += Deps.scalaAsync.value,
utest,
sharedTestResources
)
lazy val paths = project
.settings(
pureJava,
dontPublish,
addDirectoriesSources
)
2015-12-30 01:34:41 +01:00
lazy val cache = project
.dependsOn(coreJvm)
.settings(
2017-04-02 21:51:11 +02:00
shared,
Mima.previousArtifacts,
coursierPrefix,
libs += Deps.scalazConcurrent,
Mima.cacheFilters,
addPathsSources
)
lazy val bootstrap = project
.settings(
2017-04-02 21:51:11 +02:00
pureJava,
dontPublish,
addPathsSources,
2017-05-05 18:04:20 +02:00
// seems not to be automatically found with sbt 0.13.16-M1 :-/
mainClass := Some("coursier.Bootstrap"),
2017-04-02 21:51:11 +02:00
renameMainJar("bootstrap.jar")
)
lazy val extra = project
2017-07-08 14:18:03 +02:00
.enablePlugins(ShadingPlugin)
.dependsOn(coreJvm)
.settings(
shared,
2017-07-08 14:18:03 +02:00
coursierPrefix,
shading,
libs ++= {
if (scalaBinaryVersion.value == "2.11")
Seq(
Deps.scalaNativeTools % "shaded",
// brought by only tools, so should be automaticaly shaded,
// but issues in ShadingPlugin (with things published locally?)
// seem to require explicit shading...
Deps.scalaNativeNir % "shaded",
Deps.scalaNativeUtil % "shaded",
2017-07-08 14:18:03 +02:00
Deps.fastParse % "shaded"
)
else
Nil
},
shadeNamespaces ++=
Set(
"fastparse",
"sourcecode"
) ++
// not blindly shading the whole scala.scalanative here, for some constant strings starting with
// "scala.scalanative.native." in scalanative not to get prefixed with "coursier.shaded."
Seq("codegen", "io", "linker", "nir", "optimizer", "tools", "util")
.map("scala.scalanative." + _)
)
lazy val cli = project
.dependsOn(coreJvm, cache, extra)
2017-10-20 02:48:12 +02:00
.enablePlugins(PackPlugin, SbtProguard)
.settings(
2017-04-02 21:51:11 +02:00
shared,
dontPublishIn("2.10", "2.12"),
coursierPrefix,
libs ++= {
if (scalaBinaryVersion.value == "2.11")
2016-11-09 18:28:31 +01:00
Seq(
Deps.caseApp,
Deps.argonautShapeless
)
else
Seq()
},
2017-04-02 21:51:11 +02:00
addBootstrapJarAsResource,
proguardedCli
)
lazy val web = project
.enablePlugins(ScalaJSPlugin)
.dependsOn(coreJs, `fetch-js`)
.settings(
2017-04-02 21:51:11 +02:00
shared,
dontPublish,
libs ++= {
if (scalaBinaryVersion.value == "2.11")
2016-10-22 22:24:41 +02:00
Seq(
2017-04-02 21:51:11 +02:00
CrossDeps.scalaJsJquery.value,
CrossDeps.scalaJsReact.value
2016-10-22 22:24:41 +02:00
)
else
Seq()
},
sourceDirectory := {
val dir = sourceDirectory.value
if (scalaBinaryVersion.value == "2.11")
dir
else
dir / "target" / "dummy"
},
2017-04-02 21:51:11 +02:00
noTests,
webjarBintrayRepository,
jsDependencies ++= Seq(
2017-04-02 21:51:11 +02:00
WebDeps.bootstrap
.intransitive()
./("bootstrap.min.js")
.commonJSName("Bootstrap"),
WebDeps.react
.intransitive()
./("react-with-addons.js")
.commonJSName("React"),
WebDeps.bootstrapTreeView
.intransitive()
./("bootstrap-treeview.min.js")
.commonJSName("Treeview"),
WebDeps.raphael
.intransitive()
./("raphael-min.js")
.commonJSName("Raphael")
)
)
2015-12-30 01:34:34 +01:00
lazy val doc = project
2015-12-30 01:34:41 +01:00
.dependsOn(coreJvm, cache)
2017-05-15 15:32:49 +02:00
.enablePlugins(TutPlugin)
2015-12-30 01:34:34 +01:00
.settings(
2017-04-02 21:51:11 +02:00
shared,
dontPublish,
2015-12-30 01:34:34 +01:00
tutSourceDirectory := baseDirectory.value,
2017-04-02 21:51:11 +02:00
tutTargetDirectory := baseDirectory.in(LocalRootProject).value
2015-12-30 01:34:34 +01:00
)
lazy val `sbt-shared` = project
.dependsOn(coreJvm, cache)
.settings(
plugin,
utest
)
2017-02-02 02:06:04 +01:00
lazy val `sbt-coursier` = project
.dependsOn(coreJvm, cache, extra, `sbt-shared`)
.settings(
plugin,
utest
)
2017-01-30 22:57:24 +01:00
2017-06-06 19:51:38 +02:00
lazy val `sbt-pgp-coursier` = project
.dependsOn(`sbt-coursier`)
.settings(
plugin,
libs ++= {
scalaBinaryVersion.value match {
case "2.10" | "2.12" =>
Seq(Deps.sbtPgp.value)
case _ => Nil
}
}
)
2017-01-30 22:57:24 +01:00
lazy val `sbt-shading` = project
2017-04-02 21:51:11 +02:00
.enablePlugins(ShadingPlugin)
2017-02-02 02:06:04 +01:00
.dependsOn(`sbt-coursier`)
2016-04-01 00:39:30 +02:00
.settings(
2017-04-02 21:51:11 +02:00
plugin,
shading,
localM2Repository, // for a possibly locally published jarjar
2017-07-11 19:04:00 +02:00
libs += Deps.jarjar % "shaded",
2017-04-02 21:51:11 +02:00
// dependencies of jarjar-core - directly depending on these so that they don't get shaded
libs ++= Deps.jarjarTransitiveDeps
2015-12-30 01:34:34 +01:00
)
2017-02-21 15:57:41 +01:00
lazy val `sbt-launcher` = project
2017-10-20 02:48:12 +02:00
.enablePlugins(PackPlugin)
2017-02-21 15:57:41 +01:00
.dependsOn(cache)
.settings(
2017-04-02 21:51:11 +02:00
shared,
dontPublishIn("2.10", "2.12"),
libs ++= {
if (scalaBinaryVersion.value == "2.11")
Seq(
Deps.caseApp12,
Deps.sbtLauncherInterface,
Deps.typesafeConfig
)
else
Nil
}
2017-02-21 15:57:41 +01:00
)
lazy val `http-server` = project
2017-10-20 02:48:12 +02:00
.enablePlugins(PackPlugin)
2016-04-05 16:24:39 +02:00
.settings(
2017-04-02 21:51:11 +02:00
shared,
dontPublishIn("2.10", "2.11"),
libs ++= {
if (scalaBinaryVersion.value == "2.12")
Seq(
Deps.http4sBlazeServer,
Deps.http4sDsl,
Deps.slf4jNop,
Deps.caseApp12
)
else
Nil
}
2016-04-05 16:24:39 +02:00
)
2016-08-22 00:40:01 +02:00
lazy val okhttp = project
.dependsOn(cache)
.settings(
2017-04-02 21:51:11 +02:00
shared,
coursierPrefix,
libs += Deps.okhttpUrlConnection
2016-08-22 00:40:01 +02:00
)
lazy val echo = project
2017-05-15 15:32:52 +02:00
.settings(pureJava)
2017-02-27 16:15:15 +01:00
lazy val jvm = project
.dummy
2017-02-27 16:15:15 +01:00
.aggregate(
coreJvm,
testsJvm,
`proxy-tests`,
paths,
2017-02-27 16:15:15 +01:00
cache,
bootstrap,
extra,
2017-02-27 16:15:15 +01:00
cli,
`sbt-shared`,
2017-02-27 16:15:15 +01:00
`sbt-coursier`,
2017-06-06 19:51:38 +02:00
`sbt-pgp-coursier`,
2017-02-27 16:15:15 +01:00
`sbt-shading`,
`sbt-launcher`,
doc,
`http-server`,
okhttp,
echo
2017-02-27 16:15:15 +01:00
)
.settings(
2017-04-02 21:51:11 +02:00
shared,
dontPublish,
2017-02-27 16:15:15 +01:00
moduleName := "coursier-jvm"
)
lazy val js = project
.dummy
2017-02-27 16:15:15 +01:00
.aggregate(
coreJs,
`fetch-js`,
testsJs,
web
)
.settings(
2017-04-02 21:51:11 +02:00
shared,
dontPublish,
2017-02-27 16:15:15 +01:00
moduleName := "coursier-js"
)
2017-05-31 15:24:53 +02:00
// run sbt-plugins/publishLocal to publish all that necessary for plugins
lazy val `sbt-plugins` = project
.dummy
.aggregate(
coreJvm,
cache,
extra,
`sbt-shared`,
2017-05-31 15:24:53 +02:00
`sbt-coursier`,
2017-06-06 19:51:38 +02:00
`sbt-pgp-coursier`,
2017-05-31 15:24:53 +02:00
`sbt-shading`
)
.settings(
shared,
dontPublish
)
2017-04-02 21:51:11 +02:00
lazy val coursier = project
2017-05-15 15:32:48 +02:00
.in(root)
2017-01-30 23:28:45 +01:00
.aggregate(
coreJvm,
coreJs,
`fetch-js`,
testsJvm,
testsJs,
`proxy-tests`,
paths,
2017-01-30 23:28:45 +01:00
cache,
bootstrap,
extra,
2017-01-30 23:28:45 +01:00
cli,
`sbt-shared`,
2017-02-02 02:06:04 +01:00
`sbt-coursier`,
2017-06-06 19:51:38 +02:00
`sbt-pgp-coursier`,
2017-01-30 23:28:45 +01:00
`sbt-shading`,
2017-02-21 15:57:41 +01:00
`sbt-launcher`,
2017-01-30 23:28:45 +01:00
web,
doc,
2017-05-05 18:04:20 +02:00
echo,
2017-01-30 23:28:45 +01:00
`http-server`,
okhttp
)
.settings(
2017-04-02 21:51:11 +02:00
shared,
dontPublish,
moduleName := "coursier-root"
)
2017-01-30 23:28:45 +01:00
2017-04-02 21:51:11 +02:00
lazy val addBootstrapJarAsResource = {
import java.nio.file.Files
packageBin.in(Compile) := {
val bootstrapJar = packageBin.in(bootstrap).in(Compile).value
val source = packageBin.in(Compile).value
val dest = source.getParentFile / (source.getName.stripSuffix(".jar") + "-with-bootstrap.jar")
ZipUtil.addToZip(source, dest, Seq(
"bootstrap.jar" -> Files.readAllBytes(bootstrapJar.toPath)
))
dest
}
2017-04-02 21:51:11 +02:00
}
2017-01-30 23:28:45 +01:00
2017-04-02 21:51:11 +02:00
lazy val addBootstrapInProguardedJar = {
import java.nio.charset.StandardCharsets
import java.nio.file.Files
2017-10-20 02:48:12 +02:00
proguard.in(Proguard) := {
2017-04-02 21:51:11 +02:00
val bootstrapJar = packageBin.in(bootstrap).in(Compile).value
val source = proguardedJar.value
2017-01-30 23:28:45 +01:00
2017-04-02 21:51:11 +02:00
val dest = source.getParentFile / (source.getName.stripSuffix(".jar") + "-with-bootstrap.jar")
val dest0 = source.getParentFile / (source.getName.stripSuffix(".jar") + "-with-bootstrap-and-prelude.jar")
// TODO Get from cli original JAR
val manifest =
s"""Manifest-Version: 1.0
|Implementation-Title: ${name.value}
|Implementation-Version: ${version.value}
|Specification-Vendor: ${organization.value}
|Specification-Title: ${name.value}
|Implementation-Vendor-Id: ${organization.value}
|Specification-Version: ${version.value}
|Implementation-URL: ${homepage.value.getOrElse("")}
|Implementation-Vendor: ${organization.value}
|Main-Class: ${mainClass.in(Compile).value.getOrElse(sys.error("Main class not found"))}
|""".stripMargin
ZipUtil.addToZip(source, dest, Seq(
"bootstrap.jar" -> Files.readAllBytes(bootstrapJar.toPath),
"META-INF/MANIFEST.MF" -> manifest.getBytes(StandardCharsets.UTF_8)
))
ZipUtil.addPrelude(dest, dest0)
Seq(dest0)
2017-01-30 23:28:45 +01:00
}
2017-04-02 21:51:11 +02:00
}
lazy val proguardedCli = Seq(
2017-10-20 02:48:12 +02:00
proguardVersion.in(Proguard) := SharedVersions.proguard,
proguardOptions.in(Proguard) ++= Seq(
2017-04-02 21:51:11 +02:00
"-dontwarn",
"-keep class coursier.cli.Coursier {\n public static void main(java.lang.String[]);\n}",
"-keep class coursier.cli.IsolatedClassLoader {\n public java.lang.String[] getIsolationTargets();\n}",
"-adaptresourcefilenames **.properties"
),
2017-10-20 02:48:12 +02:00
javaOptions.in(Proguard, proguard) := Seq("-Xmx3172M"),
artifactPath.in(Proguard) := proguardDirectory.in(Proguard).value / "coursier-standalone.jar",
2017-04-02 21:51:11 +02:00
artifacts ++= {
if (scalaBinaryVersion.value == "2.11")
Seq(proguardedArtifact.value)
else
Nil
},
addBootstrapInProguardedJar,
2017-10-24 17:47:29 +02:00
addProguardedJar
)
2017-04-02 21:51:11 +02:00
lazy val sharedTestResources = {
unmanagedResourceDirectories.in(Test) += baseDirectory.in(LocalRootProject).value / "tests" / "shared" / "src" / "test" / "resources"
}
// Using directly the sources of directories, rather than depending on it.
// This is required to use it from the bootstrap module, whose jar is launched as is (so shouldn't require dependencies).
// This is done for the other use of it too, from the cache module, not to have to manage two ways of depending on it.
lazy val addDirectoriesSources = {
unmanagedSourceDirectories.in(Compile) += baseDirectory.in(LocalRootProject).value / "directories" / "src" / "main" / "java"
}
lazy val addPathsSources = Seq(
addDirectoriesSources,
unmanagedSourceDirectories.in(Compile) ++= unmanagedSourceDirectories.in(Compile).in(paths).value
)