Can ant replace text in files inside jar / ear / war?

I want to create an ear file once, and then use ant to change some parameters in the application.xml file, property files, etc.

Is there any way to do this with ant?

[edit] Just found this

How to change file in jar file with ant?

+5
source share
2 answers

The only way to change the file inside your jar or ear is to use the task <unzip>, use the task <replace>to change the fields in the file, and then reformat the file with <zip>or <jar>/<ear>.

There are several ways to handle this without unpacking and unpacking your ear / jar / war files:

  • - , . application.xml . , .

  • , , . Jenkins . , , , . , Dev QA STAGE to Production , , . , AntContrib <foreach> application.xml. <filterset> <copy> application.xml .

+4

-

<zip destfile="tmp.jar" >
  <zipfileset src="lib/myjar.jar" excludes="org/example/My*.class" />
  <zipfileset dir="bin" includes="org/example/My*.class"  />
</zip>
<move file="tmp.jar" tofile="lib/myjar.jar"/>

tmp.jar, myjar.jar , , My org/example. bin. jar .

0

All Articles