使用Git发布多模块maven项目 [英] Releasing a multi-module maven project with Git

查看:133
本文介绍了使用Git发布多模块maven项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图发布一个使用git作为SCM的多模块maven项目,而我遇到的第一个问题就是maven发布插件构建release.properties scm.url的方式。我的父母POM看起来像这样:

I'm trying to release a multi-module maven project that uses git as the SCM, and among the first problems I've encountered is the way in which the maven release plugin builds the release.properties scm.url. My parent POM looks something like this:

<packaging>pom</packaging>
<groupId>org.project</groupId>
<artifactId>project-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>

<scm>
    <connection>scm:git:git://github.com/username/project.git</connection>
    <developerConnection>scm:git:git@github.com:username/project.git</developerConnection>
    <url>http://github.com/username/project</url>
</scm>

<modules>
    <module>api</module>
    <module>spi</module>
</modules>

模块POM非常简单:

And the module POMs are straightforward:

<parent>
    <groupId>org.project</groupId>
    <artifactId>project-parent</artifactId>
    <version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>api</artifactId>
<version>0.2.2</version>

我的目标是能够发布各个模块,因为它们每个都有不同的版本,而且我不希望在每次发布时将所有版本一起增加。

My goal is to be able to release individual modules since they each have different versions and I don't want to increment all of the versions together each time I do a release.

当我切换到 api 目录时并执行 mvn release:clean release:prepare 遇到以下输出:

When I change to the api directory and do a mvn release:clean release:prepare I'm met with the following output:

[INFO] Executing: cmd.exe /X /C "git push git@github.com:username/project.git/api master:master"
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Unable to commit files
Provider message:
The git-push command failed.
Command output:
ERROR: Repository not found.

它看起来像maven release插件通过将模块名称附加到<$来创建scm.url c $ c> developerConnection ,它最终不是github上的有效存储库。我不知道设置这个的正确方法是什么。 Maven + git +发布一个单独的子模块可能无法正常工作?任何输入值得赞赏。

It looks like the maven release plugin creates the scm.url by appending the module name to the developerConnection, which ends up not being a valid repository at github. I'm not sure what the right way to set this up is. It might be the case that Maven + git + releasing an individual child module simply won't work? Any input is appreciated.

推荐答案

要了解如何使其工作,请查看一个工作示例,例如:

To see how to make this work, have a look at a working example, such as:

https://github.com/sonatype/sonatype -aether

然而,如果您想要发布个别作品,这无济于事。在这种情况下,您只需复制< scm>元素到所有的poms中。

However, this won't help if you like to release the individual pieces. In that case, you have to just copy the <scm> elements into all the poms.

这是maven开发人员名单上讨论的热门话题,但不要屏住呼吸寻求解决方案。这是一件大事。

This is an active topic of discussion on the maven dev list, but don't hold your breath for a solution from there; it's a big deal.

这篇关于使用Git发布多模块maven项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆