开发者

ant copy folder from zip file

I have a zip file with the following structure

apache-tomcat-6.0.26.z开发者_高级运维ip apache-tomcat-6.0.26/webapps/manager

I want to copy just the manager folder into another dir

I tried

<copy todir="${tomcat.webapp.dir}/manager/" includeEmptyDirs="true">
 <zipfileset src="${tomcat.zip.file}/" >
  <patternset>
   <include name="apache-tomcat-${tomcat.version}/webapps/manager" />
  </patternset>
 </zipfileset>
</copy>

The output manager folder contains the following structure apache-tomcat-6.0.26/webapps/manager. I just need the manager folder and its content not its parents.

Tried changing the to but get an error msg that the folder is not an archieve


Use a patternset to restrict the files to be extracted from the zip, coupled with a mapper that strips off the leading directory name

<unzip src="apache-tomcat-${tomcat.version}.zip" dest="${tomcat.webapp.dir}/manager">
    <patternset>
        <include name="**/webapps/manager/**"/>
    </patternset>
    <globmapper from="apache-tomcat-${tomcat.version}/webapps/manager/*" to="*"/>
</unzip>


Here's my solution:

<copy todir="${tomcat.webapp.dir}/manager/" includeEmptyDirs="true">
 <zipfileset src="${tomcat.zip.file}/" prefix="apache-tomcat-${tomcat.version}/webapps" >
  <patternset>
   <include name="apache-tomcat-${tomcat.version}/webapps/manager" />
  </patternset>
 </zipfileset>
</copy>

I intensely dislike the <unzip> task because when it fails, it gives no errors (the default for <copy> is to fail on error, which is exactly what you want in a build.)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜