« Return to Thread: creating a manifest-file

Re: creating a manifest-file

by Helmut Denk :: Rate this Message:

Reply to Author | View in Thread

samples are always a good startingpoint ...
maybe a wiki-page  or snipplr.com could become source
for a collection of useful gradle-snippets.

Adam Murdoch-2 wrote:
I wonder if this is the start of a 'java-application' plugin
such a plugin targets a typical usecase but
implicates the danger of beeing 'overgeneric'.


for the interested gradle-user ...
i improved my script a little bit:

Set runtimeLibFiles = configurations.runtime.resolve()

manifest.mainAttributes(
  'Provider': group,
  'Main-Class': 'insert_mainclass_here', 
  'Implementation-Version': version,
  'Built-With': 'gradle-' + new GradleVersion().getVersion(),
  'Class-Path': getManifestCp(runtimeLibFiles))

task distZip(type: Zip) {
  fileSet(dir: libsDir)
  zipFileSet(dir: 'lib') {
  	  runtimeLibFiles.each {	
	  	include(it.name)
	  }
	  prefix = 'lib'
  }
  files(new File('insert_name_of_propertiesfile_here'))
}

String getManifestCp(Set runtimeLibFiles) {
	StringBuffer manifestCp = new StringBuffer()
	runtimeLibFiles.eachWithIndex() {
				file, index ->
		if (index > 0) 
			manifestCp.append(' ')
		manifestCp.append("lib/$file.name")
	}
	return manifestCp.toString()	
}  

 « Return to Thread: creating a manifest-file