3

I have this 2 simple pom.xml main parent project and module which the project is using main project pom.xml :

<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>

    <groupId>com.clouddispatcher</groupId>
    <artifactId>clouddispatcher</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>
    <modules>
        <module>aws-manager</module>
    </modules>
    <dependencies>
        <dependency>
            <groupId>com.clouddispatcher</groupId>
            <artifactId>aws-manager</artifactId>
            <version>1.0-SNAPSHOT</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
    <properties>
        <aws.java.sdk.version>1.11.875</aws.java.sdk.version>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencyManagement>
        <dependencies>

            <dependency>
                <groupId>com.amazonaws</groupId>
                <artifactId>aws-java-sdk</artifactId>
                <version>${aws.java.sdk.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

</project>

and the module pom.xml :

<?xml version="1.0" encoding="UTF-8"?>
<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">
    <parent>
        <artifactId>clouddispatcher</artifactId>
        <groupId>com.clouddispatcher</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>aws-manager</artifactId>
    <dependencies>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk</artifactId>
        </dependency>
    </dependencies>
</project>

now when I run :

mvn clean install

I keep getting this error :

The build could not read 1 project -> [Help 1]
  
  The project com.clouddispatcher:aws-manager:1.0-SNAPSHOT (C:\Dev\my\java\clouddispatcher\aws-manager\pom.xml) has 1 error
    'dependencies.dependency. com.clouddispatcher:aws-manager:1.0-SNAPSHOT' for com.clouddispatcher:aws-manager:1.0-SNAPSHOT is referencing itself. @ com.clouddispatcher:clouddispatcher:1.0-SNAPSHOT, C:\Dev\my\java\clouddispatcher\pom.xml, line 23, column 21
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException

enter image description here

4
  • 3
    Why does your parent has a dependency on a module? Does not make sense. Commented Oct 7, 2020 at 14:34
  • in parent class im using : AWSManager awsManager = new AWSManager(); which is the module Commented Oct 7, 2020 at 14:39
  • 2
    Your parent module which has the packaging pom does not contain any source code so it does not makes sense...Best would be to make an example project on github... Commented Oct 7, 2020 at 14:45
  • i added an image with the file structure Commented Oct 7, 2020 at 14:54

1 Answer 1

7

Let me explain the points of khmarbaise in more detail:

  1. Parents cannot have Java classes. You need to remove the classes from the parent.
  2. You cannot define circular dependencies, i.e. if A is a parent of B, it cannot have B as dependency.

You need to refactor your project to meet these criteria, e.g. by moving the classes from the parent to a second module.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.