logo Build Helper Maven Plugin

This plugin contains various small independent goals to assist with Maven build lifecycle

homepage: www.mojohaus.org/build-helper-maven-plugin
fresh index:
last release: 2 years ago, first release: 2 decades ago
packaging: maven-plugin
get this artifact from: central
see this artifact on: search.maven.org


Display vulnerabilities (snyk): Vulnerability check

This chart shows how much is this artifact used as a dependency in other Maven artifacts in Central repository and GitHub:


select version:

Add this snippet into pom.xml inside tag <project><build><plugins>:




Switch to artifact.
goals:
build-helper:add-resource (phase: generate-resources)

Add more resource directories to the POM.

build-helper:add-source (phase: generate-sources)

Add more source directories to the POM.

build-helper:add-test-resource (phase: generate-test-resources)

Add more test resource directories to the POM.

build-helper:add-test-source (phase: generate-test-sources)

Add test source directories to the POM.

build-helper:attach-artifact (phase: package)

Attach additional artifacts to be installed and deployed.

build-helper:bsh-property (phase: validate)

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.

build-helper:cpu-count (phase: initialize)

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 (phase: process-test-classes)

Retrieve current hostname and place it under a configurable project property

build-helper:local-ip (phase: process-test-classes)

Retrieve current host IP address and place it under a configurable project property

build-helper:maven-version (phase: validate)

Store the maven core version in a property maven.version.

build-helper:parse-version (phase: validate)

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 (phase: validate)

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 (phase: validate)

Sets a property by applying a regex replacement rule to a supplied value.

build-helper:released-version (phase: validate)

Resolve the latest released version of this project. This mojo sets the following properties: [propertyPrefix].version [propertyPrefix].majorVersion [propertyPrefix].minorVersion [propertyPrefix].incrementalVersion Where the propertyPrefix is the string set in the mojo parameter.

build-helper:remove-project-artifact (phase: package)

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 (phase: process-test-classes)

Reserve a list of random and not in use network ports and place them in a configurable project properties.

build-helper:rootlocation (phase: validate)

This goal will get the location of the root folder within a multi module build as a property {@code rootlocation}.

build-helper:timestamp-property (phase: validate)

Sets a property based on the current date and time.

build-helper:uptodate-properties (phase: validate)

Sets multiple properties according to whether multiple sets of source and target resources are respectively up to date.

build-helper:uptodate-property (phase: validate)

Sets a property according to whether one set of resources is up to date with respect to another.

Often used code snippets:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <executions>
    <execution>
      <id>add-source</id>
      <phase>generate-sources</phase>
      <goals>
        <goal>add-source</goal>
      </goals>
      <configuration>
        <sources>
          <source>
                                    target/generated-code/src
                                </source>
        </sources>
      </configuration>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <executions>
    <execution>
      <id>add-source</id>
      <phase>generate-sources</phase>
      <goals>
        <goal>add-source</goal>
      </goals>
      <configuration>
        <sources>
          <source>src/gen/java</source>
        </sources>
      </configuration>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <version>1.9.1</version>
  <executions>
    <execution>
      <id>add-source</id>
      <phase>generate-sources</phase>
      <goals>
        <goal>add-source</goal>
      </goals>
      <configuration>
        <sources>
          <source>src/gen/java</source>
        </sources>
      </configuration>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <executions>
    <execution>
      <id>add-source</id>
      <phase>generate-sources</phase>
      <goals>
        <goal>add-source</goal>
      </goals>
      <configuration>
        <sources>
          <source>target/generated-code/src</source>
        </sources>
      </configuration>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <version>1.8</version>
  <executions>
    <execution>
      <id>add-source</id>
      <phase>generate-sources</phase>
      <goals>
        <goal>add-source</goal>
      </goals>
      <configuration>
        <sources>
          <source>src/gen/java</source>
        </sources>
      </configuration>
    </execution>
  </executions>
</plugin>

© Jiri Pinkas 2015 - 2022. All rights reserved! Admin login To submit bugs / feature requests please use this github page
related: JavaVids | Top Java Blogs | Java školení
Apache and Apache Maven are trademarks of the Apache Software Foundation. The Central Repository is a service mark of Sonatype, Inc.