开发者

Ant script to modify a jar

开发者 https://www.devze.com 2023-01-08 02:07 出处:网络
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. I

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消