You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Tibor Digana <ti...@apache.org> on 2019/04/05 15:37:41 UTC

How to list config parameter names in MOJO used by a plugin in POM?

I want to observe a list of config parameters (names) in MOJO plugin
without injecting @Param for each.

If the customer still uses old parameter, the MOJO wouldn't know it.
Therefore I want to read the list of paramaters. And if he stil uses the
old name, the plugin would fail with a hint saying how to fix this problem.

Is this possible in MOJO?

Thx
Tibor

Re: How to list config parameter names in MOJO used by a plugin in POM?

Posted by Robert Scholte <rf...@apache.org>.
     @Parameter( defaultValue = "${mojoExecution}", readonly = true )
     private MojoExecution mojo;

     private void verifyRemovedParameter( String paramName )
     {
         Xpp3Dom configDom = mojo.getConfiguration();
         if ( configDom != null )
         {
             if ( configDom.getChild( paramName ) != null )
             {
                 throw new IllegalArgumentException( "parameter '" +  
paramName
                     + "' has been removed from the plugin, please verify  
documentation." );
             }
         }
     }

     private void verifyReplacedParameter( String oldParamName, String  
newParamNew )
     {
         Xpp3Dom configDom = mojo.getConfiguration();
         if ( configDom != null )
         {
             if ( configDom.getChild( oldParamName ) != null )
             {
                 throw new IllegalArgumentException( "parameter '" +  
oldParamName
                     + "' has been replaced with " + newParamNew + ",  
please verify documentation." );
             }
         }
     }

On Fri, 05 Apr 2019 17:37:41 +0200, Tibor Digana <ti...@apache.org>  
wrote:

> I want to observe a list of config parameters (names) in MOJO plugin
> without injecting @Param for each.
>
> If the customer still uses old parameter, the MOJO wouldn't know it.
> Therefore I want to read the list of paramaters. And if he stil uses the
> old name, the plugin would fail with a hint saying how to fix this  
> problem.
>
> Is this possible in MOJO?
>
> Thx
> Tibor

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