Maven says it cannot find something in the "reactor"

Viewed 32136

I have a maven project and I'm using this --projects command from the root of the project to run several pom files.

mvn clean install --projects proj1, then-proj2

The proj1 and then proj2 are the artifact ids of the projects I want to run. That is, I go to the pom.xml for each project and use the "artifact id" there.

Both proj1 & then-proj2 are themeslves sub modules of projects in the main pom file.

Say proj1 is in A, and then-proj2 is in B, and both A & B are in the main pom file.

When I run this, maven tells me: "could not find the selected project in the reactor: proj1".

This is really frustrating - why not tell me what all the projects in the reactor are? Anyway, what am I doing wrong?

5 Answers

Try this:

mvn clean install -pl A/proj1, B/then-proj2

check this out: https://stackoverflow.com/a/23076358/1680793

Another thing is to make sure that you have listed your child projects inside the

<modules>
  <module> 

sections of the corresponding parent multimodule projects.

For example in the below project structure:

  • main
    • A
      • proj1
        • proj1A
    • B
      • then-proj2

Let's say you are trying to build proj1A. When you try

mvn package -pl A/proj1/proj1A

from the main's pom directory you will still have this same reactor error if you don't have:

  • "A" as a module in "main", or
  • "proj1" as a module in "A", or
  • "proj1A" as a module in "proj1"

If your modules are distinguished based on profiles then make sure to consider profiles too. Eg:

mvn -P profile1 -pl relative/path/to/project1 clean install

For this kind of setting, the pom would be:

<profiles>
    <profile>
        <id>profile1</id>
        <modules>
            <module>project1</module>
        </modules>
    </profile>
    <profile>
        <id>profile2</id>
        <modules>
            <module>project2</module>
        </modules>
    </profile>
</profiles>

Not mentioning profile would also give the Not Found in reactor.

A solution that worked for me, run the below command from the root directory.

mvn clean install --projects :projA, :projB -am

assuming that projB is dependent on projA

-am

If project list is specified, also build projects required by the list

Related