How do I manipulate a list of jar files?

Hi there

In my current project, I have to manipulate a list of third party jar files. I’m able to get the files, using a copy task, but I cannot figure out how to manipulate individual jar files, e.g. remove INDEX.LIST from each.

In my small example, I have the following copy task:

task removeIndexAndSign(type: Copy) {
          eachFile( { file ->
        if('.jar')) {
            *** STUFF GOES HERE ***
          from thirdParty
    include '**/*'
          into 'build/client'
          from (project(':someSubProject').fileTree('build/libs/')) {

I could of course add a jar task for each jar file, but that somehow doesn’t seem right, and how do I make Gradle execute it?! Isn’t there an easier way? I’ve literally spent hours on this seemingly easy problem, but for some reason, the solution eludes me…

Help would be greatly appreciated!

To be clear, are you trying to copy the jar and modify it at the same time?

Well, not exactly “the jar”, but rather a set of jar files the system depends on. Problem is, that some of the jar files has invalid jar file references in their INDEX.LIST files, so I need to replace that and sign the jar files with the new content.