
Question:
Is there a way I can modify a file in a jar using ant script. Like, I have a x.properties in a y.jar. I want to edit this x.properties and put it back into the y.jar using ant script. Is this possible?
Solution:1
To extract a file from a jar:
<unjar src="y.jar" dest="build"> <patternset> <include name="x.properties"/> </patternset> </unjar>
To add it back in:
<jar jarfile="y.jar" update="true"> <fileset dir="." includes="x.properties"/> </jar>
Solution:2
jar -xvf <filename>
extracts a file out of a jar.
jar -uvf <filename>
can update a file in the jar.
You can use a script to do this and then use Ant to call the script.
Solution:3
I usually unpack the whole jar file, alter the file I want to alter, and then create a new jar file. I is probably not the fasted way, but my build scrips are not time critical.
Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
EmoticonEmoticon