[
https://jira.codehaus.org/browse/MCOBERTURA-148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=280148#comment-280148
]
Miguel Almeida commented on MCOBERTURA-148:
-------------------------------------------
Isn't this a duplicate of http://jira.codehaus.org/browse/MCOBERTURA-151 ?
> NPE in CoberturaReportMojo.getAllChildren in multi-module project
> -----------------------------------------------------------------
>
> Key: MCOBERTURA-148
> URL: https://jira.codehaus.org/browse/MCOBERTURA-148
> Project: Maven 2.x Cobertura Plugin
> Issue Type: Bug
> Affects Versions: 2.5.1
> Environment: Linux
> Reporter: Per Rovegård
> Priority: Blocker
>
> I have a multi-module project where some of the modules have pom packaging.
> These are dependency modules and one module that does non-standard
> deployment. Thus, none is a parent module of some other module.
> When I run
> {code}
> mvn -e cobertura:cobertura -Dcobertura.aggregate=true
> {code}
> I get:
> {code}
> org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute
> goal org.codehaus.mojo:cobertura-maven-plugin:2.5.1:cobertura (default-cli)
> on project zzz-test: Execution default-cli of goal
> org.codehaus.mojo:cobertura-maven-plugin:2.5.1:cobertura failed.
> at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225)
> at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
> at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
> at
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
> at
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
> at
> org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
> at
> org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
> at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
> at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
> at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
> 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:597)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
> Caused by: org.apache.maven.plugin.PluginExecutionException: Execution
> default-cli of goal org.codehaus.mojo:cobertura-maven-plugin:2.5.1:cobertura
> failed.
> at
> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110)
> at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
> ... 19 more
> Caused by: java.lang.NullPointerException
> at java.util.ArrayList.addAll(ArrayList.java:472)
> at
> org.codehaus.mojo.cobertura.CoberturaReportMojo.getAllChildren(CoberturaReportMojo.java:574)
> at
> org.codehaus.mojo.cobertura.CoberturaReportMojo.executeAggregateReport(CoberturaReportMojo.java:275)
> at
> org.codehaus.mojo.cobertura.CoberturaReportMojo.executeAggregateReport(CoberturaReportMojo.java:265)
> at
> org.codehaus.mojo.cobertura.CoberturaReportMojo.executeReport(CoberturaReportMojo.java:251)
> at
> org.apache.maven.reporting.AbstractMavenReport.generate(AbstractMavenReport.java:93)
> at
> org.apache.maven.reporting.AbstractMavenReport.execute(AbstractMavenReport.java:68)
> at
> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
> ... 20 more
> {code}
> The zzz-test module does NOT have pom packaging, though.
> I noticed in CoberturaReportMojo.getAllChildren that there is one code path
> that passes {{null}} into addAll, namely when a module with pom packaging
> does not have any child modules.
> I suppose the following patch will fix the problem:
> {code:java}
> --- CoberturaReportMojo.java 2011-05-26 14:53:47.000000000 +0200
> +++ CoberturaReportMojo.java.fix 2011-05-26 14:55:56.000000000 +0200
> @@ -23,6 +23,7 @@
> import java.util.Locale;
> import java.util.Map;
> import java.util.ResourceBundle;
> +import java.util.Collections;
> import net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler;
> import net.sourceforge.cobertura.coveragedata.ProjectData;
> @@ -563,7 +564,7 @@
> List<MavenProject> children = projectChildren.get( parentProject );
> if ( children == null )
> {
> - return null;
> + return Collections.emptyList();
> }
> List<MavenProject> result = new ArrayList<MavenProject>();
> {code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email