You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by jerome lacoste <je...@gmail.com> on 2005/10/20 12:41:05 UTC

plugin configuration && execution seem to have different parameter values

When I mark the following plugin in phase package, it works OK.
When I mark it in a phase before 'package' (e.g. compile), project
parameter is null while the debug log shows that the configuration was
done properly.

If I add a @required, same thing.

Here's the mojo:

 * @phase package
 * @requiresProject
 */
public class JnlpMojo
    extends AbstractWarMojo
{

    /**
     * Project.
     *
     * @parameter expression="${project}"
     * @readonly
     */
    private MavenProject project;
[...]



Here's the execution


[DEBUG]   (s) project = org.apache.maven.project.MavenProject@f79ffcb3
[...]
[DEBUG] -- end configuration --
[INFO] [webstart:jnlp {execution: default}]
[DEBUG] project null
[INFO] ----------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ----------------------------------------------------------------------------
[INFO] null
[INFO] ----------------------------------------------------------------------------
[DEBUG] Trace
java.lang.NullPointerException
        at org.codehaus.mojo.webstart.JnlpMojo.checkInput(JnlpMojo.java:763)
        at org.codehaus.mojo.webstart.JnlpMojo.execute(JnlpMojo.java:229)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:399)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:519)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:469)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:448)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:301)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:268)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:137)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:316)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:113)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:249)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[INFO] ----------------------------------------------------------------------------
[INFO] Total time: 5 seconds

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: plugin configuration && execution seem to have different parameter values

Posted by Brett Porter <br...@gmail.com>.
Its because the base class is not in your plugin, so the annotations
can not be read.

We generally don't encourage this form of reuse across plugins (ie we
prefer composition over inheritence).

- Brett

On 10/20/05, jerome lacoste <je...@gmail.com> wrote:
> On 10/20/05, jerome lacoste <je...@gmail.com> wrote:
> > When I mark the following plugin in phase package, it works OK.
> > When I mark it in a phase before 'package' (e.g. compile), project
> > parameter is null while the debug log shows that the configuration was
> > done properly.
> >
> > If I add a @required, same thing.
> >
> > Here's the mojo:
> >
> >  * @phase package
> >  * @requiresProject
> >  */
> > public class JnlpMojo
> >     extends AbstractWarMojo
> > {
> >
>
> I've found a work-around. Althought the abstract base class defines a
> project parameter, it isn't visible in my plugin. I thus create a new
> parameter, project2 which is now visible.
>
> The following code:
>
>         getLog().debug( "project " + this.getProject() ); // from base class
>         getLog().debug( "project2 " + this.project2 );
>
> will display:
>
> [DEBUG] project null
> [DEBUG] project2 org.apache.maven.project.MavenProject@f79ffcb3
>
> This loooks like an m2 bug.
>
> I don't understand why, because the WarMojo does exactly the same thing.
> Maybe because I have a different package name than the base class?
> Why does it work with the package phase?
>
> Cheers,
>
> jerome
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: plugin configuration && execution seem to have different parameter values

Posted by jerome lacoste <je...@gmail.com>.
On 10/20/05, jerome lacoste <je...@gmail.com> wrote:
> When I mark the following plugin in phase package, it works OK.
> When I mark it in a phase before 'package' (e.g. compile), project
> parameter is null while the debug log shows that the configuration was
> done properly.
>
> If I add a @required, same thing.
>
> Here's the mojo:
>
>  * @phase package
>  * @requiresProject
>  */
> public class JnlpMojo
>     extends AbstractWarMojo
> {
>

I've found a work-around. Althought the abstract base class defines a
project parameter, it isn't visible in my plugin. I thus create a new
parameter, project2 which is now visible.

The following code:

        getLog().debug( "project " + this.getProject() ); // from base class
        getLog().debug( "project2 " + this.project2 );

will display:

[DEBUG] project null
[DEBUG] project2 org.apache.maven.project.MavenProject@f79ffcb3

This loooks like an m2 bug.

I don't understand why, because the WarMojo does exactly the same thing.
Maybe because I have a different package name than the base class?
Why does it work with the package phase?

Cheers,

jerome

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org