When using maven-release-plugin, why not just detect scm info from local repo?

Mar*_*ler 5 maven maven-release-plugin maven-scm-plugin

As far as I am aware, in order to use the maven-release-plugin, you have to drop in an scm section into your POM file. E.g.:

<scm>
    <connection>scm:hg:ssh://hg@bitbucket.org/my_account/my_project</connection>
    <developerConnection>scm:hg:ssh://hg@bitbucket.org/my_account/my_project</developerConnection>
    <url>ssh://hg@bitbucket.org/my_account/my_project</url>
    <tag>HEAD</tag>
</scm>
Run Code Online (Sandbox Code Playgroud)

I understand this data is used to determine what to tag and where to push changes. But isn't this information already available if you have the code cloned/checked-out? I'm struggling a bit with the concept that I need to tell maven what code it needs to tag when it could, at least in theory, just ask Git/HG/SVN/CVS what code it's dealing with. I suspect I'm missing something in the details, but I'm not sure what. Could the the maven-release-plugin code be changed to remove this as a requirement, or at least make auto-detection the default? If not could someone provide some context on why that wouldn't work?

Ste*_*lly 4

一方面,GIT 和 Subversion 可以使用不同的 SCM URI 进行读写和只读访问。

这就是 different<connection><developerConnection>URI 应该捕获的内容。第一个是保证读取访问的 URI。第二个是保证写访问的 URI。

通常无法从签出的存储库推断出规范的 URI。

例如,我可以通过协议和服务器的 IP 地址查看内部 Subversion 存储库svn:,但外部贡献者需要使用https://主机名。

或者甚至使用 GIT 存储库,在 Github 上,您可以为不同的访问机制提供不同的 URI,例如

  • https://github.com/stephenc/eaio-uuid.git(使用用户名/密码或 OAuth 进行读写)
  • git@github.com:stephenc/eaio-uuid.git(使用SSH私钥识别进行读写)
  • git://github.com/stephenc/eaio-uuid.git(匿名只读)

不要介意你可能已经签出git://github.com/zznate/eaio-uuid.git或克隆了本地签出,换句话说,你的本地 git 存储库可能认为“上游”是../eaio-uuid-from-nate而不是“上游”git@github.com:stephenc/eaio-uuid.git

我同意,对于某些 SCM 工具,您可以自动检测...例如,如果您知道源代码是从 AccuRev 等中检出的,那么您应该可以假设其详细信息...直到您点击 Subversion 或 GIT 或 CVS或等代码模块检出到 AccuRev 工作区(真实故事),以便可以更新正在拉入的标签。

简而言之,检测代码必须非常确定您没有同时使用两个 SCM 系统,才能确定哪个是主 SCM...而另一个 SCM 甚至可能不会在磁盘上留下标记文件以供使用。嗅出(例如,AccuRev 不...因此我选择它)

唯一安全的方法是要求 pom 定义,至少是 SCM 系统,对于那些 URI 无法可靠推断的 SCM 系统(想想 CVS、Subversion、GIT、HG,实际上大多数)都要求 URI被指定。