sbt/build.sbt

477 lines
12 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-10-26 14:53:18 +02:00
.disablePlugins(ScriptedPlugin)
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
2017-10-26 14:53:18 +02:00
.disablePlugins(ScriptedPlugin)
.enablePlugins(ScalaJSPlugin)
.dependsOn(coreJs)
.settings(
2017-04-02 21:51:11 +02:00
shared,
dontPublish,
coursierPrefix
)
lazy val tests = crossProject
2017-10-26 14:53:18 +02:00
.disablePlugins(ScriptedPlugin)
.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
2017-10-26 14:53:18 +02:00
.disablePlugins(ScriptedPlugin)
.dependsOn(testsJvm % "test->test")
.configs(Integration)
.settings(
shared,
dontPublish,
hasITs,
coursierPrefix,
libs += Deps.scalaAsync.value,
utest,
sharedTestResources
)
lazy val paths = project
2017-10-26 14:53:18 +02:00
.disablePlugins(ScriptedPlugin)
.settings(
pureJava,
dontPublish,
addDirectoriesSources
)
2015-12-30 01:34:41 +01:00
lazy val cache = project
2017-10-26 14:53:18 +02:00
.disablePlugins(ScriptedPlugin)
.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
2017-10-26 14:53:18 +02:00
.disablePlugins(ScriptedPlugin)
.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-10-26 14:53:18 +02:00
.disablePlugins(ScriptedPlugin)
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-26 14:53:18 +02:00
.disablePlugins(ScriptedPlugin)
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,
unmanagedResources.in(Test) += packageBin.in(bootstrap).in(Compile).value,
2017-04-02 21:51:11 +02:00
libs ++= {
if (scalaBinaryVersion.value == "2.11")
2016-11-09 18:28:31 +01:00
Seq(
Deps.caseApp,
Add json report to fetch and local exclusion option (#692) This patch introduces changes for cli with json output #659. Format as follows: ``` { "conflict_resolution": { "org:name:version" (requested): "org:name:version" (reconciled) }, "dependencies": [ { "coord": "orgA:nameA:versionA", "files": [ [ <classifier>, <path> ] ], "dependencies": [ // coodinates for its transitive dependencies <orgX:nameX:versionX>, <orgY:nameY:versionY>, ] }, { "coord": "orgB:nameB:versionB", "files": [ [ <classifier>, <path> ] ], "dependencies": [ // coodinates for its transitive dependencies <orgX:nameX:versionX>, <orgZ:nameZ:versionZ>, ] }, ] } ``` For example: ``` fetch -t org.apache.avro:trevni-avro:1.8.2 org.slf4j:slf4j-api:1.7.6 --json-output-file x.out Result: ├─ org.apache.avro:trevni-avro:1.8.2 │ ├─ org.apache.avro:trevni-core:1.8.2 │ │ ├─ org.apache.commons:commons-compress:1.8.1 │ │ ├─ org.slf4j:slf4j-api:1.7.7 │ │ └─ org.xerial.snappy:snappy-java:1.1.1.3 │ └─ org.slf4j:slf4j-api:1.7.7 └─ org.slf4j:slf4j-api:1.7.6 -> 1.7.7 ``` would produce the following json file: ``` $ jq < x.out { "conflict_resolution": { "org.slf4j:slf4j-api:1.7.6": "org.slf4j:slf4j-api:1.7.7" }, "dependencies": [ { "coord": "org.apache.avro:trevni-core:1.8.2", "files": [ [ "", "/Users/yic/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/apache/avro/trevni-core/1.8.2/trevni-core-1.8.2.jar" ] ], "dependencies": [ "org.slf4j:slf4j-api:1.7.7", "org.xerial.snappy:snappy-java:1.1.1.3", "org.apache.commons:commons-compress:1.8.1" ] }, { "coord": "org.apache.avro:trevni-avro:1.8.2", "files": [ [ "", "/Users/yic/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/apache/avro/trevni-avro/1.8.2/trevni-avro-1.8.2.jar" ] ], "dependencies": [ "org.apache.avro:trevni-core:1.8.2", "org.slf4j:slf4j-api:1.7.7", "org.xerial.snappy:snappy-java:1.1.1.3", "org.apache.commons:commons-compress:1.8.1" ] }, { "coord": "org.slf4j:slf4j-api:1.7.7", "files": [ [ "", "/Users/yic/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.7/slf4j-api-1.7.7.jar" ] ], "dependencies": [] }, { "coord": "org.apache.commons:commons-compress:1.8.1", "files": [ [ "", "/Users/yic/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.jar" ] ], "dependencies": [] }, { "coord": "org.xerial.snappy:snappy-java:1.1.1.3", "files": [ [ "", "/Users/yic/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/xerial/snappy/snappy-java/1.1.1.3/snappy-java-1.1.1.3.jar" ] ], "dependencies": [] } ] } ```
2017-12-26 19:46:35 +01:00
Deps.argonautShapeless,
Deps.junit % "test", // to be able to run tests with pants
Deps.scalatest % "test"
2016-11-09 18:28:31 +01:00
)
else
Seq()
},
2017-04-02 21:51:11 +02:00
addBootstrapJarAsResource,
proguardedCli
)
lazy val web = project
2017-10-26 14:53:18 +02:00
.disablePlugins(ScriptedPlugin)
.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")
)
)
lazy val readme = project
.in(file("doc/readme"))
2015-12-30 01:34:41 +01:00
.dependsOn(coreJvm, cache)
2017-10-26 14:53:18 +02:00
.disablePlugins(ScriptedPlugin)
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)
2017-10-26 14:53:18 +02:00
.disablePlugins(ScriptedPlugin)
.settings(
plugin,
utest,
// addSbtPlugin("com.dwijnand" % "sbt-compat" % "1.2.0+2-f30b82f4")
libs ++= {
val dependency = "com.dwijnand" % "sbt-compat" % "1.2.0+2-f30b82f4"
val sbtV = (sbtBinaryVersion in pluginCrossBuild).value
val scalaV = (scalaBinaryVersion in update).value
val m = Defaults.sbtPluginExtra(dependency, sbtV, scalaV)
CrossVersion.partialVersion(scalaVersion.value).collect {
case (2, 10) => m
case (2, 12) => m
}.toList
}
)
2017-02-02 02:06:04 +01:00
lazy val `sbt-coursier` = project
.dependsOn(coreJvm, cache, extra, `sbt-shared`)
.disablePlugins(ScriptedPlugin)
.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`)
.disablePlugins(ScriptedPlugin)
2017-06-06 19:51:38 +02:00
.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
.enablePlugins(ShadingPlugin)
.disablePlugins(ScriptedPlugin)
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
)
2016-08-22 00:40:01 +02:00
lazy val okhttp = project
.dependsOn(cache)
2017-10-26 14:53:18 +02:00
.disablePlugins(ScriptedPlugin)
2016-08-22 00:40:01 +02:00
.settings(
2017-04-02 21:51:11 +02:00
shared,
coursierPrefix,
libs += Deps.okhttpUrlConnection
2016-08-22 00:40:01 +02:00
)
2017-02-27 16:15:15 +01:00
lazy val jvm = project
.dummy
2017-10-26 14:53:18 +02:00
.disablePlugins(ScriptedPlugin)
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`,
readme,
okhttp
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-10-26 14:53:18 +02:00
.disablePlugins(ScriptedPlugin)
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
2017-10-26 14:53:18 +02:00
.disablePlugins(ScriptedPlugin)
2017-05-31 15:24:53 +02:00
.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,
pluginOverrideCrossScalaVersion,
2017-05-31 15:24:53 +02:00
dontPublish
)
2017-04-02 21:51:11 +02:00
lazy val coursier = project
2017-05-15 15:32:48 +02:00
.in(root)
2017-10-26 14:53:18 +02:00
.disablePlugins(ScriptedPlugin)
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`,
web,
readme,
2017-01-30 23:28:45 +01:00
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
)