Skip to content

Commit

Permalink
Merge pull request #333 from jroper/multiproject-classifiers
Browse files Browse the repository at this point in the history
Added support for classifiers in multiproject builds
  • Loading branch information
muuki88 committed Aug 29, 2014
2 parents 3a35214 + 69e6ec3 commit 9ebb44b
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ object JavaAppPackaging {
case (Some(l), Some(r)) =>
// TODO - extra attributes and stuff for comparison?
// seems to break stuff if we do...
(l.name == r.name)
l.name == r.name && l.classifier == r.classifier
case _ => false
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import sbt._
import Keys._
import com.typesafe.sbt.SbtNativePackager._

object MutliBuild extends Build {

val appVersion = "1.0"

val mySettings: Seq[Setting[_]] =
packageArchetype.java_application ++
Seq(
organization := "org.test",
version := appVersion,
TaskKey[Unit]("show-files") <<= (name, target, streams) map { (n, t, s) =>
System.out.synchronized {
println("Files in ["+n+"]")
val files = (t / "universal/stage").***.get
files foreach println
}
}
)

val assets = config("assets")

lazy val sub = (
Project("sub", file("sub"))
settings(mySettings:_*)
settings(
ivyConfigurations += assets,
artifact in assets := artifact.value.copy(classifier = Some("assets")),
packagedArtifacts += {
val file = target.value / "assets.jar"
val assetsDir = baseDirectory.value / "src" / "main" / "assets"
val sources = assetsDir.***.filter(_.isFile) pair relativeTo(assetsDir)
IO.zip(sources, file)
(artifact in assets).value -> file
},
exportedProducts in assets := {
Seq(
Attributed.blank(baseDirectory.value / "src" / "main" / "assets")
.put(artifact.key, (artifact in assets).value)
.put(AttributeKey[ModuleID]("module-id"), projectID.value)
)
}
)
)

lazy val root = (
Project("root", file("."))
settings(mySettings:_*)
dependsOn(sub % "compile->compile;compile->assets")
)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version"))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
h1 { color: blue; }
5 changes: 5 additions & 0 deletions src/sbt-test/universal/multiproject-classifiers/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Run the staging and check the script.
> stage
> show-files
$ exists target/universal/stage/lib/org.test.sub-1.0.jar
$ exists target/universal/stage/lib/org.test.sub-1.0-assets.jar

0 comments on commit 9ebb44b

Please sign in to comment.