At first, just to clarify, they are included in banks containing compiled classes. They are not included in banks containing sources.
By default, generated resources are not included in the packaged source artifact .
For packageBin generated files should already be included - just make sure that you return all the generated files from the generator method. Assuming you want to pack them into an artifact of sources, this is what you need to do.
Suppose you have a generator that generates a properties file.
lazy val generatePropertiesTask = Def.task { val file = (resourceManaged in Compile).value / "stack-overflow" / "res.properties" val contents = s"name=${name.value}\nversion=${version.value}" IO.write(file, contents) Seq(file) } resourceGenerators in Compile += generatePropertiesTask.taskValue
To include this in the generated sources, you must tell sbt where res.properties should be copied to the generated artifact source. The task that generates packaged sources is called packageSrc , so you need to set mappings to this task .
mappings in (Compile, packageSrc) += { ((resourceManaged in Compile).value / "stack-overflow" / "res.properties") -> "path/in/jar/res.properties" }
Since your generator can generate many tasks, and displaying each of them will be a tedious task, sbt provides you with a utility to map multiple paths at once.
mappings in (Compile, packageSrc) ++= { val allGeneratedFiles = ((resourceManaged in Compile).value ** "*") filter { _.isFile } allGeneratedFiles.get pair relativeTo((resourceManaged in Compile).value) }
The first line finds all the generated files using the path finders , and the second line maps them to its path in the target bank.
lpiepiora
source share