Skip to content

Failing build during Maven MultiModule Parallel build due to absence of Reactor Project Output directory. #355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pschhikara88 opened this issue Apr 18, 2025 · 3 comments

Comments

@pschhikara88
Copy link

pschhikara88 commented Apr 18, 2025

Maven Module Setup

  • RootModule
    • ReactorModule1
      • Module11
      • Module12
      • Module13
      • Module14
    • Module2

Run Command

mvn -T 1C clean install
mvn -T 1C -P scoverage scoverage:test

Error

Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.scoverage:scoverage-maven-plugin:2.1.0:test failed.
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:133)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:193)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:180)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
    at java.lang.Thread.run (Thread.java:833)
Caused by: java.lang.NullPointerException
    at java.util.concurrent.ConcurrentHashMap.putVal (ConcurrentHashMap.java:1011)
    at java.util.concurrent.ConcurrentHashMap.put (ConcurrentHashMap.java:1006)
    at java.util.Properties.put (Properties.java:1301)
    at org.scoverage.plugin.SCoverageForkedLifecycleConfigurator.afterForkedLifecycleExit (SCoverageForkedLifecycleConfigurator.java:143)
    at org.scoverage.plugin.SCoverageIntegrationTestMojo.execute (SCoverageIntegrationTestMojo.java:87)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:193)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:180)

Temporary Solution

**I got this error because my reactor project pom.xml is like this

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.ebay.mad.pl</groupId>
        <artifactId>RootModule</artifactId>
        <version>8.1</version>
    </parent>

    <artifactId>ReactorModule1</artifactId>
    <packaging>pom</packaging>
    <modules>
        <module>Module11</module>
        <module>Module12</module>
        <module>Module13</module>
        <module>Module14</module>
    </modules>
</project>

If you see here, we are not having any src folder in reactor project and not having maven-jar-plugin or any plugin which can create output directory. thats why it is giving NPE at SCoverageForkedLifecycleConfigurator.afterForkedLifecycleExit (SCoverageForkedLifecycleConfigurator.java:143)
https://github.com/scoverage/scoverage-maven-plugin/blob/main/src/main/java/org/scoverage/plugin/SCoverageForkedLifecycleConfigurator.java#L143

String originalOutputDirectory = (String) reactorProject.getProperties().remove( PROP_ORIG_OUTPUT_DIRECTORY );
forkedOutputDirectory = reactorProject.getBuild().getOutputDirectory();
  
reactorProject.getProperties().put( PROP_FORKED_OUTPUT_DIRECTORY, forkedOutputDirectory );
reactorProject.getBuild().setOutputDirectory( originalOutputDirectory );

**Solution
Add this in your ReactorModule1

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

Permanent Solution

As reactor project output directory could be empty depends on its POM.
We are getting null as forkedOutputDirectory = reactorProject.getBuild().getOutputDirectory(); and when we are putting null in concurrentHashMap, it is giving NPE
reactorProject.getProperties().put( PROP_FORKED_OUTPUT_DIRECTORY, forkedOutputDirectory );

we could resolved it by putting it only when forkedOutputDirectory is not null.

if(forkedOutputDirectory!=null)
   reactorProject.getProperties().put( PROP_FORKED_OUTPUT_DIRECTORY, forkedOutputDirectory )
@jozic
Copy link
Collaborator

jozic commented Apr 19, 2025

Hey, thanks for reporting. Our README mentions that multi threading is not supported

The plugin is not thread-safe, so it should not be used in multi-threaded builds.

But please feel free to send a PR with the fix and an integration test.

@pschhikara88
Copy link
Author

@jozic thanks for reply. Yes in readme file, it is mentioned that this plugin is not thread safe. But when i was going through this link, it is mentioned that scoverage:test goal is thread safe and supports parallel build.
reference link : https://scoverage.github.io/scoverage-maven-plugin/2.1.0/test-mojo.html

Please let me know if my understanding is not correct. I am trying to use scoverage:test goal in parallel mode.

@jozic
Copy link
Collaborator

jozic commented Apr 29, 2025

It could be that this doc is obsolete, I need to check the history and probably fix the doc until the main issue is fixed. But overall I believe it's not thread-safe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants