蚂蚁不发起战争目标
我在 build.xml 中有三个目标。
过程中没有错误。
前两个运行成功,但第三个未启动并且结果中没有 war 文件。
这是我的 buid.xml
<?xml version="1.0" encoding="utf-8"?>
<project name="LoginProject" basedir="." default="compile">
<property name="src.dir" value="src"/>
<property name="classes.dir" value="build/classes"/>
<property name="war.dir" value="build/war"/>
<target name="clean">
<delete dir="build"/>
</target>
<target name="compile" depends="clean">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}" destdir="${classes.dir}" includeantruntime="false">
<classpath location="lib/myfaces-api-2.0.2.jar"/>
<classpath location="lib/servlet-api.jar"/>
</javac>
</target>
<target name="war" depends="compile">
<mkdir dir="${war.dir}"/>
<war destfile="${war.dir}/loginproject.war" webxml="web/WEB-INF/web.xml">
<fileset dir="WebContent"/>
<lib dir="lib"/>
<classes dir="${classes.dir}"/>
</war>
</target>
</project>
这是来自命令行的日志
D:\Work\Java\AntLoginProject>ant
Buildfile: D:\Work\Java\AntLoginProject\build.xml
clean:
[delete] Deleting directory D:\Work\Java\AntLoginProject\build
compile:
[mkdir] Created dir: D:\Work\Java\AntLoginProject\build\classes
[javac] Compiling 3 source files to D:\Work\Java\AntLoginProject\build\classes
BUILD SUCCESSFUL
Total time: 1 second
我做错了什么?
我将默认目标更改为战争。 但现在出现错误。
D:\Work\Java\AntLoginProject>ant war
Buildfile: D:\Work\Java\AntLoginProject\build.xml
BUILD FAILED
D:\Work\Java\AntLoginProject\build.xml:30: Content is not allowed in trailing section.
Total time: 0 seconds
I have three targets in build.xml.
There are not errors in process.
First two runned successfully, but third don't start and there are not war file in result.
This is my buid.xml
<?xml version="1.0" encoding="utf-8"?>
<project name="LoginProject" basedir="." default="compile">
<property name="src.dir" value="src"/>
<property name="classes.dir" value="build/classes"/>
<property name="war.dir" value="build/war"/>
<target name="clean">
<delete dir="build"/>
</target>
<target name="compile" depends="clean">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}" destdir="${classes.dir}" includeantruntime="false">
<classpath location="lib/myfaces-api-2.0.2.jar"/>
<classpath location="lib/servlet-api.jar"/>
</javac>
</target>
<target name="war" depends="compile">
<mkdir dir="${war.dir}"/>
<war destfile="${war.dir}/loginproject.war" webxml="web/WEB-INF/web.xml">
<fileset dir="WebContent"/>
<lib dir="lib"/>
<classes dir="${classes.dir}"/>
</war>
</target>
</project>
And this is log from command line
D:\Work\Java\AntLoginProject>ant
Buildfile: D:\Work\Java\AntLoginProject\build.xml
clean:
[delete] Deleting directory D:\Work\Java\AntLoginProject\build
compile:
[mkdir] Created dir: D:\Work\Java\AntLoginProject\build\classes
[javac] Compiling 3 source files to D:\Work\Java\AntLoginProject\build\classes
BUILD SUCCESSFUL
Total time: 1 second
What wrong i do?
I change default target to war.
But now get error.
D:\Work\Java\AntLoginProject>ant war
Buildfile: D:\Work\Java\AntLoginProject\build.xml
BUILD FAILED
D:\Work\Java\AntLoginProject\build.xml:30: Content is not allowed in trailing section.
Total time: 0 seconds
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
按如下方式调用构建:
或者将默认目标从“compile”更改为“war”
更新:
默认目标更改如下:
Call the build as follows:
Alternatively change the default target from "compile" to "war"
Update:
The default target is changed as follows:
您的默认目标是
compile
并且您只调用ant
。如果您想运行非默认目标,则需要指定ant targetName
。在你的例子中:ant war
。Your default target is
compile
and you only callant
. You need to specifyant targetName
if you want to run a target that's not default. In your case:ant war
.