Hi,
I’m trying to create a Jar with a subset of classes of my project. My prj structure is ‘standard’ (src/main/java/…) and I have two sub-packages there at different places named ‘persistence’ (with sub-structures).
So for a start I tried to put one of these sub-packages in the jar using several variations of the following:
task persistenceJar(type: Jar) {
baseName = 'SbSPersistence'
dependsOn compileJava
include 'de/aspect/sbs/persistence/**/*'
}
The resulting Jar is basically empty.
Finally I would like to have those two sub-packages ‘persistence’ with the sub-structures in one separate Jar.
Well, I don’t know how to proceed from here - am I doing something totally wrong?
Mark.
ok, started from scratch:
task tJar(type: Jar) {
from sourceSets.main.output
include '**/persistence/**/*.class'
}
This gives me basically the needed classes plus all the other directories without content AND all the classes are there TWICE???
How can I get rid of the dublicates and those empty dirs?
started from scratch:
task tJar(type: Jar, dependsOn: compileJava) {
from sourceSets.main.output.classesDir
include '**/persistence/**/*'
}
If you ommit “classesDir” all the classes will end up in the jar TWICE 
Ok, only point now is, that I have lots of empty dirs in the jar (packages that are not picked up) - any idea how I can get rid of them?
Mark.
If you ommit “classesDir” all the classes will end up in the jar TWICE 
It happens when you reconfigure Gradle to use the same output directory for classes and resources. Hopefully, the default behavior of the ‘Jar’ task will eventually be changed to not include duplicates.
Ok, only point now is, that I have lots of empty dirs in the jar (packages that are not picked up) - any idea how I can get rid of them?
jar.includeEmptyDirs = false
Make sure to consult the DSL reference whenever you have such a question.
shame on me- Thank you very much 