sbt-assembly 0.8.1
minor enhancements
- sbt 0.11.3
- more default exclusions and merges contributed by @rjmac
sbt-assembly is a plug-in for Simple Build Tool that creates a single jar of your project including all of its dependencies.
implicit.ly |
Scala software, hot off the presses |
sbt-assembly is a plug-in for Simple Build Tool that creates a single jar of your project including all of its dependencies.
sbt-assembly 0.8.0 adds merge strategy feature contributed by @rkuhn (Roland from Akka team) and @sirthias (Mathias the spray guy).
The original use case for MergeStrategy is to merge reference.conf from multiple Akka jars into one configuration file. We then realized that a strategy can be expressed as a function value Seq[File] => Either[String, File], which takes a sequence of conflicted files and returns either an error message or a file. The actual type is a bit more complicated, but that's the gist. Let's look at the six strategies that we ship with sbt-assembly.
MergeStrategy.first picks the first of the conflicting files in classpath order
MergeStrategy.last picks the last one
MergeStrategy.error bails out with an error message
MergeStrategy.deduplicate verifies that all candidates have the same contents and error out otherwise
MergeStrategy.concat simply concatenates all conflicting files and includes the result
MergeStrategy.filterDistinctLines also concatenates, but leaves out duplicates along the way
A function from path name to a merge strategy can be set to newly added mergeStrategy key.
The default implementation looks like this:
mergeStrategy in assembly := {
case "reference.conf" => MergeStrategy.concat
case n if n.startsWith("META-INF/services/") => MergeStrategy.filterDistinctLines
case _ => MergeStrategy.deduplicate
}sbt-assembly is a plug-in for Simple Build Tool that creates a single jar of your project including all of its dependencies.
assembledMappings task to allow customization of jar content.
sbt-assembly is a plug-in for Simple Build Tool that creates a single jar of your project including all of its dependencies.
In plugins.sbt:
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.7.3")
resolvers += Resolver.url("sbt-plugin-releases",
new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns)sbt-assembly is a plug-in for Simple Build Tool that creates a single jar of your project including all of its dependencies.
META-INF/services merging. contributed by @rjmac
sbt-assembly is a plug-in for Simple Build Tool that creates a single jar of your project including all of its dependencies.
packageDependency, assembleArtifact in packageBin, etc. #18 reported by @vasa-chi .
sbt-assembly is a plug-in for Simple Build Tool that creates a single jar of your project including all of its dependencies.
In an effort to solve namespace conflicts and to increase consistency among the plugins, a number of sbt plugin authors have discussed on the mailing list, and come up with sbt plugins best practices. I've made my effort to conform to the guideline while minimizing the impact on the existing builds. Here are the changes:
AssemblyKeys objectKeys provided by sbt-assembly now resides in AssemblyKeys object. Place the following at the top of your build.sbt:
import AssemblyKeys._
Scala identifiers for the keys remain the same (e.g. jarName), but key names accessible from the shell are now prefixed with assembly- (e.g. assembly-jar-name).
assemblyassembly-specific settings are now scoped under assembly task, instead of Assembly configuration.
jarName in assembly := "foo.jar"
assembleArtifact instead of publishArtifactTo exclude Scala library,
assembleArtifact in packageScala := false
To build assembly for Test configuration,
seq(inConfig(Test)(baseAssemblySettings): _*) jarName in (Test, assembly) := "foo-test.jar"
excludedJars setting to skip certain jars.
To exclude some jar file, first consider using "provided" dependency. The dependency will be part of compilation, but excluded from the runtime. Next, try creating a custom configuration that describes your classpath. If all efforts fail, here's a way to exclude jars:
excludedJars in assembly <<= (fullClasspath in assembly) map { cp =>
cp filter {_.data.getName == "compile-0.1.0.jar"}
}sbt-assembly is a plug-in for Simple Build Tool that creates a single jar of your project including all of its dependencies.
license and MANIFEST.MF. #11 reported by @rollinsruss.
publishArtifact setting to disable output of packageBin, packageScala, and packageDependency. #3 and #4 requested by @ijuma.
To exclude Scala library,
publishArtifact in (Assembly, packageScala) := false
To exclude your source files,
publishArtifact in (Assembly, packageBin) := false
sbt-assembly is a plug-in for Simple Build Tool that creates a single jar of your project including all of its dependencies.
sbt-assembly is a plug-in for Simple Build Tool that creates a single jar of your project including all of its dependencies.
Settings are no longer loaded automatically. Add the following to build.sbt:
seq(sbtassembly.Plugin.assemblySettings: _*)
sbt-assembly is a plug-in for Simple Build Tool that creates a single jar of your project including all of its dependencies.