How to call fatJar task multiple times from same

(john caron) #1

Sorry for the simple question.

I’m using fatJar to create several artifacts. Id like to do it all in one task, but I dont know how to call the fatJar task more than one time from the same eg id like to do

apply plugin: 'fatjar'
  task release(dependsOn: ['fatJar', 'fatJar2]) << {
  where fatJar and fatJar2 are both fatJar tasks

thanks for any help!

(Peter Niederwieser) #2

Are you referring to this ‘fatjar’ plugin? If yes, it looks like that plugin only adds a single ‘fatJar’ task. But then I don’t understand your question.

(john caron) #3

Yes thats the plugin.

Sorry, I suspect my question is so easy or so hard it doesnt make much sense.

I know how to make 1 fatJar artifact in a, but not more than one. So I guess the question is "how do I make more than one artifact, using the fatJar plugin, from a single task?

Heres a more complete example of how far Ive gotten:

apply plugin: 'fatjar'
  dependencies {
  compile project(':cdm')
  compile project(':bufr')
  compile project(':grib')
  compile (project(':opendap'))
{ // eliminate servlet
      transitive = false
  compile (project(':visad')) {
 // eliminate original visad.jar
    transitive = false
  runtime ('org.slf4j:slf4j-jdk14:1.6.4')
  jar {
  manifest {
    attributes 'Implementation-Title': 'toolsUI'
  ext {
  ncIdvJar = 'ncIdv-'+version+'.jar'
  webstartWorkingDir = "build/signed"
  webstartDir = webdir + "webstart"
  fatJar {
// does not inherit from parent jar
  archiveName = ncIdvJar
  manifest {
    attributes 'Implementation-Title': ncIdvJar,
     'Implementation-Version': version,
     'Implementation-Vendor': 'UCAR/Unidata',
     'Implementation-Vendor-Id': 'edu.ucar',
     'Built-On': new Date()
  exclude 'DATE'
  // crap from other packages
  exclude 'JDOM*'
  exclude '*.html'
  exclude 'META-INF/*.txt'
  exclude 'META-INF/*.xml'
  exclude 'nom/**'
  exclude 'edu/wisc/**'
  exclude 'visad/**'
  task releaseCdm(dependsOn: ['fatJar']) << {
  println "copy " + ncIdvJar + " to " + ftpdir
  copy { // does not give error message
    from 'build/libs/' + ncIdvJar
    into ftpdir


(Peter Niederwieser) #4

It all depends on if and how the ‘fatjar’ plugin supports multiple ‘fatJar’ tasks. At first sight, I’d say it doesn’t, but I recommend to ask the author of the plugin. Or you don’t use the plugin and declare your own ‘fatJar’ tasks.

(john caron) #5

Well, I need to use the fatJar plugin, which has the fatJar task.

Is there a way to wrap that task in one of my own?

(Peter Niederwieser) #6

Is there a way to wrap that task in one of my own?

If the plugin provides a new task type, you can declare multiple tasks of that type. But it seems to add a single ‘Jar’ task, in which case you are left with that. Of course you can declare additional ‘Jar’ tasks yourself.