Strange side effect when patching a Manifest


(Andi) #1

Hi,

we need to patch an existing jar and I noticed that when I comment/uncomment the from() section inside the manifest configuration, our pom.xml generated with the maven-publish plugin are missing their dependencies (or not).

When commenting out the section as in the example all is good. Can anyone give me some hints on whats going wrong here?

//...
configurations {
  clientExeJars {
    description = 'Contains dependencies needed to build the Windows Client'
    transitive = false
  }
}
// ...

task patchSomeJar(type: Jar) {
  description = 'Takes the original jar and patches it with a splashscreen and a new manifest.'
  archiveName = 'some-patched.jar'
  destinationDir = file(someCfg.outDir)
  duplicatesStrategy = DuplicatesStrategy.EXCLUDE

  manifest {
//    from(
//      configurations.clientExeJars
//              .findAll { it.name.matches('some.*\\.jar') }
//              .collect { zipTree(it).findAll { it.name == 'MANIFEST.MF' } }
//    )
    attributes(
            "SplashScreen-Image": "splashscreen.png"
    )
  }
  from { configurations.clientExeJars.findAll { it.name.matches('some.*\\.jar') }.collect { zipTree(it) } }
}

// ...

(Andi) #3

I don’t know exactly why but using:

from {
  zipTree(
          configurations.clientExeJars.filter { it.name.matches('some.*\\.jar') }.singleFile
  ).filter { it.name == 'MANIFEST.MF' }.singleFile
}

and the side effect has gone.