Return to Snippet

Revision: 34176
at October 19, 2010 01:51 by laurenceosx


Initial Code
// make fat jar
	// exclude META-INF/MANIFEST.MF files and *groovy*.jar
	
	def f_NotGroovyJar(ao) {
		// filter routine for find All to exclude groovy jar files
		def f_ew_jar     = { a -> return a.toString().trim().toLowerCase().endsWith(".jar") }
		def f_has_groovy = { a -> return ( a.toString().trim().toLowerCase().contains("groovy") ) }
		return ( f_ew_jar(ao) ) && ( !f_has_groovy(ao) )
	}
	
	jar {
		println "*** jar task beg ***"
		def cp1 = configurations.compile.collect { it }
		// note: might want to use configuration runtime instead for above line
		
		def fo = new File( "${buildDir}/jars.txt" ).newWriter()
		cp1.each {
			println it
			fo.write( "${it.name}\n" )
		}
		fo.flush()
		fo.close()
		
		def cp2       = cp1.clone().findAll { f_NotGroovyJar(it)	}
		def classpath = cp2.collect { it.directory ? it : zipTree(it) }
		
		from (classpath) {
			exclude 'META-INF/MANIFEST.MF'
		} 
		
		println "*** jar task end ***"
		// println "Press any key..."; System.in.read();
	}

Initial URL


Initial Description


Initial Title
Groovy Gradle make Fat Jar

Initial Tags
groovy

Initial Language
Groovy