开发者

A zip file cannot include itself - Ant build error

开发者 https://www.devze.com 2023-01-10 08:09 出处:网络
I have error at the first line of the following code while building with Ant builder, <war warfile=\"${wartemp.dir}/${name}.war\" basedir=\"${wartemp.dir}\" webxml=\"${wartemp.dir}/WEB-INF/web.xml

I have error at the first line of the following code while building with Ant builder,

<war warfile="${wartemp.dir}/${name}.war" basedir="${wartemp.dir}" webxml="${wartemp.dir}/WEB-INF/web.xml">
            <include name="*"/>
            <include n开发者_如何学Pythoname="scripts/**"/>
            <include name="styles/**"/>
            <include name="images/**"/>
            <include name="WEB-INF/*.*"/>
            <include name="WEB-INF/lib/**"/>
            <include name="WEB-INF/views/**"/>
            <include name="WEB-INF/classes/**"/>
            <include name="WEB-INF/jsp/**"/>
            <include name="WEB-INF/resources/**"/>
            <include name="WEB-INF/spring/**"/>
            <include name="WEB-INF/messages/**"/>
            <include name="WEB-INF/layouts/**"/>
            <exclude name="WEB-INF/web.xml"/>           
            <exclude name="**/.*"/>
        </war>

The error message is:

"... /WEB-INF/build.xml:67: A zip file cannot include itself" line 67 is the first line of the snippet posted above.

I am beginner to Spring framework. I am using Spring version 3 with springsource toolsuite. How to fix this? thanks.


Your basedir is the same dir as where you are sending the outputted war file. This is not a problem in itself, the problem is you are including * as input which will include the output file.

To fix this you could either exclude the output file from the included files, e.g.:

<exclude name="${name}.war"/>

or you could write the war file to a different directory structure than you are reading from, e.g.:

<mkdir dir="${war.output.dir}" />
<war warfile="${war.output.dir}/${name}.war" ...>


I guess I found another cause of the "A zip file cannot include itself" problems in any "zip-alike" Ant tasks (zip, jar ...):

Remember, setting the "basedir" attribute is already the first set of files to include! You need to explicitly exclude the zip file being created at this level (with "excludes" attribute. Or, starting with Ant 1.7, with nested "excludes" element).

The "fileset" nested element is another "set" for the zip task. You should ensure that the zip "itself" will be excluded from the set also with another explicit exclude. And so on...

0

精彩评论

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