gpt4 book ai didi

maven - 如何在jenkins中构建一个多模块的maven项目

转载 作者:行者123 更新时间:2023-12-04 15:12:51 24 4
gpt4 key购买 nike

我有一个项目结构如下:

ProjectParent
- pom.xml
ProjectApp
-pom.xml
ProjectAPI
-pom.xml
ProjectModels
-pom.xml
ProjectServices
-pom.xml
Etc..
ProjectModels/ProjectsServicesProjectAPI/ProjectApp 中的依赖项.
  • 我应该在 Jenkins 中创建单独的作业来分别构建每个模块吗?
  • 我为 ProjectAPP 创建了一个工作但出现以下错误(已将目标和操作设置为“全新安装”:

  • [INFO] Scanning for projects... [INFO]
    [INFO] ------------------------------------------------------------------------ [INFO] Building myproject-app 0.0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------

    Downloading: http://maven.springframework.org/snapshot/com/myproject/myproject-common-config/0.0.1-SNAPSHOT/myproject-common-config-0.0.1-SNAPSHOT.pom
    [WARNING] The POM for com.myproject:myproject-common-config:jar:0.0.1-SNAPSHOT is missing,

    no dependency information available Downloading: http://maven.springframework.org/snapshot/com/myproject/myproject-entities/0.0.1-SNAPSHOT/myproject-entities-0.0.1-SNAPSHOT.pom [WARNING] The POM for com.myproject:myproject-entities:jar:0.0.1-SNAPSHOT is missing, no dependency information available Downloading: http://maven.springframework.org/snapshot/com/myproject/myproject-services/0.0.1-SNAPSHOT/myproject-services-0.0.1-SNAPSHOT.pom [WARNING] The POM for com.myproject:myproject-services:jar:0.0.1-SNAPSHOT is missing, no dependency information available Downloading: http://maven.springframework.org/snapshot/com/myproject/myproject-persistence/0.0.1-SNAPSHOT/myproject-persistence-0.0.1-SNAPSHOT.pom [WARNING] The POM for com.myproject:myproject-persistence:jar:0.0.1-SNAPSHOT is missing, no dependency information available Downloading: http://maven.springframework.org/snapshot/com/myproject/myproject-common-config/0.0.1-SNAPSHOT/myproject-common-config-0.0.1-SNAPSHOT.jar ...... org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project myproject-app: Could not resolve dependencies for project com.myproject:myproject-app:war:0.0.1-SNAPSHOT: The following artifacts could not be resolved: com.myproject:myproject-common-config:jar:0.0.1-SNAPSHOT, com.myproject:myproject-entities:jar:0.0.1-SNAPSHOT, com.myproject:myproject-services:jar:0.0.1-SNAPSHOT, com.myproject:myproject-persistence:jar:0.0.1-SNAPSHOT: Could not find artifact com.myproject:myproject-common-config:jar:0.0.1-SNAPSHOT in org.springframework.maven.snapshot (http://maven.springframework.org/snapshot)



    项目父Pom
    <?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">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.myproject</groupId>
    <artifactId>myproject-parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>

    <modules>
    <module>myproject-entities</module>
    <module>myproject-services</module>
    <module>myproject-persistence</module>
    <module>myproject-app</module>
    <module>myproject-merchant</module>
    <module>myproject-common-config</module>
    <module>myproject-api</module>
    </modules>

    <dependencyManagement>
    <dependencies>
    ...
    </dependencies>
    </dependencyManagement>

    <repositories>
    ...
    </repositories>

    <build>
    ...
    </build>

    <properties>
    ...

    <myproject-entities-version>0.0.1-SNAPSHOT</myproject-entities-version>
    <myproject-services-version>0.0.1-SNAPSHOT</myproject-services-version>
    <myproject-persistence-version>0.0.1-SNAPSHOT</myproject-persistence-version>
    </properties>

    </project>

    ProjectApp Pom
    <?xml version="1.0"?>
    <project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <parent>
    <groupId>com.myproject</groupId>
    <artifactId>myproject-parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    </parent>

    <artifactId>myproject-app</artifactId>
    <packaging>war</packaging>

    <version>0.0.1-SNAPSHOT</version>
    <name>myproject-app</name>
    <url>http://maven.apache.org</url>


    <dependencies>

    ...

    <dependency>
    <groupId>com.myproject</groupId>
    <artifactId>myproject-common-config</artifactId>
    <version>${myproject-common-config}</version>
    </dependency>

    <dependency>
    <groupId>com.myproject</groupId>
    <artifactId>myproject-entities</artifactId>
    <version>${myproject-entities-version}</version>
    </dependency>

    <dependency>
    <groupId>com.myproject</groupId>
    <artifactId>myproject-services</artifactId>
    <version>${myproject-services-version}</version>
    </dependency>

    <dependency>
    <groupId>com.myproject</groupId>
    <artifactId>myproject-persistence</artifactId>
    <version>${myproject-persistence-version}</version>
    </dependency>

    </dependencies>

    <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <myproject-common-config>0.0.1-SNAPSHOT</myproject-common-config>
    <myproject-entities-version>0.0.1-SNAPSHOT</myproject-entities-version>
    <myproject-services-version>0.0.1-SNAPSHOT</myproject-services-version>
    <myproject-persistence-version>0.0.1-SNAPSHOT</myproject-persistence-version>
    </properties>

    </project>

    我是否使用了错误的目标?我需要链接许多命令吗?即先构建其他模块?

    我正在使用 Maven 3。

    注意:我将目标更改为针对 ParentProject Pom 的“全新安装”,并且一切都正确构建。

    谢谢

    最佳答案

    问题是您不能只为 ProjectApp 创建项目。模块,因为它依赖于 ProjectApp 下的其他模块 parent 。如果您不将这些模块部署到您的 maven 存储库,maven 将无法在存储库或构建 react 器中找到它们。

    相反,您应该为父级创建作业。这将构建必要的模块。

    您也可以使用选项 also-make-dependants 当你有 ProjectApp 的工作时,但我对此没有任何经验。

    关于maven - 如何在jenkins中构建一个多模块的maven项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16136514/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com