I get "The build could not read 1 project" in maven build because undefined versions
Asked Answered
I

4

12

I've a parent-pom and a integration-pom:
integration pom

<dependencies>
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
    </dependency>

    <dependency>
        <groupId>commons-httpclient</groupId>
        <artifactId>commons-httpclient</artifactId>
    </dependency>

    <dependency>
        <groupId>com.example</groupId>
        <artifactId>example-model</artifactId>
    </dependency>

</dependencies>
<parent>
    <groupId>com.example</groupId>
    <artifactId>example-parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</parent>

parent pom

<modules>
    <module>../example-business</module>
    <module>../example-integration</module>
    <module>../example-model</module>
</modules>
<dependencyManagement>
    <dependencies>

        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20131018</version>
        </dependency>

        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <version>3.1</version>
        </dependency>

        <dependency>
            <groupId>com.example</groupId>
            <artifactId>example-model</artifactId>
            <version>${project.version}</version>
        </dependency>

    </dependencies>
</dependencyManagement>

Now when I will do a clean install on the parent, I get the following error:

[INFO] Scanning for projects...
Downloading: http://www.example.com/content/groups/mirror/com/example/example-parent/0.0.1-SNAPSHOT/maven-metadata.xml
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project com.example:example-integration:0.0.1-SNAPSHOT (D:\dev\workspaces\example-git\example\example-integration\pom.xml) has 3 errors
[ERROR]     'dependencies.dependency.version' for org.json:json:jar is missing. @ line 22, column 15
[ERROR]     'dependencies.dependency.version' for commons-httpclient:commons-httpclient:jar is missing. @ line 27, column 15
[ERROR]     'dependencies.dependency.version' for com.example:example-model:jar is missing. @ line 32, column 15

But when I take a look to the Effective POM of the integration pom, there are the version written.
So why I can't build it?


Edit:
Here is a snip of the EFFECTIVE POM view:

<dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20131018</version>
      </dependency>
      <dependency>
        <groupId>commons-httpclient</groupId>
        <artifactId>commons-httpclient</artifactId>
        <version>3.1</version>
      </dependency>
      <dependency>
        <groupId>com.example</groupId>
        <artifactId>example-model</artifactId>
        <version>0.0.1-SNAPSHOT</version>
      </dependency>
      <dependency>
        <groupId>com.example</groupId>
        <artifactId>example-integration</artifactId>
        <version>0.0.1-SNAPSHOT</version>
      </dependency>
      <dependency>
        <groupId>com.example</groupId>
        <artifactId>example-business</artifactId>
        <version>0.0.1-SNAPSHOT</version>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.json</groupId>
      <artifactId>json</artifactId>
      <version>20131018</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>commons-httpclient</groupId>
      <artifactId>commons-httpclient</artifactId>
      <version>3.1</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.example</groupId>
      <artifactId>example-model</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.example</groupId>
      <artifactId>example-business</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
Impropriety answered 6/12, 2013 at 12:44 Comment(0)
G
11

The problem is to do with your project structure and how you have defined the parent in the child poms.

Your child modules are actually in folders that are one level up from where your parent pom resides rather than in the same level (judging from <module>../example-business</module>). When maven tries to build the child modules it can not find the parent pom as it is not available in the maven repository (it is currently in the process of building it so it has not yet been uploaded).

To fix this you simply need to change the parent definition in the child poms to define a real relativePath to the location of the parent pom so that maven can find it. So change it to be something like the following:

<parent>
    <groupId>com.example</groupId>
    <artifactId>example-parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <relativePath>../name-of-folder-containing-parent-pom</relativePath>
</parent>

Obviously you'll need to change name-of-folder-containing-parent-pom to be whatever the folder is.

Glavin answered 6/12, 2013 at 13:34 Comment(6)
It don't work. First I added the parent again over the "Overview" tab and added it over the "Select Parent" button. This don't work. So I added the relativePath to "../example-parent". Also haven't workedImpropriety
Are you building from the command line or from within an IDE? Could you try from the command line? What happens if you try and build one of the child modules by itself?Glavin
I build it from within the IDE (eclipse). I don't know how to do it from the command line and it should work in the IDE... When I build a child, I'll get an Compilation failure error...Impropriety
Is there any chance you could make the complete poms available somewhere for me to take a look at?Glavin
Hm. I added again the relative path. Now I get a different error: The projects in the reactor contain a cyclic reference: Edge between 'Vertex{label='com.example:example-integration:0.0.1-SNAPSHOT'}' and 'Vertex{label='com.example:example-business:0.0.1-SNAPSHOT'}' introduces to cycle in the graph com.example:example-business:0.0.1-SNAPSHOT ...Impropriety
The problem is, I must change all the names, because I'm not allowed to share the package names etc. So my real project doesn't name com.example, I just replaced that. It would be hard to share the file. Sorry. But if you really need it to help me, I'll look what I can do. Thank you for your help!Impropriety
M
0

Check why parent dependency is not getting solved in your local. You might be missing something in settings.xml which resides in c:Users/name/.m2 Check if the credentials are correct and you have added all the artifactory links in case if they are not public.

Minestrone answered 26/7, 2019 at 19:45 Comment(0)
C
0

I had same issue, Please check actual folder name in file explorer it should match what u defined as module in pom. eclipse might be showing project name differently than actual project name in explorer.

Cincture answered 20/9, 2022 at 10:41 Comment(0)
P
-1

I too had similar issue and is solved by adding missed close tag below

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-jexl</artifactId>
<version>2.1.1</version>
<dependency>

Same resolved as below:

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-jexl</artifactId>
<version>2.1.1</version>
</dependency>
Pablo answered 23/3, 2020 at 12:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.