0

I am developing a maven plugin.

When maven instantiates the mojo class, fields annotated as @Parameter will be "dependency injected" by maven, as childenodes are defined inside the project/build/plugins/plugin/executions/execution tag.

Like this:

@Parameter(defaultValue = "${basedir}/src", alias = "src")
private String sourcePath;

will be filled by

<configuration>
    <src>${basedir}/whatever</src>
</configuration>

.

Is there a way to get the configuration via some java calls? I know that I can use

public Xpp3Dom org.apache.maven.plugin.MojoExecution.getConfiguration()

to retrieve that configuration, the problem is that properties are not resolved in this case, so I get "${basedir}/whatever" for sourcePath, ${} of properties are not resolved. I need them resolved, whatever property they are.

Is there a way to get the resolved values runtime?

Thanks

Androrider
  • 1,050
  • 2
  • 13
  • 20
  • 1
    Which Maven version? Which maven-plugin-plugin version? Do you use maven-plugin-annotation ? Show your full pom file? Don't use '${basedir}/' better use '${project.basedir}' instead. – khmarbaise Jun 23 '14 at 10:57

1 Answers1

1

Annotate your mojo with:

@Mojo(name = "mymojoid", defaultPhase = LifecyclePhase.PACKAGE, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
public class MyMojo extends AbstractMojo{}

Then the values will automatically be resolved

maress
  • 3,533
  • 1
  • 19
  • 37