Ant构建失败,错误" SAXParseException:对于属性"

时间:2011-11-11 08:36:17

标签: java ant

D:\Test>ant -v
Apache Ant(TM) version 1.8.2 compiled on December 20 2010
Trying the default build file: build.xml
Buildfile: D:\Test\build.xml
Detected Java version: 1.5 in: C:\Program Files\Java\jdk1.5.0_22\jre
Detected OS: Windows XP
parsing buildfile D:\Test\build.xml with URI = file:/D:/Test/build.xml
Project base dir set to: D:\Test

BUILD FAILED
D:\Test\build.xml:6: Open quote is expected for attribute "dir" associated with an  elemen
t type  "mkdir".
        at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:320)
        at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:178)
        at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:82)
        at org.apache.tools.ant.Main.runBuild(Main.java:793)
        at org.apache.tools.ant.Main.startAnt(Main.java:217)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Caused by: org.xml.sax.SAXParseException: Open quote is expected for attribute "dir" assoc
iated with an  element type  "mkdir".
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseExcep
tion(ErrorHandlerWrapper.java:236)
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHan
dlerWrapper.java:215)
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorRe
porter.java:386)
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorRe
porter.java:316)
        at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.
java:1441)
        at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanAttributeValue(XMLScanne
r.java:802)
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanAttribute(
XMLNSDocumentScannerImpl.java:578)
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartEleme
nt(XMLNSDocumentScannerImpl.java:222)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$Fragment
ContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocu
ment(XMLDocumentFragmentScannerImpl.java:368)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Config
uration.java:834)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Config
uration.java:764)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXP
arser.java:1242)
        at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:307)
        ... 6 more

Total time: 0 seconds

D:\Test>

当我运行ant-v命令而不是创建构建时,我得到了上面的消息,并且有关变量的所有内容都已正确完成。我无法纠正它并创建构建。任何人都可以纠正这个错误吗?

的build.xml:

<?xml version = "1.0"?>
<project name="test" default="compile" basedir=".">
    <property name="src" value="."/>
    <property name="build" value="build"/>
    <target name="init">
        <mkdir dir="${build}"/>
    </target>
    <target name="compile" depends="init">
        <javac srcdir="${src}" destdir="${build}"/>
    </target>
</project>

1 个答案:

答案 0 :(得分:2)

我看起来你的build.xml文件中有无效内容(缺少公开引用)在第6行。

你可能有类似的东西

<mkdir dir=foo/>

你需要这样的东西

<mkdir dir="foo"/>