I have a file which maintains a build-number for release build. Everytime a release build is made, this number is incremented and the file is saved into svn repository.
Now say I have a plugin to do this job and i have created a build profile. But I need this plugin to be triggered only when build profile is activated and not otherwise. I guess adding pluginManagement to profile could be the way out like below. Any suggestions?
<profiles>
<id>release</id>
<build>
<pluginManagement>
<plugins>
<plugin>
..
</plugin>
</plugins>
</pluginManagement>
</build>
</profiles>
A profile in Maven is an alternative set of configuration values which set or override default values. Using a profile, you can customize a build for different environments. Profiles are configured in the pom. xml and are given an identifier.
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.
I would suggest you take a look at the documentation for build profiles first. You can find that here. The first thing you want to look over is this section:
How can a profile be triggered? How does this vary according to the type of profile being used?
Basically, once you understand that, note that what you put in your profile section is pretty close to what you have outside your profile. That being said, if you need a profile specific build section, it should emulate what you would have outside the profile - if you take a look at the pom.xsd it is the exact same I believe.
So, for example:
<profiles>
<profile>
<id>full-build</id>
<activation>
<property>
<name>build</name>
<value>full</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo.webstart</groupId>
<artifactId>webstart-maven-plugin</artifactId>
<version>1.0-beta-1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jnlp</goal>
</goals>
</execution>
</executions>
<configuration>
<resourcesDirectory>src/main/web</resourcesDirectory>
....
This would be triggered by running: mvn package -Dbuild=full
I hope this helps.
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