How can I selectively include files in Jar?

I have the following task definition:

task testingJar(type: Jar, dependsOn: compileTestJava) {
 from sourceSets.test.output
 include '**/org/hibernate/testing/**'
 classifier = 'testing'
}

After running this task, the generate jar file contains all files from sourceSets.test.output whether they matched the include pattern or not.

How can I make the Jar task include only files from the org.hibernate.testing package?

That’s surprising. Does the following make a difference?

task testingJar(type: Jar, dependsOn: compileTestJava) {

from(sourceSets.test.output) {

include ‘/org/hibernate/testing/

}

classifier = ‘testing’

}

Peter, sorry, i just wasnt noticing that the “other dirs” were empty and my task did not define ‘includeEmptyDirs = false’. The filtering is happening as per the include defined either way

No problem, could have been worse.