ANT war任务失败,出现奇怪的错误消息

时间:2010-02-17 11:03:00

标签: ant properties war

我正在尝试使用ant从eclipse项目中创建一个war文件 负责任的蚂蚁目标看起来像这样

<target name="jar" depends="build" description="Erzeugt das WAR File">
    <war destfile="${project.dir.dist}/xyz.jar" webxml="${basedir}/WebRoot/WEB-INF/web.xml" duplicate="fail" basedir="${basedir}">
        <lib dir="${project.dir.dist}" excludesfile="${project.dir.dist}/xyz.jar" />
        <classes dir="${project.dir.bin}" />
        <webinf dir="${basedir}/WebRoot/WEB-INF" excludes="*.class" />
        <metainf dir="${basedir}/WebRoot/META-INF" />
    </war>
</target>

它失败并出现以下错误: F:\ eclipse_workspaces \ skyeye \ railWeb \ build.xml:35:属性中的语法错误:??? ??? I8?

谷歌搜索只出现了这个:http://209.85.135.132/search?q=cache:OrmNOY9EJd0J:teamcity.jetbrains.com/viewLog.html%3Bjsessionid%3D114D52086BAE423B2F69A99B4CFACACD%3FbuildId%3D29573%26tab%3DbuildChangesDiv%26buildTypeId%3Dbt134+ant+war+task+%22Syntax+error+in+property%22&cd=1&hl=en&ct=clnk&client=firefox-a

任何人都能解释一下,到底发生了什么事?

2 个答案:

答案 0 :(得分:7)

问题是我使用'excludesFile'假设它会排除单个文件。相反,ANT试图将其解析为属性文件,因为它实际上是一个jar文件而变得困难。

答案 1 :(得分:1)

documentation中给出了排除jar文件的正确方法。如果有人遇到同样的问题,他们可以参考这个链接。

此示例摘自文档,此处我们从jdbc1.jar

中删除lib
Assume the following structure in the project's base directory:

thirdparty/libs/jdbc1.jar
thirdparty/libs/jdbc2.jar
build/main/com/myco/myapp/Servlet.class
src/metadata/myapp.xml
src/html/myapp/index.html
src/jsp/myapp/front.jsp
src/graphics/images/gifs/small/logo.gif
src/graphics/images/gifs/large/logo.gif
then the war file myapp.war created with


<war destfile="myapp.war" webxml="src/metadata/myapp.xml">
  <fileset dir="src/html/myapp"/>
  <fileset dir="src/jsp/myapp"/>
  <lib dir="thirdparty/libs">
    <exclude name="jdbc1.jar"/>
  </lib>
  <classes dir="build/main"/>
  <zipfileset dir="src/graphics/images/gifs"
              prefix="images"/>
</war>


will consist of
WEB-INF/web.xml
WEB-INF/lib/jdbc2.jar
WEB-INF/classes/com/myco/myapp/Servlet.class
META-INF/MANIFEST.MF
index.html
front.jsp
images/small/logo.gif
images/large/logo.gif