I have a multi-project setup for the game. There is a very specific subproject called "resources" that contains only files, such as images, sounds, and tex files that need to be packaged in a jar.
I have a custom task that processes images and packs them. Inside "src / main" I use the "preprocess" folder, where the images should go, and the "unmanaged" folder, where everything else is. By running my task, all the images in the preprocess are packaged and displayed in the "resources", and everything in the "unmanaged" is copied as is.
val texturePacker = TaskKey[Unit]("texture-packer", "Runs libgdx Texture Packer")
val texturePackerTask = texturePacker := {
println("Packaging textures...")
val inputDir = file("resources/src/main/preprocess")
val outputDir = file("resources/src/main/resources")
val folders = inputDir.asFile.listFiles filter (_.isDirectory)
println("Sub-Folders:" + folders.mkString(", "))
for (subfolder <- folders) {
println("Building assets for:" + subfolder)
val args = Array(subfolder.toString, outputDir.toString, subfolder.getName)
com.badlogic.gdx.tools.imagepacker.TexturePacker2.main(args)
}
IO.copyDirectory(file("resources/src/main/unmanaged"), file("resources/src/main/resources"))
}
And then in the 'resources' project settings:
...
packageBin in Compile <<= packageBin in Compile dependsOn(texturePacker)
...
packageBin, . , , , . , . , . , SBT SBT, , .
, , ?