Download jar from nexus and add or update new class files to it

Hi,

I have a third party jar in nexus. I have a requirement to

  1. Download the jar from Nexus using jenkins pipeline.
  2. Add or remove class files of the downloaded jar
  3. Upload it back to nexus with new version.

I got the first step, but not able to implement next steps.

configurations {
    copyConf
}
dependencies {
copyConf "jarfiletobeupdated"
}
task copyTask(type: Copy) {
	File tempPath = new File("$buildDir/tmp/patch/")
	tempPath.mkdirs()
	File dir = new File("$tempPath/downloads");
	if(!dir.exists())
	        {
			dir.mkdirs()
			}
    from configurations.copyConf
    into "$dir"
    println "Downloading .... "+'$copyConf'
    println "JAR DOWNLOADED "+dir
     exec {
        commandLine 'which', 'ls'
        workingDir '/opt/app/workspace/ORG/Project/build/tmp/patch/downloads'
       commandLine 'ls', '-lrt'  //Here it shows the downloaded jar
       //Need logic to add some class files that I have in a Set
      // Need logic to delete classes that I have in another Set
      // Upload the updated jar back to nexus with new version
   }
}

Can someone help with this.