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

Check for the presence of the file in your standalone Ant file. Example:

<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 に答える