You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Lukas Theussl (JIRA)" <ji...@codehaus.org> on 2007/04/03 20:37:20 UTC

[jira] Moved: (MPLUGIN-31) The plugin:xdoc produce a null pointer exception when no parameter is provided

     [ http://jira.codehaus.org/browse/MPLUGIN-31?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lukas Theussl moved MPPLUGIN-37 to MPLUGIN-31:
----------------------------------------------

    Affects Version/s:     (was: 1.7.1)
             Workflow: Maven New  (was: jira)
                  Key: MPLUGIN-31  (was: MPPLUGIN-37)
              Project: Maven 2.x Plugin Plugin  (was: maven-plugin-plugin)

> The plugin:xdoc produce a null pointer exception when no parameter is provided
> ------------------------------------------------------------------------------
>
>                 Key: MPLUGIN-31
>                 URL: http://jira.codehaus.org/browse/MPLUGIN-31
>             Project: Maven 2.x Plugin Plugin
>          Issue Type: Bug
>         Environment: Group Id:  org.apache.maven.plugins
> Artifact Id: maven-plugin-plugin
> Version:     2.2
> Goal Prefix: plugin
> version of plugin-plugin : 2.2
>            Reporter: Clement Soullard
>
> The pluggin:xdoc return  a mojo MojoDescriptor with a null parameter list when the mojo has no parameter. 
> That causes a null pointer exception when converted to xdoc.
> The folowing patch applied to maven-plugin-tools-2.1/maven-plugin-tools-api/ (not maven-plugin-plugin) solves the problem but maybe it is better to analyse plugin-plugin so that returned list has a zero size. 
> Index: C:/maven-plugin-tools-2.1/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGeneratorTest.java
> ===================================================================
> --- C:/maven-plugin-tools-2.1/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGeneratorTest.java	(revision 525213)
> +++ C:/maven-plugin-tools-2.1/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGeneratorTest.java	(working copy)
> @@ -106,7 +106,7 @@
>          assertNotNull( mojoDescriptor.isDependencyResolutionRequired() );
>  
>          // check the parameter.
> -        checkParameter( (Parameter) mojoDescriptor.getParameters().get( 0 ) );
> +        // checkParameter( (Parameter) mojoDescriptor.getParameters().get( 0 ) );
>      }
>  
>      private void checkParameter( Parameter parameter )
> Index: C:/maven-plugin-tools-2.1/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java
> ===================================================================
> --- C:/maven-plugin-tools-2.1/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java	(revision 525213)
> +++ C:/maven-plugin-tools-2.1/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java	(working copy)
> @@ -50,54 +50,90 @@
>      }
>  
>      public void testGenerator()
> -        throws Exception
> -    {
> -        setupGenerator();
> +    throws Exception
> +{
> +    setupGenerator();
>  
> -        MojoDescriptor mojoDescriptor = new MojoDescriptor();
> -        mojoDescriptor.setGoal( "testGoal" );
> -        mojoDescriptor.setImplementation( "org.apache.maven.tools.plugin.generator.TestMojo" );
> -        mojoDescriptor.setDependencyResolutionRequired( "compile" );
> +    MojoDescriptor mojoDescriptor = new MojoDescriptor();
> +    mojoDescriptor.setGoal( "testGoal" );
> +    mojoDescriptor.setImplementation( "org.apache.maven.tools.plugin.generator.TestMojo" );
> +    mojoDescriptor.setDependencyResolutionRequired( "compile" );
>  
> -        List params = new ArrayList();
> +    List params = new ArrayList();
>  
> -        Parameter param = new Parameter();
> -        param.setExpression( "${project.build.directory}" );
> -        param.setName( "dir" );
> -        param.setRequired( true );
> -        param.setType( "java.lang.String" );
> -        param.setDescription( "Test parameter description" );
> +    Parameter param = new Parameter();
> +    param.setExpression( "${project.build.directory}" );
> +    param.setName( "dir" );
> +    param.setRequired( true );
> +    param.setType( "java.lang.String" );
> +    param.setDescription( "Test parameter description" );
>  
> -        params.add( param );
> +    params.add( param );
>  
> -        mojoDescriptor.setParameters( params );
> +    mojoDescriptor.setParameters( params );
>  
> -        PluginDescriptor pluginDescriptor = new PluginDescriptor();
> -        mojoDescriptor.setPluginDescriptor( pluginDescriptor );
> +    PluginDescriptor pluginDescriptor = new PluginDescriptor();
> +    mojoDescriptor.setPluginDescriptor( pluginDescriptor );
>  
> -        pluginDescriptor.addMojo( mojoDescriptor );
> +    pluginDescriptor.addMojo( mojoDescriptor );
>  
> -        pluginDescriptor.setArtifactId( "maven-unitTesting-plugin" );
> -        pluginDescriptor.setGoalPrefix( "test" );
> +    pluginDescriptor.setArtifactId( "maven-unitTesting-plugin" );
> +    pluginDescriptor.setGoalPrefix( "test" );
>  
> -        ComponentDependency dependency = new ComponentDependency();
> -        dependency.setGroupId( "testGroup" );
> -        dependency.setArtifactId( "testArtifact" );
> -        dependency.setVersion( "0.0.0" );
> +    ComponentDependency dependency = new ComponentDependency();
> +    dependency.setGroupId( "testGroup" );
> +    dependency.setArtifactId( "testArtifact" );
> +    dependency.setVersion( "0.0.0" );
>  
> -        pluginDescriptor.setDependencies( Collections.singletonList( dependency ) );
> +    pluginDescriptor.setDependencies( Collections.singletonList( dependency ) );
>  
> -        File destinationDirectory = new File( System.getProperty( "java.io.tmpdir" ), "testGenerator-outDir" );
> -        FileUtils.deleteDirectory( destinationDirectory );
> -        destinationDirectory.mkdir();
> +    File destinationDirectory = new File( System.getProperty( "java.io.tmpdir" ), "testGenerator-outDir" );
> +    FileUtils.deleteDirectory( destinationDirectory );
> +    destinationDirectory.mkdir();
>  
> -        generator.execute( destinationDirectory, pluginDescriptor );
> +    generator.execute( destinationDirectory, pluginDescriptor );
>  
> -        validate( destinationDirectory );
> +    validate( destinationDirectory );
>  
> -        FileUtils.deleteDirectory( destinationDirectory );
> -    }
> +    FileUtils.deleteDirectory( destinationDirectory );
> +}
> +    
> +    public void testGeneratorEmptyParameters()
> +    throws Exception
> +{
> +    setupGenerator();
>  
> +    MojoDescriptor mojoDescriptor = new MojoDescriptor();
> +    mojoDescriptor.setGoal( "testGoal" );
> +    mojoDescriptor.setImplementation( "org.apache.maven.tools.plugin.generator.TestMojo" );
> +    mojoDescriptor.setDependencyResolutionRequired( "compile" );
> +
> +    PluginDescriptor pluginDescriptor = new PluginDescriptor();
> +    mojoDescriptor.setPluginDescriptor( pluginDescriptor );
> +
> +    pluginDescriptor.addMojo( mojoDescriptor );
> +
> +    pluginDescriptor.setArtifactId( "maven-unitTesting-plugin" );
> +    pluginDescriptor.setGoalPrefix( "test" );
> +
> +    ComponentDependency dependency = new ComponentDependency();
> +    dependency.setGroupId( "testGroup" );
> +    dependency.setArtifactId( "testArtifact" );
> +    dependency.setVersion( "0.0.0" );
> +
> +    pluginDescriptor.setDependencies( Collections.singletonList( dependency ) );
> +
> +    File destinationDirectory = new File( System.getProperty( "java.io.tmpdir" ), "testGenerator-outDir" );
> +    FileUtils.deleteDirectory( destinationDirectory );
> +    destinationDirectory.mkdir();
> +
> +    generator.execute( destinationDirectory, pluginDescriptor );
> +
> +    validate( destinationDirectory );
> +
> +    FileUtils.deleteDirectory( destinationDirectory );
> +}
> +
>      // ----------------------------------------------------------------------
>      //
>      // ----------------------------------------------------------------------
> Index: C:/maven-plugin-tools-2.1/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java
> ===================================================================
> --- C:/maven-plugin-tools-2.1/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java	(revision 525213)
> +++ C:/maven-plugin-tools-2.1/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java	(working copy)
> @@ -249,6 +249,10 @@
>      private List filterParameters( List parameterList )
>      {
>          List filtered = new ArrayList();
> +        
> +        if(parameterList==null){
> +        	return filtered;
> +        }
>  
>          for ( Iterator parameters = parameterList.iterator(); parameters.hasNext(); )
>          {

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira