Can't get system parameter from custom maven MOJO

253 views Asked by At

I try to get the value of a system property in a custom maven MOJO, like described here : https://maven.apache.org/developers/mojo-api-specification.html. The property which I try to get the value is "releaseVersion" from the following command line :

mvn -DdevelopmentVersion=0.0.0.7-SNAPSHOT -DreleaseVersion=0.0.0.6 -Dresume=false release:clean release:prepare release:perform

In my custom MOJO, I try to inject the system property in an attribute with the following code :

@Mojo(name = "release-change", defaultPhase = LifecyclePhase.COMPILE)
public class ReleaseChangesMojo extends AbstractMojo
{
    @Parameter(property = "releaseVersion", defaultValue = "${releaseVersion}", required = true)
    private String releaseVersion;

My pom.xml contains this to launch my MOJO :

      <plugin>
        <groupId>fr.my.plugin</groupId>
        <artifactId>my-release-maven-plugin</artifactId>
        <version>0.0.5</version>
      </plugin>
    </plugins>

    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.5.3</version>
          ...
          <configuration combine.self="override">
            <preparationGoals>clean verify</preparationGoals>
            <goals>deploy</goals>
            <completionGoals>my-release:release-change</completionGoals>
          ...
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>

But on execution, I get the following error :

[ERROR] Failed to execute goal plugin:my-release-maven-plugin:0.0.5:release-change (default-cli) on project exemple: The parameters 'releaseVersion' for goal fr.my.plugin:my-release-maven-plugin:0.0.5:release-change are missing or invalid -> [Help 1]

Do you have any idea why the system property is not injected in my MOJO ?

0

There are 0 answers