Maven版本不适用于分组pom

时间:2012-06-08 12:16:29

标签: maven jenkins maven-release-plugin

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


- 模块A(包装类型:pom)

- 模块B(类型jar)

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

我想在Jenkins的帮助下发布我的项目。构建工作正常。 但是对于发布,似乎反应堆中不会有一个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>

1 个答案:

答案 0 :(得分:11)

您可以将准备目标设置为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安装到您的本地存储库中,以便您的子模块可以找到它。