蚂蚁不发起战争目标

发布于 2025-01-05 02:03:22 字数 1923 浏览 2 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼眸 2025-01-12 02:03:22

按如下方式调用构建:

ant war

或者将默认目标从“compile”更改为“war”


更新:

默认目标更改如下:

<?xml version="1.0" encoding="utf-8"?>
<project name="LoginProject" basedir="." default="war">
..

Call the build as follows:

ant war

Alternatively change the default target from "compile" to "war"


Update:

The default target is changed as follows:

<?xml version="1.0" encoding="utf-8"?>
<project name="LoginProject" basedir="." default="war">
..
你丑哭了我 2025-01-12 02:03:22

您的默认目标是 compile 并且您只调用 ant。如果您想运行非默认目标,则需要指定 ant targetName。在你的例子中:ant war

Your default target is compile and you only call ant. You need to specify ant targetName if you want to run a target that's not default. In your case: ant war.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文