Reputation: 7299
I have a gradle java project with custom task which generates some files during build. I need to produce jar artifact containing ONLY generated files. Problem: jar contains both generated files and class files.
Exclusion of *.java files from source sets is impossible because I need compiled classes for generation.
jar {
exclude("**/*.class")
from ("$buildDir/generated-files-dir")
}
Snippet above removes class files but leaves directories as is.
Upvotes: 0
Views: 686
Reputation: 7968
Add includeEmptyDirs = false
to your jar task.
jar {
exclude("**/*.class")
includeEmptyDirs = false
from ("$buildDir/generated-files-dir")
}
Upvotes: 1