开发者

How to disable antrun if certain file already exists?

开发者 https://www.devze.com 2023-02-17 02:19 出处:网络
How can I disable maven-antrun-plugin execution when certain file already exists?: [...] <plugin>

How can I disable maven-antrun-plugin execution when certain file already exists?:

[...]
<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>
[...]

The execution takes some time and I don't want to repeat it every time when file.txt is already there.


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>


Use a <profile> that's only active if file.txt doesn't exist:

<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>

Reference:

  • Introduction to Build Profiles
0

精彩评论

暂无评论...
验证码 换一张
取 消