apply plugin:'application' def mainClassName = "ensemble.EnsembleApp" def FileCollection apachecp = files( "./lib/lucene-core-7.1.0.jar", "./lib/lucene-grouping-7.1.0.jar", "./lib/lucene-queryparser-7.1.0.jar") sourceSets { main { java { srcDirs 'src/app/java', 'src/generated/java', 'src/samples/java' } resources { srcDirs 'src/app/resources', 'src/generated/resources', 'src/samples/resources' } compileClasspath += apachecp } } jar { manifest.attributes("Main-Class": mainClassName) // add in the sample sources.... from fileTree('src/samples/java') // Note: this would be the "gradle" way to add in the Lucene jars // BUT we run into total path length on Windows with the temp file in ./build //apachecp.each { from zipTree(it) } //exclude 'META-INF/*' } // Merge the Apache Lucene jars into our master jar. jar.doLast() { ant.zip(destfile: jar.archivePath, update: true, duplicate: "preserve") { zipgroupfileset(dir: new File("./lib"), includes:"*.jar") } }