Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven could not resolve dependencies from reactor

Tags:

maven

maven-3

I'm getting the following warnings when I do `mvn clean package

07:02:39 [WARNING] The following dependencies could not be resolved at this point of the build but seem to be part of the reactor:
07:02:39 [WARNING] o proj:fs-models:jar:1.0.0-SNAPSHOT12345 (compile)
07:02:39 [WARNING] Try running the build up to the lifecycle phase "package"
07:02:39 [WARNING] The following dependencies could not be resolved at this point of the build but seem to be part of the reactor:
07:02:39 [WARNING] o proj:fs-api:jar:1.0.0-SNAPSHOT12345 (compile)
07:02:39 [WARNING] o proj:fs-models:jar:1.0.0-SNAPSHOT12345 (compile)
07:02:39 [WARNING] Try running the build up to the lifecycle phase "package"
07:02:39 [WARNING] The following dependencies could not be resolved at this point of the build but seem to be part of the reactor:
07:02:39 [WARNING] o proj:ep-api-models:jar:1.0.0-SNAPSHOT12345 (compile)
07:02:39 [WARNING] o proj:pckg-models:jar:1.0.0-SNAPSHOT12345 (provided)
07:02:39 [WARNING] o proj:fs-api:jar:1.0.0-SNAPSHOT12345 (provided)
07:02:39 [WARNING] o proj:pckg-fs-models:jar:1.0.0-SNAPSHOT12345 (provided)
07:02:39 [WARNING] Try running the build up to the lifecycle phase "package"
07:02:39 [WARNING] The following dependencies could not be resolved at this point of the build but seem to be part of the reactor:
07:02:39 [WARNING] o proj:models:jar:1.0.0-SNAPSHOT12345 (compile)
07:02:39 [WARNING] o proj:ep-api-models:jar:1.0.0-SNAPSHOT12345 (compile)
07:02:39 [WARNING] Try running the build up to the lifecycle phase "package"

Those dependencies are part of the reactor but maven couldn't resolve it. What could be a cause of this?

like image 860
dgzz Avatar asked Oct 12 '25 05:10

dgzz


1 Answers

The issue is that maven somehow tries to download the modules from remote repositories but shouldn't because they are yet to be built. In my case, it is caused by aggregator maven plugins invoking aggregator goals. These aggregator goals require full information about the project’s dependencies thus maven tries to download them.

I troubleshooted this problem by commenting out all aggregator plugins in my project and rebuild it again. If maven doesn't download them anymore, then they are the culprits. These plugins usually have aggregate- on their goal. Example:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>license-maven-plugin</artifactId>
    <inherited>false</inherited>
    <version>1.16</version>
    <executions>
        <execution>
            <id>default-cli</id>
            <goals>
                <goal>aggregate-add-third-party</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Notice the aggregate-add-third-party-goal.

Related article: https://blog.sonatype.com/2009/05/how-to-make-a-plugin-run-once-during-a-build/

Some plugins are what we call "aggregators" which means they actually do want all the information about the full multi-module build before execution. These plugins, when run on a tree of projects cause Maven to resolve all the children before calling the plugin's execute() method. In this mode a plugin executes just once, but effectively on the whole tree at once. (as a side note, you never want to bind an aggregator goal in your pom as this would cause the plugin to run an n! recursive build since the lifecycle would step into each child and execute the aggregator...which would cause Maven to reresolve all the children, etc)

Once you have identified the causing plugins, you can do one of the following:

  1. Move them on a maven profile such that they are only activated when you're using a profile
  2. If the goal is meant to be a report, move it to the reporting section on your pom (see configuring reports).
like image 196
dgzz Avatar answered Oct 15 '25 21:10

dgzz