小编典典

如何在詹金斯中构建多模块Maven项目

jenkins

我的项目结构如下:

ProjectParent
 - pom.xml
 ProjectApp
   -pom.xml
 ProjectAPI
   -pom.xml
 ProjectModels
   -pom.xml
 ProjectServices
   -pom.xml
 Etc..

ProjectModels/ProjectsServices是内的依赖项ProjectAPI/ProjectApp

  1. 我是否应该在Jenkins中创建单独的作业以分别构建每个模块?

  2. 我为此创建了工作,ProjectAPP但在下面得到以下错误(已将目标和操作设置为“全新安装”:

[INFO]扫描项目… [INFO]
[INFO] -----------------------------------
------------------------------------- [INFO]构建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,

没有可用的依赖项信息下载:http :
//maven.springframework.org/snapshot/com/myproject/myproject-
entities/0.0.1-SNAPSHOT/myproject-
entities-0.0.1-SNAPSHOT.pom [警告] com的POM
.myproject:myproject-
entities:jar:0.0.1-SNAPSHOT丢失,没有依赖项信息下载:http :
//maven.springframework.org/snapshot/com/myproject/myproject-
services/0.0.1-SNAPSHOT/myproject
-services-0.0.1-SNAPSHOT.pom [警告]
com.myproject:myproject-
services:jar:0.0.1-SNAPSHOT的POM丢失,没有可用的依赖项信息下载:http :
//maven.springframework.org/快照/com/myproject/myproject-
persistence/0.0.1-SNAPSHOT/myproject-
persistence-0.0.1-SNAPSHOT.pom [警告]
com.myproject:myproject-
persistence:jar:0.0.1-SNAPSHOT的POM丢失,没有可用的依赖项信息下载: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:无法在项目myproject-
app上执行目标:无法解析项目com.myproject:myproject-
app:war:0.0.1-SNAPSHOT的依赖项:无法解析工件: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:在org.springframework.maven中找不到工件com.myproject:myproject-
common-
config:jar:0.0.1-SNAPSHOT。快照(http://maven.springframework.org/snapshot

ProjectParent 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的“全新安装”,并且一切正常。

谢谢


阅读 195

收藏
2020-07-25

共1个答案

小编典典

问题是您不能仅为ProjectApp模块创建项目,因为它依赖于ProjectApp父级以下的其他模块。如果您不将这些模块部署到您的Maven存储库中,则Maven将无法在存储库或构建反应堆中找到它们。

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

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

2020-07-25