简体   繁体   中英

Complex multi module maven project failed to build

I stuck on building complex maven multi module project based on Hexagonal architecture.

My maven module structure look like that

|   graphql-intro (root module)
|   graphql-intro.xml
+-- bootloader (module)
|    +--- src/main/java/com/intro/graphql/ApplicationInitializer
|    +--- bootloader.xml
|
+-- domain (module)
|     +--- domain.xml
|
+-- infrastructure-adapters (module, root module for adapters)
|     +--- infrastructure-adapters.xml
|
|     +--- adapter-api-graphql (module)
|     |   +--- adapter-api-graphql.xml
|
|     +--- adapter-persistence-in-memory (module)
|     |   +--- adapter-persistence-in-memory.xml
|
|     +--- adapter-persistence-spring-data-jpa (module)
|     |   +--- adapter-persistence-spring-data-jpa.xml

root.xml look like that

    ...
    <packaging>pom</packaging>
    <modules>
        <module>domain</module>
        <module>infrastructure-adapters</module>
        <module>bootloader</module>
    </modules>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.4.RELEASE</version>
    </parent>
    <groupId>com.into.graphql</groupId>
    <artifactId>graphql-into</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    ...
    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>${spring-boot.version}</version>
        <executions>
            <execution>
                <goals>
                    <goal>repackage</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <mainClass>com.intro.graphql.ApplicationInitializer</mainClass>
        </configuration>
    </plugin>
    ...

and this is infrastructure-adapters.xml

    <parent>
        <artifactId>graphql-into</artifactId>
        <groupId>com.into.graphql</groupId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>

    <packaging>pom</packaging>

    <artifactId>infrastructure-adapters</artifactId>
    <name>infrastructure-adapters</name>
    <description>infrastructure-adapters</description>

    <modules>
        <module>adapter-persistence-spring-data-jpa</module>
        <module>adapter-persistence-in-memory</module>
        <module>adapter-api-graphql-kickstarter</module>
    </modules>

The problem is that during build persistence adapters cannot see class from domain module, and this is pom in spring data jpa persistence adapter

<parent>
        <groupId>com.into.graphql</groupId>
        <artifactId>infrastructure-adapters</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>adapter-persistence-spring-data-jpa</artifactId>
    <name>adapter-persistence-spring-data-jpa</name>
    <description>adapter-persistence-spring-data-jpa</description>

    <dependencies>
        ...
        <dependency>
            <groupId>com.into.graphql</groupId>
            <artifactId>domain</artifactId>
        </dependency>
        ...
    </dependencies>

The error is

[INFO] graphql-into ....................................... SUCCESS [  1.875 s]
[INFO] domain ............................................. SUCCESS [  2.582 s]
[INFO] infrastructure-adapters ............................ SUCCESS [  0.092 s]
[INFO] adapter-persistence-spring-data-jpa ................ FAILURE [  2.118 s]
[INFO] adapter-persistence-in-memory ...................... SKIPPED
[INFO] adapter-api-graphql-kickstarter .................... SKIPPED
[INFO] bootloader ......................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  7.152 s
[INFO] Finished at: 2020-04-30T11:17:26+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project adapter-persistence-spring-data-jpa: Compilation failure: Compilation failure:
[ERROR] path/graphql-into/infrastructure-adapters/adapter-persistence-spring-data-jpa/src/main/java/com/intro/graphql/persistance/jpa/products/ProductDaoAdapter.java:[3,33] package com.intro.grap
hql.dealers does not exist (it is package from domain module)

Has anyone know what could be a problem, can inside module depend from outside module or maybe the order of build is bad?

Problem solved, I moved build configuration with spring-boot-maven-plugin to the bootloader pom and now build work. Unfortunatelly I dont know the reason why it solved problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM