6

我有一个项目结构如下:

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

ProjectModels/ProjectsServicesProjectAPI/ProjectApp.

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

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

[INFO] 正在扫描项目... [INFO]
[INFO] ------------------------------------ ------------------------------------- [INFO] 构建 myproject-app 0.0.1-SNAPSHOT [信息]------------------------------------------------ ----------------------

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/快照/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


项目父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 的“全新安装”,并且一切都正确构建。

谢谢

4

2 回答 2

4

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

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

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

于 2013-04-22T06:57:55.967 回答
1

Had the same problem, and SpaceTrucker answer helped me.

Hence I just run something like:

.../ProjectParent$ mvn -am -pl ProjectApp test

于 2013-10-16T06:23:59.753 回答