Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for classifiers in multiproject builds #333

Merged
merged 1 commit into from
Aug 29, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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