Hi,

I have a problem which seems to be easy to resolve but I have difficulties
with it.

I am developing a custom plugin that contains a Mojo that doesn't requires a
project.
The Mojo is invoked from an empty working directory.
What the Mojo does is get a parameter defined in the plugin's POM and print
it to the log.
The problem is that I don't know how to pass this parameter to the Mojo.

Here is an example:

In the Mojo class I define the member param to be injected with the value of
a parameter called myParam.

/**
 * @parameter expression="${myParam}"
 */
private String param;

When the Mojo executes it suppose to print the parameter's value

public void execute() throws MojoExecutionException, MojoFailureException {
    getLog().info("Param value is: " + param);
}

In the plugin's POM I define the parameter

<project...>
    ...
    <properties>
        <myParam>Hello World!</myParam>
    </properties>
    ...
</project>

The plugin is installed in the local repository.

When I invoke the Mojo I get the following message:

[0] Inside the definition for plugin 'maven-myplugin-plugin' specify the
following:

<configuration>
  ...
  <myParam>VALUE</myParam>
</configuration>

-OR-

on the command line, specify: '-DmyParam=VALUE'


I tried to include my plugin in the plugins section in the POM of the plugin
itself (some kind of crazy recursive inclusion) as follows:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-myplugin-plugin</artifactId>
    <configuration>
        <myParam>Hello World!</myParam>
    </configuration>
</plugin>

but I still get the same message.

If I invoke the plugin from a working directory that contains a pom.xml file
the defines this parameter the Mojo executes successfully.

Does anyone know how to define a parameter in a custom plugin and use the
value of this parameter in the Mojos of the plugin?

Shai
-- 
View this message in context: 
http://www.nabble.com/Please-help---Injecting-a-custom-plugin-parameter-tp15976512s177p15976512.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to