无需解压整个 zipfile,使用
如果 log4j.properties 位于 zip 的根目录中:
<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 位于 zip 的任何子文件夹中:
<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>