简体   繁体   English

Java ANT组合任务

[英]Java ANT to combine tasks

I am trying to write a task that will combine all the tasks in by build.xml 我正在尝试编写一个任务,它将结合build.xml中的所有任务

<project name="HW4_Build">

<target name="mkedir">
    <mkdir dir="bld/class/cscie55/hw4"/>
</target>

<target name="clean">
    <delete dir="bld"/>
</target>

<target name="compile" depends="clean, mkedir">
    <javac destdir="bld/class" srcdir="src/cscie55/hw4"/>
</target>

<target name="jar" depends="compile">
    <jar destfile="HW4.jar" basedir="bld/class"/>
</target>

</project>

Is following method right way to go about this? 以下方法是正确的方法吗?

<ant antfile="build"/>

In this build.xml you might just want to try: 在此build.xml中,您可能只想尝试:

<project name="HW4_Build" default="jar">

Because the jar target already includes the other targets via the dependency chain. 因为jar目标已经通过依赖关系链包含了其他目标。

<ant antfile="build"/>

Is used for invoking another build file. 用于调用另一个构建文件。 Not sure that's what you want. 不确定那是您想要的。

<antcall target="target"/>

Use this to define a target that combines all your other targets. 使用它来定义一个结合了所有其他目标的目标。

Although this won't exactly work in your case since you are using depends ... So you only need to call your last target in the dependency chain. 虽然这不会在你的情况正是工作,因为你正在使用depends ......所以,你只需要打电话给你的最后一个目标的依赖链。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM