Java 如何在Ant中将命令添加到目标的末尾?

Java 如何在Ant中将命令添加到目标的末尾?,java,ant,Java,Ant,我对蚂蚁了解不多。我在网上找到了一段很好的代码,我想把它附加到一个我无法直接编辑的已经存在的目标的末尾。我该怎么做 为了清晰起见,Java示例: public methodName() { super.methodName(); a++; } 下面是一个小示例Ant构建文件。默认目标是post.process。这可能是您希望在现有进程运行后执行的处理。我还添加了一个名为“around”的目标。这将调用before目标,然后是现有目标,最后是process.process目标 <p

我对蚂蚁了解不多。我在网上找到了一段很好的代码,我想把它附加到一个我无法直接编辑的已经存在的目标的末尾。我该怎么做

为了清晰起见,Java示例:

public methodName() {
  super.methodName();
  a++;
}

下面是一个小示例Ant构建文件。默认目标是post.process。这可能是您希望在现有进程运行后执行的处理。我还添加了一个名为“around”的目标。这将调用before目标,然后是现有目标,最后是process.process目标

<project name="Test Dependency" basedir="." default="post.process">

    <target name="existing.target" description="Existing target">
        <echo>Existing target that you cannot change</echo>
    </target>

    <target name="post.process"  description="new post processing " depends="existing.target">
        <echo>New target that runs after existing target</echo>
    </target>

    <target name="around"  description="processing around existing target" depends="before.process,existing.target,post.process"/>

    <target name="before.process" description="run before existing target">
       <echo>runs before existing target when target around called </echo>
    </target>

</project>.

代码示例看起来不像Ant—您确定发布了正确的内容吗?正如我所说,是Java。它展示了相同的概念,但使用了不同的语言。我懂Java,但不懂Ant。Ant是基于XML的。要向目标添加更多处理,只需在and标记中向要执行的任务添加调用即可。标记之间的所有内容都被认为是为该目标执行的代码。目标还可以具有要求在当前目标之前执行另一个目标的依赖项。希望这有帮助。我很难弄清楚你想做什么。我会在标签之间添加代码,但我不能编辑目标本身。它已导入,我可以添加额外的目标,但我想知道是否有方法扩展现有目标。如果无法编辑现有目标,则很难扩展现有目标。您可能会创建一个新目标,该目标“依赖”现有目标。这样,当您执行新目标时,它必须首先运行该目标,然后再运行新的单独目标。
Mikes-MacBook-Pro:J7 mike$ ant
Buildfile: build.xml

existing.target:
     [echo] Existing target that you cannot change

post.process:
     [echo] New target that runs after existing target

BUILD SUCCESSFUL
Total time: 0 seconds
Mikes-MacBook-Pro:J7 mike$ ant around
Buildfile: build.xml

before.process:
     [echo] runs before existing target when target around called 

existing.target:
     [echo] Existing target that you cannot change

post.process:
     [echo] New target that runs after existing target

around: