Is there a way I can modify a file in a jar using ant s开发者_开发问答cript. 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?
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>
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.
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.
精彩评论