如果某个文件已经存在,如何禁用antrun?

yeg*_*256 3 java ant maven-2 maven maven-antrun-plugin

当某个文件已存在时,如何禁用maven-antrun-plugin执行?:

[...]
<plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <version>1.6</version>
  <executions>
    <execution>
      <phase>test</phase>
      <goals>
        <goal>run</goal>
      </goals>
      <configuration>
        <target>
          <!-- do something really complex in order to create file.txt -->
        </target>
      </configuration>
    </execution>
  </executions>
</build>
[...]
Run Code Online (Sandbox Code Playgroud)

执行需要一些时间,我不想每次都在file.txt那里重复它.

Lau*_*eyn 6

检查独立Ant文件中是否存在该文件.例:

<target name="check-file">
    <available file="foo.bar" property="fileExists" />
</target>

<target name="time-consuming" depends="check-file" unless="fileExists">
    ...
</target>
Run Code Online (Sandbox Code Playgroud)

  • @ yegor256确实,但我假设您使用外部Ant文件,而您的POM调用"耗时"目标. (2认同)