Maven 版本不适用于分组 pom

标签 maven jenkins maven-release-plugin

我想发布一个具有以下结构(简化)的项目:

parent
--module A(封装类型:pom)

--module B(类型 jar)

--module C(类型 jar,使用 A 和 B 作为依赖项)

我想在 Jenkins 的帮助下发布我的项目。构建工作正常。
但是对于发布来说,reactor 中似乎不会有 pom 类型的项目的版本。构建失败,因为在我的 maven 存储库中找不到 pom 类型项目的版本。使用 jar 类型的依赖,一切正常。

有谁能够帮助我?

在这里你可以看到控制台和我的测试 pom 文件:

    [INFO] [release:prepare {execution: default-cli}]
[INFO] Verifying that there are no local modifications...
[INFO] Executing: /bin/sh -c cd /CVS1/home/jenkins/.jenkins/jobs/PomDepstest/workspace && git status
[INFO] Working directory: /CVS1/home/jenkins/.jenkins/jobs/PomDepstest/workspace
[INFO] Checking dependencies and plugins for snapshots ...
[INFO] Transforming 'Unnamed - com.basfits.test:parentTest:pom:0.0.2-SNAPSHOT'...
[INFO] Transforming 'Unnamed - com.basfits.test:childTestSimplePom:pom:0.0.2-SNAPSHOT'...
[INFO] Transforming 'Unnamed - com.basfits.test:testjarDep:jar:0.0.2-SNAPSHOT'...
[INFO] Transforming 'Unnamed - com.basfits.test:testPomDep:jar:0.0.2-SNAPSHOT'...
[INFO] Updating testjarDep to 0.0.2
[INFO] Updating childTestSimplePom to 0.0.2
[INFO] Not generating release POMs
[INFO] Executing goals 'clean verify'...
[INFO] [INFO] Scanning for projects...
[INFO] [INFO] Reactor build order: 
[INFO] [INFO]   Unnamed - com.basfits.test:parentTest:pom:0.0.2
[INFO] [INFO]   Unnamed - com.basfits.test:childTestSimplePom:pom:0.0.2
[INFO] [INFO]   Unnamed - com.basfits.test:testjarDep:jar:0.0.2
[INFO] [INFO]   Unnamed - com.basfits.test:testPomDep:jar:0.0.2
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Building Unnamed - com.basfits.test:parentTest:pom:0.0.2
[INFO] [INFO]    task-segment: [clean, verify]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] [clean:clean {execution: default-clean}]
[INFO] [INFO] [site:attach-descriptor {execution: default-attach-descriptor}]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Building Unnamed - com.basfits.test:childTestSimplePom:pom:0.0.2
[INFO] [INFO]    task-segment: [clean, verify]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] [clean:clean {execution: default-clean}]
[INFO] [INFO] [site:attach-descriptor {execution: default-attach-descriptor}]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Building Unnamed - com.basfits.test:testjarDep:jar:0.0.2
[INFO] [INFO]    task-segment: [clean, verify]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] [clean:clean {execution: default-clean}]
[INFO] [INFO] [resources:resources {execution: default-resources}]
[INFO] [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] [INFO] skip non existing resourceDirectory /CVS1/home/jenkins/.jenkins/jobs/PomDepstest/workspace/testjarDep/src/main/resources
[INFO] [INFO] [compiler:compile {execution: default-compile}]
[INFO] [INFO] Compiling 1 source file to /CVS1/home/jenkins/.jenkins/jobs/PomDepstest/workspace/testjarDep/target/classes
[INFO] [INFO] [resources:testResources {execution: default-testResources}]
[INFO] [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] [INFO] skip non existing resourceDirectory /CVS1/home/jenkins/.jenkins/jobs/PomDepstest/workspace/testjarDep/src/test/resources
[INFO] [INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] [INFO] No sources to compile
[INFO] [INFO] [surefire:test {execution: default-test}]
[INFO] [INFO] No tests to run.
[INFO] [INFO] [jar:jar {execution: default-jar}]
[INFO] [INFO] Building jar: /CVS1/home/jenkins/.jenkins/jobs/PomDepstest/workspace/testjarDep/target/testjarDep-0.0.2.jar
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Building Unnamed - com.basfits.test:testPomDep:jar:0.0.2
[INFO] [INFO]    task-segment: [clean, verify]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] [clean:clean {execution: default-clean}]
[INFO] [INFO] Deleting directory /CVS1/home/jenkins/.jenkins/jobs/PomDepstest/workspace/testPomDep/target
[INFO] [INFO] [resources:resources {execution: default-resources}]
[INFO] [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] [INFO] skip non existing resourceDirectory /CVS1/home/jenkins/.jenkins/jobs/PomDepstest/workspace/testPomDep/src/main/resources
[INFO] Downloading: http://maven.bcs.de/content/repositories/bis-releases/com/basfits/test/childTestSimplePom/0.0.2/childTestSimplePom-0.0.2.pom
[INFO] [INFO] Unable to find resource 'com.basfits.test:childTestSimplePom:pom:0.0.2' in repository bis-releases (http://maven.bcs.de/content/repositories/bis-releases)
[INFO] Downloading: http://maven.bcs.de/content/groups/public/com/basfits/test/childTestSimplePom/0.0.2/childTestSimplePom-0.0.2.pom
[INFO] [INFO] Unable to find resource 'com.basfits.test:childTestSimplePom:pom:0.0.2' in repository central (http://repo1.maven.org/maven2)
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [ERROR] BUILD ERROR
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Failed to resolve artifact.
[INFO] 
[INFO] Missing:
[INFO] ----------
[INFO] 1) com.basfits.test:childTestSimplePom:pom:0.0.2
[INFO]   Path to dependency: 
[INFO]      1) com.basfits.test:testPomDep:jar:0.0.2
[INFO]      2) com.basfits.test:childTestSimplePom:pom:0.0.2
[INFO] 
[INFO] ----------
[INFO] 1 required artifact is missing.
[INFO] 
[INFO] for artifact: 
[INFO]   com.basfits.test:testPomDep:jar:0.0.2
[INFO] 
[INFO] from the specified remote repositories:
[INFO]   nexus-central (http://maven.bcs.de/content/groups/public),
[INFO]   bis-releases (http://maven.bcs.de/content/repositories/bis-releases),
[INFO]   bis-snapshots (http://maven.bcs.de/content/repositories/bis-snapshots)
[INFO] 
[INFO] 
[INFO] 
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] For more information, run Maven with the -e switch
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 3 seconds
[INFO] [INFO] Finished at: Fri Jun 08 13:43:48 CEST 2012
[INFO] [INFO] Final Memory: 21M/271M
[INFO] [INFO] ------------------------------------------------------------------------
[JENKINS] Archiving /CVS1/home/jenkins/.jenkins/jobs/PomDepstest/workspace/pom.xml to /CVS1/home/jenkins/.jenkins/jobs/PomDepstest/modules/com.basfits.test$parentTest/builds/2012-06-08_13-43-09/archive/com.basfits.test/parentTest/0.0.2-SNAPSHOT/parentTest-0.0.2-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR

<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.basfits.test</groupId>
<artifactId>parentTest</artifactId>
<version>0.0.2-SNAPSHOT</version>
<packaging>pom</packaging>
<build />
<scm>
    <connection>...</connection>
    <url>...</url>
    </scm>
<distributionManagement>
    <repository>
        <id>bis-releases</id>
        <name>BIS Releases</name>
        <url>...</url>
    </repository>
    <snapshotRepository>
        <id>bis-snapshots</id>
        <name>BIS Snapshots</name>
        <url>...</url>
    </snapshotRepository>
</distributionManagement>
<modules>
    <module>childTestSimplePom</module>
    <module>testPomDep</module>
    <module>testjarDep</module>
</modules>

<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>
    <parent>
        <artifactId>parentTest</artifactId>
        <groupId>com.basfits.test</groupId>
        <version>0.0.2-SNAPSHOT</version>
        <relativePath>..</relativePath>
    </parent>
    <artifactId>childTestSimplePom</artifactId>
    <packaging>pom</packaging>
    <build />


    <dependencies>
        <dependency>
            <groupId>com.mysema.querydsl</groupId>
            <artifactId>querydsl-apt</artifactId>
            <version>2.3.0</version>
        </dependency>
    </dependencies>
</project>

<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>
  <parent>
    <artifactId>parentTest</artifactId>
    <groupId>com.basfits.test</groupId>
    <version>0.0.2-SNAPSHOT</version>
    <relativePath>..</relativePath>
  </parent>
  <artifactId>testPomDep</artifactId>
  <build />

  <dependencies>
    <dependency>
        <artifactId>testjarDep</artifactId>
        <version>0.0.2-SNAPSHOT</version>       
        <groupId>com.basfits.test</groupId>     
    </dependency>
  <dependency>
        <artifactId>childTestSimplePom</artifactId>
        <version>0.0.2-SNAPSHOT</version>       
        <groupId>com.basfits.test</groupId>     
        <type>pom</type>
        <scope>compile</scope>
    </dependency>



  </dependencies>

</project>

最佳答案

您可以将准备目标设置为clean install (默认为 clean verify )。在你的分组pom中添加这个:

<build>
    <plugins>
        <plugin>
            <artifactId>maven-release-plugin</artifactId>
            <configuration>
                <autoVersionSubmodules>true</autoVersionSubmodules>
                <preparationGoals>clean install</preparationGoals>
            </configuration>
        </plugin>
    <plugins>
<build>

这会将发布的 pom.xml 安装到您的本地存储库中,以便您的子模块可以找到它。

关于Maven 版本不适用于分组 pom,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10948695/

相关文章:

java - 如何禁用 Maven 配置文件?

maven - 我怎样才能告诉 maven 以不同的 scm 用户身份发布

java - Selenium RemoteWebDriver UnreachableBrowserException 与边缘

spring-boot - 当我设置 spring.active.profile 时,Spring Boot 不读取 Application.yml 文件

java - com.sun.xml.ws :jaxws-rt:pom:2. 2.10 的 POM 无效

docker - Docker 中的 Jenkins : clarification about bind mounts in pipelines

maven - 在 Maven 发布期间跳过子模块

java - 如何确定一组 springframework 依赖项的 <parent> 依赖项

java - 使用Maven部署Spring-Boot项目并进一步导入到其他项目中

ios - FaSTLane 构建从命令行工作,而不是来自 Jenkins