简体   繁体   English

从命令行设置Maven版本插件的developerConnection

[英]Setting the developerConnection for the Maven Release Plugin from the command line

I am currently trying to configure the Maven Release Plugin for our build server. 我目前正在尝试为我们的构建服务器配置Maven版本插件。

For that I am trying to set the <scm><developerConnection> through the command line. 为此,我试图通过命令行设置<scm><developerConnection> I read that 我读过

project.scm.developerConnection

is the command line property( https://maven.apache.org/guides/mini/guide-releasing.html ). 是命令行属性( https://maven.apache.org/guides/mini/guide-releasing.html )。 I tried to set it but it seems to have no effect. 我尝试设置它,但似乎没有效果。 When I start the build, it uses a constructed URL (parent pom url + artifactId) that fails. 当我开始构建时,它使用一个失败的构造URL(父pom url + artifactId)。

I have looked at the source code of the plugin but did not find the command line property mentioned above. 我查看了插件的源代码,但没有找到上面提到的命令行属性。

Can anybody shed light on this? 有人可以阐明这一点吗?

When you run mvn release:prepare , Maven forks. 运行mvn release:prepare ,Maven会分叉。 The arguments supplied on the command line are passed to the initial Maven call (the one you/build server ran) not to the fork. 命令行中提供的参数将传递给初始Maven调用(您/构建服务器运行的调用),而不传递给fork。

To pass args to the release plugin, supply the arguments as shown: 要将args传递到release插件,请提供如下所示的参数

mvn release:prepare -Darguments="-Dproject.scm.developerConnection=..." ...

Depending on what I'm trying to do, sometimes I've had to specify in two places, so both original and forked processes get the args: 根据我要尝试执行的操作,有时不得不在两个位置进行指定,因此原始进程和派生进程均会获取args:

mvn release:prepare -DsomeArg=val -Darguments="-DsomeArg=val" ...

The first example in the release plugin FAQ shows an example of where the latter is useful. 发布插件常见问题解答中的第一个示例显示了后者有用的示例。

---- Update ---- ----更新----

I found the property in the maven-scm-plugin code . 我在maven-scm-plugin代码中找到了该属性。

SCM验证Mojo.scmDeveloperConnection

Maybe project.scm.developerConnection is read-only? 也许project.scm.developerConnection是只读的? Try setting scmDeveloperConnection instead, as it's listed as the property name. 请尝试设置scmDeveloperConnection ,因为它作为属性名称列出。

It looks that you cannot pass this property directly from command line. 看来您不能直接从命令行传递此属性。 See: 看到:

https://issues.apache.org/jira/browse/MRELEASE-707 https://issues.apache.org/jira/browse/MRELEASE-707

But you should get it working by specifying it through a custom property in your pom.xml: 但是您应该通过在pom.xml中的自定义属性指定它来使其工作:

<properties>
    <my.developer.connection />
</properties>

<scm>
    <developerConnection>${my.developer.connection}</developerConnection>
    <tag>HEAD</tag>
</scm>

And running maven with, for example: 并使用以下方式运行Maven:

-Dmy.developer.connection=scm:git:ssh://user@host/repo.git

I use this approach to keep my pom.xml clean when generating a public release that should not contain information about my company's internals. 在生成不应包含有关公司内部信息的公共发行版时,我使用这种方法来保持pom.xml的清洁。

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

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