Skip to content

Commit

Permalink
Added support for classifiers in multiproject builds
Browse files Browse the repository at this point in the history
If one project has two dependencies on another project for different
classifiers in that project, this ensures that both dependencies are
included.
  • Loading branch information
jroper committed Aug 25, 2014
1 parent d334c80 commit be12a70
Show file tree
Hide file tree
Showing 4 changed files with 59 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,52 @@
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"
IO.zip(Seq.empty, 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"))
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 be12a70

Please sign in to comment.