無需解壓整個zip文件,使用
如果log4j.properties駐留在拉鍊的rootdirectory:
<project>
<!-- unzip log4j.properties only -->
<unzip src="foo.zip" dest=".">
<patternset>
<include name="log4j.properties" />
</patternset>
</unzip>
<!-- put new key in or overwrite if already existing -->
<propertyfile file="log4j.properties">
<entry key="log4j.logger.com.foobar.xyz" value="ERROR" />
</propertyfile>
<!-- update zip with modified log4j.properties -->
<zip destfile="foo.zip" update="true">
<fileset dir="." includes="log4j.properties" />
</zip>
</project>
否則,如果log4j.properties駐留在拉鍊的任何子目錄:
<project>
<!-- unzip log4j.properties only -->
<unzip src="foo.zip" dest=".">
<patternset>
<include name="**/log4j.properties" />
</patternset>
</unzip>
<fileset dir="." includes="**/log4j.properties" id="foo"/>
<!-- put new key in or overwrite if already existing -->
<propertyfile file="${toString:foo}">
<entry key="log4j.logger.com.foobar.xyz" value="ERROR" />
</propertyfile>
<!-- update zip with modified log4j.properties -->
<zip destfile="foo.zip" update="true">
<fileset dir="." includes="${toString:foo}" />
</zip>
</project>
不知道香草螞蟻一條筆直的路,但沒有必要與解壓縮整個檔案搗鼓..等等。 ,處理log4j.properties就足夠了,請參閱下面的答案。 – Rebse