Set maven property from plugin

Don't set it as System Property, set it as Maven Project property

// inject the project
@Parameter(defaultValue = "${project}")
private org.apache.maven.project.MavenProject project;

// and in execute(), use it:
project.getProperties().setProperty("currentVersion", appCurrentVersion);

See:

  • Mojo Developer Cookbook
  • MavenProject javadoc

An edit suggested using Properties.put() instead of Properties.setProperty(). While technically, Properties implements Map, this usage is discouraged explicitly in the Properties javadoc.


Maven sets properties in initialize phase. I assume that in that phase maven loads system properties. And after that maven doesn't load system properties again. If you try to add a system property after this phase than it's not loaded.

Try to run your plugin in validate phase.