Created
July 30, 2015 17:32
-
-
Save metasim/b89ac245f0316d53dd9e to your computer and use it in GitHub Desktop.
Example packaging aggregation build definition.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addCommandAlias("package", "collectPackages") | |
addCommandAlias("stage", "universal:stage") | |
enablePlugins(GitBranchPrompt) | |
enablePlugins(JavaAppPackaging) | |
// TODO: Need to figure out how to look this up from the outer project | |
version in ThisBuild := "0.2.1-SNAPSHOT" | |
scalaVersion in ThisBuild := "2.11.6" | |
val baseSettings = Seq( | |
classpathTypes += "war", | |
publishArtifact in (Compile, packageDoc) := false, | |
publishArtifact in packageDoc := false, | |
sources in (Compile,doc) := Seq.empty | |
) | |
sources in (Compile,doc) := Seq.empty | |
publishArtifact in (Compile, packageDoc) := false | |
// Due to the way that SBT works, subprojects have to be defined manually as below. | |
// IOW, don't try to refactor :-) | |
lazy val packaging = project | |
.in(file(".")) | |
.aggregate(a, b) | |
lazy val runr = ProjectRef(file(".."), "runr") | |
lazy val a = Project(id = "runr-cli", base = file("runr-cli")) | |
.dependsOn(runr) | |
.settings(baseSettings: _*) | |
lazy val b = Project(id = "runr-gui", base = file("runr-gui")) | |
.dependsOn(runr) | |
.settings(baseSettings: _*) | |
val packageSubs = taskKey[Seq[File]]("Build packages in subrojects") | |
(packageSubs in packaging) := Seq( | |
(packageBin.in(a, Universal)).value, | |
(packageBin.in(b, JDKPackager)).value | |
) | |
// Collect all the generated packages in one place. | |
val collectPackages = taskKey[File]("Move built packages") | |
collectPackages := { | |
val dest = target.value / "packages" | |
dest.mkdirs() | |
val files = packageSubs.value | |
val dests = files.map { f ⇒ | |
val d = dest / f.getName | |
IO.copyFile(f, d) | |
d | |
} | |
streams.value.log.info(s"Collected packages in $dest:\n${dests.map(_.getName).mkString(" ","\n ", "")}") | |
dest | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment