How can I selectively include files in Jar?

(steve) #1

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?

(Peter Niederwieser) #2

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’


(steve) #3

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

(Peter Niederwieser) #4

No problem, could have been worse.