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.
Usage of a Maven Plugin xml you can use the shorthand notation to execute the plugin: mvn <prefix>:<goal> , commonly the “prefix” is the artifact ID minus the “-maven-plugin”. For example mvn example:version .
pluginManagement: is an element that is seen along side plugins. Plugin Management contains plugin elements in much the same way, except that rather than configuring plugin information for this particular project build, it is intended to configure project builds that inherit from this one.
In Maven, there are two kinds of plugins, build and reporting: Build plugins are executed during the build and configured in the <build/> element. Reporting plugins are executed during the site generation and configured in the <reporting/> element.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With