Ok, 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


Reply via email to