|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
creating a manifest-filehi gradle-users,
with help from the mailinglist and some try & error i managed to create the manifest-file i want. my script looks like this:
manifestCp = new StringBuffer()
configurations.runtime.allDependencies.each { dep ->
manifestCp.append(' ')
manifestCp.append("lib/${dep.getName()}-${dep.getVersion()}.jar")
}
manifestCp.delete(0,1)
manifest.mainAttributes(
'Provider': 'com.mycompany',
'Main-Class': 'insert_mainclass_here',
'Implementation-Version': version,
'Built-With': 'gradle', // todo: get gradle-version
'Class-Path': manifestCp.toString())
but damn ... this could be more elegant ... right ? ;-) have a nice time |
|
|
Re: creating a manifest-fileHelmut Denk wrote: > hi gradle-users, > > with help from the mailinglist and some try & error > i managed to create the manifest-file i want. > > my script looks like this: > > > manifestCp = new StringBuffer() > > configurations.runtime.allDependencies.each { dep -> > manifestCp.append(' ') > manifestCp.append("lib/${dep.getName()}-${dep.getVersion()}.jar") > } > manifestCp.delete(0,1) > > manifest.mainAttributes( > 'Provider': 'com.mycompany', > 'Main-Class': 'insert_mainclass_here', > 'Implementation-Version': version, > 'Built-With': 'gradle', // todo: get gradle-version > 'Class-Path': manifestCp.toString()) > > > but damn ... this could be more elegant ... > right ? ;-) > > It could. I wonder if this is the start of a 'java-application' plugin which extends the java plugin, and which packages your project as an application in various ways: - an executable jar, like above - a windows exe using Launch4J or similar - a unix launch script - a mac OS X app bundle - RPMs, web start, etc > have a nice time > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: creating a manifest-filesamples are always a good startingpoint ...
maybe a wiki-page or snipplr.com could become source for a collection of useful gradle-snippets. 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()
}
|
|
|
Re: creating a manifest-fileI'm trying to convert this to the "new way" as of 0.9 "Dec 10th edition"
and I've fallen off the map. I can get the jar parts to work just fine but converting the distZip task is giving me problems. I can currently get it to zip the jars in the build/libs _or_ the dependencies but not both. Any ideas? -Paul Helmut Denk wrote: > 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() > } > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: creating a manifest-file AKA: executable jarOk, to prove that I'm not completely helpless, random inspiration and
trial and error has gotten me the following (note: I've create a separate artifact for the executable jar... for good or ill): manifest.mainAttributes( "Extension-Name": project.name, "Implementation-Title": "Your Title Here", "Implementation-Vendor-Id" : group, "Implementation-Version": version ) String getManifestClassPath( Set runtimeLibFiles ) { return "lib/" + runtimeLibFiles.name.join( " lib/" ); } task execJar( type: Jar, dependsOn:classes ) { classifier = 'exec' from sourceSets.main.classesDir manifest.mainAttributes( "Main-Class":"insert fully qualified class name", "Class-Path": getManifestClassPath(configurations.runtime.resolve()) ) } task execZip( type: Zip, dependsOn: execJar ) { from( libsDir ) { include "*-exec.jar" } into('lib') { from configurations.runtime.resolve() } } ...and that builds a zip that when expanded has everything needed to run my app. It is essentially doing what Helmut posted before. Hopefully this is useful to someone. Critiques welcome... I'm never confident I've done anything the "best way" with gradle yet. :) -Paul Paul Speed wrote: > I'm trying to convert this to the "new way" as of 0.9 "Dec 10th edition" > and I've fallen off the map. > > I can get the jar parts to work just fine but converting the distZip > task is giving me problems. I can currently get it to zip the jars in > the build/libs _or_ the dependencies but not both. > > Any ideas? > -Paul > > Helmut Denk wrote: >> 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() >> } > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Free embeddable forum powered by Nabble | Forum Help |