如何根据build.xml中定义的taskdef动作列表中的要求执行taskdef动作?
How to execute taskdef actions based on requirement among the list of taskdef actions defined in the build.xml?
我有一个 build.xml,它有不同的 taskdef 操作。
虽然 运行 我想从命令行调用 taskdef 操作,就像我们可以为 ant 目标做的那样。
我的问题是如何从命令行运行 taskdef 操作。在此处附加示例代码,我只想从命令行 运行 第一个 taskdef helloworld。
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="MyTask" basedir="." default="use">
<taskdef name="helloworld" classname="HelloWorld" classpath="${ant.project.name}.jar"/>
<helloworld/>
<taskdef name="helloworld1" classname="HelloWorld1" classpath="${ant.project.name}.jar"/>
<helloworld1/>
<taskdef name="helloworld2" classname="HelloWorld2" classpath="${ant.project.name}.jar"/>
<helloworld2/>
</project>
如下为每个任务创建一个单独的目标。请注意默认 "use" 目标将如何 运行 所有三个任务:
<project name="MyTask" basedir="." default="use">
<target name="use" depends="helloworld,helloworld1,helloworld2"/>
<target name="helloworld">
<taskdef name="helloworld" classname="HelloWorld" classpath="${ant.project.name}.jar"/>
<helloworld/>
</target>
<target name="helloworld1">
<taskdef name="helloworld1" classname="HelloWorld1" classpath="${ant.project.name}.jar"/>
<helloworld1/>
</target>
<target name="helloworld2">
<taskdef name="helloworld2" classname="HelloWorld2" classpath="${ant.project.name}.jar"/>
<helloworld2/>
</target>
</project>
我有一个 build.xml,它有不同的 taskdef 操作。
虽然 运行 我想从命令行调用 taskdef 操作,就像我们可以为 ant 目标做的那样。
我的问题是如何从命令行运行 taskdef 操作。在此处附加示例代码,我只想从命令行 运行 第一个 taskdef helloworld。
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="MyTask" basedir="." default="use">
<taskdef name="helloworld" classname="HelloWorld" classpath="${ant.project.name}.jar"/>
<helloworld/>
<taskdef name="helloworld1" classname="HelloWorld1" classpath="${ant.project.name}.jar"/>
<helloworld1/>
<taskdef name="helloworld2" classname="HelloWorld2" classpath="${ant.project.name}.jar"/>
<helloworld2/>
</project>
如下为每个任务创建一个单独的目标。请注意默认 "use" 目标将如何 运行 所有三个任务:
<project name="MyTask" basedir="." default="use">
<target name="use" depends="helloworld,helloworld1,helloworld2"/>
<target name="helloworld">
<taskdef name="helloworld" classname="HelloWorld" classpath="${ant.project.name}.jar"/>
<helloworld/>
</target>
<target name="helloworld1">
<taskdef name="helloworld1" classname="HelloWorld1" classpath="${ant.project.name}.jar"/>
<helloworld1/>
</target>
<target name="helloworld2">
<taskdef name="helloworld2" classname="HelloWorld2" classpath="${ant.project.name}.jar"/>
<helloworld2/>
</target>
</project>