Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable antrun if certain file already exists?

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.

like image 567
yegor256 Avatar asked Jan 21 '23 05:01

yegor256


1 Answers

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>
like image 161
Laurent Pireyn Avatar answered Jan 30 '23 02:01

Laurent Pireyn