Maven antrun plugin not executing target

352 Views Asked by At

I am trying to use the maven antrun plugin to automatically run javascript tests from our java build. Everything works fine except for the fact that it will not run the tasks defined inside of a <target></target> block.

<build>
  <plugins>
    <plugin>
      <artifactId>maven-antrun-plugin</artifactId>
      <executions>
        <execution>
          <id>test</id>
          <phase>test</phase>
          <configuration>
          <!-- this does block is never executed -->
            <target unless="skipTests"> 
              <echo message="Launching javascript tests"/>
              <exec executable="grunt" dir="${project.basedir}" failonerror="true">
                <arg line="--no-color test"/>
              </exec>
            </target>
          </configuration>
          <goals>
            <goal>run</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

However, if I replace the <target></target> with <tasks></tasks>, it is always executed. I would like to use the <target> since it allows conditional execution of the task by defining the -DskipTests attribute.

Edit:

Turns out that <tasks unless="skipTests"></tasks> is valid and is getting executed properly unless the skipTests attribute is defined. It is found nowhere in the documentation. I am still looking for an answer why this is happenning.

0

There are 0 best solutions below