Dónal
Dónal

Reputation: 187499

conditionally execute maven plugins

I have some Maven plugins configured in my pom.xml. I only want to execute these plugins if the tests are being run (tests may be skipped using either -Dmaven.test.skip=true or -DskipTests).

One of these plugins is bound to the process-classes build lifecycle phase and the other is bound to the pre-integration-test phase.

Upvotes: 44

Views: 40766

Answers (2)

Rasto
Rasto

Reputation: 31

the last example worked only when I set also value:

<property>
  <name>wsdl2java</name>
  <value>true</value>
</property>

Upvotes: -3

tenshi
tenshi

Reputation: 26566

You can use profile with special activation conditions like this:

<project>
  ...
  <profiles>
    <profile>
      <id>my-test-plugins</id>

      <activation>
        <property><name>!maven.test.skip</name></property>
        <property><name>!skipTests</name></property>
      </activation>
      <build>
        <plugins>

      <!-- define your plugins here -->

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

More info you can find here:

http://books.sonatype.com/mvnref-book/reference/profiles-sect-activation.html

Upvotes: 57

Related Questions