I want to define a task, that invokes compile and packageBin tasks, and then does its stuff. How do I do that? Currently this only does the second part and skips on compile
<<=
is a method on TaskKey that returns a value. It does not update mutable state anywhere, so in the example code, the result of the first call is being discarded. To fix this, declare packageBin as an input as well, but ignore the resulting value. Note that packageBin depends on compile, so depending on compile is unnecessary.
dist <<= (update, crossTarget, packageBin in Compile) map { (updateReport, out, _) =>
It is unlikely that you want to copy all of the files in an UpdateReport
to a directory based solely on the file's name. It is possible for different dependencies to have the same file name. Also, this will include dependencies from all configurations, including test dependencies.
For the first problem, use the associated ModuleID
to construct the path in the target directory, like is done in the lib_managed
directory when retrieveManaged := true
. For the second problem, only select the files for the configuration you want.
updateReport.matching(configurationFilter(Runtime.name)).foreach...
See the sbt.UpdateReport and sbt.RichUpdateReport API docs for other useful methods.
If you aren't concerned about file name collisions, you can get the dependency files from dependencyClasspath. For example:
dist <<= (crossTarget, packageBin in Compile, dependencyClasspath in Runtime) map { (out, _, cp) =>
and get the Seq[File]
from cp.files
.