简体   繁体   English

在多模块项目中执行Maven发布失败

[英]Performing maven release in multimodule project failing

I have a multimodule(module1,module2,module3) project which has an aggregator pom to build all the modules. 我有一个multimodule(module1,module2,module3)项目,该项目具有一个聚合器pom来构建所有模块。

Now the reactor build order is 现在反应堆的建造顺序是

                     module1
                     module2
                     module3

Also module2 has dependency on module1 and module3 has dependency on module2,Now to account for the dependency I am using ${project.version} to specify the module1 version in module2 pom, similarly I am using ${project.version} in module 3 pom to refer to module2.Now the snapshot jobs are executed successfully but when i try to release all the modules using the aggregator pom(which is the parent pom for all the modules) the build fails saying that it cannot release project due to non released dependencies.Is there a way to solve this problem? 同样,module2依赖于module1,而module3依赖于module2,现在要解决依赖关系,我在模块3 pom中使用$ {project.version}来指定module1版本,类似地,我在模块3中使用$ {project.version} pom指向module2。现在快照作业已成功执行,但是当我尝试使用聚合器pom(这是所有模块的父pom)释放所有模块时,构建失败,因为未释放,它无法释放项目有没有办法解决这个问题?

I am using Maven 3.0.4 maven-release-plugin:2.0-beta-8 for the project. 我正在为该项目使用Maven 3.0.4 maven-release-plugin:2.0-beta-8。 Also it is necessary for module2 to use the latest version of module1 which is also true for module3 and module2.And it is necessary to release all of them together as I would want the modules to be released only when all of them are built successfuly. 同样,模块2必须使用模块1的最新版本,模块3和模块2也是正确的。并且有必要一起释放所有模块,因为我希望仅当所有模块都成功构建后才能释放模块。

parent pom

    <project>
    <groupid>com.mycompany</groupid>
    <artifactid>parent</artifactid>
    <version>1.0.0</version>
    <modules>
            <module>module1</module>
            <module>module2</module>
            <module>module3</module>
        </modules>






    ..


    </project>


    module1 pom

    <project>
    <parent>
    <groupid>com.mycompany</groupid>
    <artifactid>parent</artifactid>
    <version>1.0.0</version>
    <relativePath>../pom.xml</relativePath>
    </parent>

    <groupid>com.mycompany</groupid>
    <artifactid>module2</artifactid>




    <dependencies>
        ..
        ..

    </dependencies>


    module2 pom


    <project>
    <parent>
    <groupid>com.mycompany</groupid>
    <artifactid>parent</artifactid>
    <version>1.0.0</version>
    <relativePath>../pom.xml</relativePath>
    </parent>

    <groupid>com.mycompany</groupid>
    <artifactid>module2</artifactid>




    <dependencies>
        <dependency>
        <groupid>com.mycompany</groupid>
        <artifactid>module1</artifactid>
        <version>${project.version}</version>
        </dependency>
         ..
         ..
         ..
    </dependencies>

    ..


    </project>

Things to check 检查事项

1) Make sure any dependencies under the same parent are specified with ${project.version} 1)确保使用$ {project.version}指定了同一父项下的任何依赖项

2) Make sure each module does not explicitly declare it's own version but only specifies a parent, which in turn will set the version. 2)确保每个模块未明确声明其自己的版本,而仅指定一个父级,而后者将设置该版本。

3) Make sure each project does not explicitly declare a groupId, that should come from the parent. 3)确保每个项目均未明确声明应来自父项的groupId。

4) Make sure there are not SNAPSHOT dependencies. 4)确保没有SNAPSHOT依赖项。 The only place that SNAPSHOT should occur in all modules is in the parent pom. SNAPSHOT应该出现在所有模块中的唯一位置是父pom。

5) Make sure all your poms have a packaging declared, the parent should be pom. 5)确保您所有的pom都声明了包装,父母应为pom。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM