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.
Add includeEmptyDirs = false
to your jar task.
jar {
exclude("**/*.class")
includeEmptyDirs = false
from ("$buildDir/generated-files-dir")
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.