4

当某些文件已经存在时,如何禁用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>
[...]

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

4

2 回答 2

7

检查您的独立 Ant 文件中是否存在该文件。例子:

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

<target name="time-consuming" depends="check-file" unless="fileExists">
    ...
</target>
于 2011-03-15T11:43:12.683 回答
2

使用仅在不存在<profile>时才有效的a:file.txt

<profiles>
    <profile>
        <id>createFile</id>
        <activation><file><missing>file.txt</missing></file></activation>
        <build><plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.6</version>
                <!-- etc -->
            </plugin>

        </plugins></build>
    </profile>
</profiles>

参考:

于 2011-03-15T12:08:24.373 回答