Fork me on GitHub

Plugin Documentation

Goals available for this plugin:

Goal Description
build-helper:add-resource Add more resource directories to the POM.
build-helper:add-source Add more source directories to the POM.
build-helper:add-test-resource Add more test resource directories to the POM.
build-helper:add-test-source Add test source directories to the POM.
build-helper:attach-artifact Attach additional artifacts to be installed and deployed.
build-helper:bsh-property Define one or many properties as a result of a Beanshell script invocation. Like gmaven-plugin, some variables are defined:
  • project: the actual Maven project,
  • session: the executing MavenSession,
  • settings: the executing Settings.
  • log: the logger of the Mojo (see org.apache.maven.plugin.AbstractMojo.getLog()).
build-helper:cpu-count Retrieve number of CPUs with project factor, and place it under a configurable project property
build-helper:help Display help information on build-helper-maven-plugin.
Call mvn build-helper:help -Ddetail=true -Dgoal=<goal-name> to display parameter details.
build-helper:hostname Retrieve current hostname and place it under a configurable project property
build-helper:local-ip Retrieve current host IP address and place it under a configurable project property
build-helper:maven-version Deprecated. Maven since version 3.0.4 has such property build in: MNG-4112. So goal can be removed.
build-helper:parse-version Parse a version string and set properties containing the component parts of the version. This mojo sets the following properties:
  [propertyPrefix].majorVersion
  [propertyPrefix].minorVersion
  [propertyPrefix].incrementalVersion
  [propertyPrefix].qualifier
  [propertyPrefix].buildNumber
Where the propertyPrefix is the string set in the mojo parameter. The parsing of the above is based on the following format of the version:
 <majorversion [> . <minorversion [> . <incrementalversion ] ] [> - <buildnumber | qualifier ]>
It will be tried to parse the version as an OSGi version. It this is successful the following property will be set accordingly. If this is not possible a warning will be emitted.
  [propertyPrefix].osgiVersion
This goal also sets the following properties:
  [propertyPrefix].nextMajorVersion
  [propertyPrefix].nextMinorVersion
  [propertyPrefix].nextIncrementalVersion
  [propertyPrefix].nextBuildNumber
This goal also sets the following properties:
  [formattedPropertyPrefix].majorVersion
  [formattedPropertyPrefix].minorVersion
  [formattedPropertyPrefix].incrementalVersion
  [formattedPropertyPrefix].buildNumber
This goal also sets the following properties:
  [formattedPropertyPrefix].nextMajorVersion
  [formattedPropertyPrefix].nextMinorVersion
  [formattedPropertyPrefix].nextIncrementalVersion
  [formattedPropertyPrefix].nextBuildNumber
There is another property set which is named [propertyPrefix].qualifier and furthermore another property which is named [propertyPrefix].qualifier? which contains a prefix - if the qualifier contains anything otherwise the whole property is simply empty.
mvn build-helper:parse-version versions:set \
  -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.\${parsedVersion.incrementalVersion}\${parsedVersion.qualifier?}
The above properties contain simply incremented versions of the parsed version informations. Those can now be used to update the version of your project via the following to the next Major version:
  mvn build-helper:parse-version versions:set \
     -DnewVersion=\${parsedVersion.nextMajorVersion}.0.0 \
     versions:commit
It can of course being used to increment the minor version:
  mvn build-helper:parse-version versions:set \
     -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0 \
     versions:commit
This can make an upgrade of the versions of your project very convenient.
build-helper:regex-properties Sets a property by applying a regex replacement rule to a supplied value. This is similar to regex-property goal with support for multiple regex settings using RegexPropertyConfig
build-helper:regex-property Sets a property by applying a regex replacement rule to a supplied value.
build-helper:released-version Resolve the latest released version of this project. This mojo sets the following properties:
  [propertyPrefix].version
  [propertyPrefix].majorVersion
  [propertyPrefix].minorVersion
  [propertyPrefix].incrementalVersion
  [propertyPrefix].buildNumber
  [propertyPrefix].qualifier
Where the propertyPrefix is the string set in the mojo parameter.
build-helper:remove-project-artifact Remove project's artifacts from local repository. Useful to keep only one copy of large local snapshot, for example: installer, for disk space optimization purpose.
build-helper:reserve-network-port Reserve a list of random and not in use network ports and place them in a configurable project properties.
build-helper:rootlocation This goal will get the location of the root folder within a multi module build as a property rootlocation.
build-helper:timestamp-property Sets a property based on the current date and time.
build-helper:uptodate-properties Sets multiple properties according to whether multiple sets of source and target resources are respectively up to date.
build-helper:uptodate-property Sets a property according to whether one set of resources is up to date with respect to another.

System Requirements

The following specifies the minimum requirements to run this Maven plugin:

Maven 3.6.3
JDK 1.8

Usage

You should specify the version in your project's plugin configuration:

<project>
  ...
  <build>
    <!-- To define the plugin version in your parent POM -->
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <version>3.5.0</version>
        </plugin>
        ...
      </plugins>
    </pluginManagement>
    <!-- To use the plugin goals in your POM or parent POM -->
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
      </plugin>
      ...
    </plugins>
  </build>
  ...
</project>

For more information, see "Guide to Configuring Plug-ins"