You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Kris Nuttycombe <Kr...@noaa.gov> on 2005/12/13 19:41:48 UTC

[m2] Passing command-line argument to custom plugin

Hi, all,

I'm currently in the process of developing my first Maven 2.0 plugin.
I've been able to figure out everything except how to add custom
command-line arguments. Can anyone point out some documentation of how
to do this?

For example, I want to do the following:

mvn -Dmyarg1=val1 -Dmyarg2=val2 myplugin:mygoal

Thanks,

Kris


Re: [m2] Passing command-line argument to custom plugin

Posted by Kris Nuttycombe <Kr...@noaa.gov>.
Excellent, that was exactly the problem. I'm not sure how I overlooked
that attribute, but thanks very much!

Kris

dan tran wrote:

>add expression="${....}" see my changes below
>
>-D
>
>  
>
>>    
>>
>
>  
>


Re: [m2] Passing command-line argument to custom plugin

Posted by dan tran <da...@gmail.com>.
add expression="${....}" see my changes below

-D


On 12/13/05, Kris Nuttycombe <Kr...@noaa.gov> wrote:
>
> dan tran wrote:
>
> >http://maven.apache.org/guides/plugin/guide-java-plugin-development.html
> >
> >after that, you can use -Dkey=value to override any configurations
> >(parameters) of hte plugin
> >
> >-Dan
> >
> >
> >
> I'm having a hard time getting this to work. Here's a snippet of my
> plugin source:
>
> /**
> * This plugin is used to create and run an SDIF pipeline.
> *
> * @goal sdif
> * @description This plugin is used to create and run an SDIF pipeline.
> * @requiresProject false
> */
> public class SdifPlugin extends AbstractMojo {
>    /**
>     * The XML configuration file for the pipeline to run.
>     * @parameter expression="${pipeConfig}"
>     */
>    protected File pipeConfig;
>
>    /**
>     * The XML configuration file for the log4j logging system.
>     * @parameter expression="${logConfig}"
>
>     */
>    protected File logConfig;
>
>    /**
>     * A list of objects to enqueue onto the first stage of the pipeline.
>     * @parameter
>     */
>    protected List<Object> queueElements;
>
>    public void execute() throws MojoExecutionException {
>        if (pipeConfig == null || !pipeConfig.exists()) {
>            throw new MojoExecutionException(this, "You must specify the
> location of the pipeline configuration file.", null);
>        }
>        ...
>    }
> }
>
> I install the plugin as usual...
>
> mvn -e -DpipeConfig=acars_conf.xml -DlogConfig=log4j_acars.xml
> eds:m2-sdif-plugin:0.1-SNAPSHOT:sdif
>
> [INFO]
>
> ----------------------------------------------------------------------------
> [ERROR] BUILD ERROR
> [INFO]
>
> ----------------------------------------------------------------------------
> [INFO] : gov.noaa.eds.sdif.m2.SdifPlugin@676437
> You must specify the location of the pipeline configuration file.
> [INFO]
>
> ----------------------------------------------------------------------------
> [INFO] Trace
> org.apache.maven.lifecycle.LifecycleExecutionException: You must specify
> the location of the pipeline configuration file.
>        at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(
> DefaultLifecycleExecutor.java:555)
>        at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(
> DefaultLifecycleExecutor.java:485)
>        at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(
> DefaultLifecycleExecutor.java:455)
>        at
>
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures
> (DefaultLifecycleExecutor.java:303)
>        at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(
> DefaultLifecycleExecutor.java:216)
>        at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(
> DefaultLifecycleExecutor.java:139)
>        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
>        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
>        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)
> Caused by: org.apache.maven.plugin.MojoExecutionException: You must
> specify the location of the pipeline configuration file.
>        at gov.noaa.eds.sdif.m2.SdifPlugin.execute(SdifPlugin.java:57)
>        at
> org.apache.maven.plugin.DefaultPluginManager.executeMojo(
> DefaultPluginManager.java:432)
>        at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(
> DefaultLifecycleExecutor.java:530)
>
>
> The plugin is clearly getting run, but the file (which is in the
> directory that I'm running the plugin from) is not being found.
>
> Thanks for your help,
>
> Kris
>
> >On 12/13/05, Kris Nuttycombe <Kr...@noaa.gov> wrote:
> >
> >
> >>Hi, all,
> >>
> >>I'm currently in the process of developing my first Maven 2.0 plugin.
> >>I've been able to figure out everything except how to add custom
> >>command-line arguments. Can anyone point out some documentation of how
> >>to do this?
> >>
> >>For example, I want to do the following:
> >>
> >>mvn -Dmyarg1=val1 -Dmyarg2=val2 myplugin:mygoal
> >>
> >>Thanks,
> >>
> >>Kris
> >>
> >>
> >>
> >>---------------------------------------------------------------------
> >>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: [m2] Passing command-line argument to custom plugin

Posted by Kris Nuttycombe <Kr...@noaa.gov>.
dan tran wrote:

>http://maven.apache.org/guides/plugin/guide-java-plugin-development.html
>
>after that, you can use -Dkey=value to override any configurations
>(parameters) of hte plugin
>
>-Dan
>
>  
>
I'm having a hard time getting this to work. Here's a snippet of my
plugin source:

/**
 * This plugin is used to create and run an SDIF pipeline.
 *
 * @goal sdif
 * @description This plugin is used to create and run an SDIF pipeline.
 * @requiresProject false
 */
public class SdifPlugin extends AbstractMojo {
    /**
     * The XML configuration file for the pipeline to run.
     * @parameter
     */
    protected File pipeConfig;

    /**
     * The XML configuration file for the log4j logging system.
     * @parameter
     */
    protected File logConfig;

    /**
     * A list of objects to enqueue onto the first stage of the pipeline.
     * @parameter
     */
    protected List<Object> queueElements;

    public void execute() throws MojoExecutionException {
        if (pipeConfig == null || !pipeConfig.exists()) {
            throw new MojoExecutionException(this, "You must specify the
location of the pipeline configuration file.", null);
        }
        ...
    }
}

I install the plugin as usual...

mvn -e -DpipeConfig=acars_conf.xml -DlogConfig=log4j_acars.xml
eds:m2-sdif-plugin:0.1-SNAPSHOT:sdif

[INFO]
----------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]
----------------------------------------------------------------------------
[INFO] : gov.noaa.eds.sdif.m2.SdifPlugin@676437
You must specify the location of the pipeline configuration file.
[INFO]
----------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: You must specify
the location of the pipeline configuration file.
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:555)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:485)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:455)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:303)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:216)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:139)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
        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)
Caused by: org.apache.maven.plugin.MojoExecutionException: You must
specify the location of the pipeline configuration file.
        at gov.noaa.eds.sdif.m2.SdifPlugin.execute(SdifPlugin.java:57)
        at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:432)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:530)


The plugin is clearly getting run, but the file (which is in the
directory that I'm running the plugin from) is not being found.

Thanks for your help,

Kris

>On 12/13/05, Kris Nuttycombe <Kr...@noaa.gov> wrote:
>  
>
>>Hi, all,
>>
>>I'm currently in the process of developing my first Maven 2.0 plugin.
>>I've been able to figure out everything except how to add custom
>>command-line arguments. Can anyone point out some documentation of how
>>to do this?
>>
>>For example, I want to do the following:
>>
>>mvn -Dmyarg1=val1 -Dmyarg2=val2 myplugin:mygoal
>>
>>Thanks,
>>
>>Kris
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>>    
>>
>
>  
>


Re: [m2] Passing command-line argument to custom plugin

Posted by dan tran <da...@gmail.com>.
http://maven.apache.org/guides/plugin/guide-java-plugin-development.html

after that, you can use -Dkey=value to override any configurations
(parameters) of hte plugin

-Dan


On 12/13/05, Kris Nuttycombe <Kr...@noaa.gov> wrote:
>
> Hi, all,
>
> I'm currently in the process of developing my first Maven 2.0 plugin.
> I've been able to figure out everything except how to add custom
> command-line arguments. Can anyone point out some documentation of how
> to do this?
>
> For example, I want to do the following:
>
> mvn -Dmyarg1=val1 -Dmyarg2=val2 myplugin:mygoal
>
> Thanks,
>
> Kris
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>