In my Maven build I use maven-processor-plugin
to generate JPA meta model like this
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.2.4</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
....
</execution>
</plugin>
Now I would like to skip the meta model generation based on a property, like this
$ mvn -Dspeed.up.build.from.eclipse=true
Unfortunately the maven-processor-plugin
doesn't support <skip>${speed.up.build.from.eclipse}</skip>
configuration tag like some plugins do.
I could put my plugin in a profile and then activate it based on my property. But then I need somehow to negate the value of the property...
So I need:
Is there some nice way to archieve it? If yes, how?
Judging from the documentation, there is indeed no skip
property.
In such a case, a possible solution is to use the hack of setting the phase to none
to disable the plugin execution. You would define 2 profiles
speed.up.build.from.eclipse
that would set a custom property maven-annotation-plugin.phase
to none
;You would then use the custom property as your phase in your plugin configuration.
Note that it is a hack because this is an undocumented feature.
Another solution (that I would recommend actually) would be to make a pull request adding that feature. The code is hosted on GitHub so you can easily fork it, patch it and make a pull request. In the mean time, you can use your custom plugin, and when the request is merged, you could drop your custom plugin.
Had similar issue with a different plugin, I opted for the following solution:
<properties>
<mvn.processor.goal>process</mvn.processor.goal>
</properties>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.2.4</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>${mvn.processor.goal}</goal>
</goals>
<phase>generate-sources</phase>
....
</execution>
</plugin>
Then when you run it you can do:
$ mvn -Dmvn.processor.goal=none
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