java Maven 发布属性

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/989574/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 14:42:31  来源:igfitidea点击:

Maven release properties

javamaven-2release

提问by javamonkey79

When we release projects it is usually the same every time. Are there any arguments or properties that I can add to release:prepare that will allow for pattern releasing in batch mode?

当我们发布项目时,通常每次都是一样的。是否有任何参数或属性可以添加到 release:prepare 中以允许以批处理模式发布模式?

Example:

例子:

What is the release version for "MyProject"? (company.jar.site:myproject) 0.0.1: : 
What is SCM release tag or label for "MyProject"? (company.jar.site:myproject) MyProject-0.0.1: : 
What is the new development version for "MyProject"? (company.jar.site:myproject) 0.0.2-SNAPSHOT: : 

It would be nice to do something like this:

做这样的事情会很好:

mvn -B release:perform -DreleaseVersion:$nextMinorVersion$ or
mvn -B release:perform -DreleaseVersion:$nextPatchVersion$ or
mvn -B release:perform -Dtag:v$nextPatchVersion$ or
mvn -B release:perform -Dtag:v$nextPatchVersion$-someCustomNaming 

If something like this does not already exist, I will create a custom Mojo to do so.

如果这样的东西尚不存在,我将创建一个自定义 Mojo 来执行此操作。

Alternatively, during the prompts above we usually do default to the 1st question, 'v' + current version on the second, and next minor on the last. If we could modify these somehow, that would solve the immediate issue.

或者,在上面的提示中,我们通常会默认为第一个问题,'v' + 当前版本在第二个问题上,下一个次要问题在最后一个问题上。如果我们能以某种方式修改这些,那将解决眼前的问题。

Thanks in advance.

提前致谢。

回答by caskey

mvn -B release:prepare release:perform

-B is for batch mode, it will use the defaults it offers when in non-batch mode. Generally for X.Y.Z-SNAPSHOT, it does a release of X.Y.Z and sets the new snapshot to X.Y.(Z+1)-SNAPSHOT.

-B 用于批处理模式,它将使用它在非批处理模式下提供的默认值。通常对于 XYZ-SNAPSHOT,它会发布 XYZ 并将新快照设置为 XY(Z+1)-SNAPSHOT。

As with all things maven, you can fight this naming convention and have lots of headaches, or give in and decide your versions and labels are going to be the maven way and get lots for free. I fought it, and lost. Just one of the many ways that you have to give over completely to maven if you're going to use it.

与 maven 的所有事物一样,您可以与此命名约定作斗争并遇到很多麻烦,或者屈服并决定您的版本和标签将成为 maven 方式并免费获得很多。我打了,输了。如果您要使用它,那么这只是您必须完全放弃 Maven 的众多方法之一。

I'm perfectly happy having done so, wanting to impose my own schemes usually isn't a good idea anyway.

我很高兴这样做了,无论如何,想要强加我自己的计划通常不是一个好主意。

回答by Robert Munteanu

Partial answer, after your comment:

部分答案,在您发表评论后

To change the tag name, use the -Dtag=xxxargument to release:prepare. See the release:prepare documentationfor details.

要更改标签名称,请使用-Dtag=xxx参数release:prepare。有关详细信息,请参阅发布:准备文档

Untested code warning

未经测试的代码警告

To do this in a fully automated way, you need to add a configuration entry to your pom.xml where you would set the tag name:

要以完全自动化的方式执行此操作,您需要在 pom.xml 中添加一个配置条目,您可以在其中设置标记名称:

<maven-release-plugin>
   <configuration>
       <tag>parent-${releaseVersion}</tag>
   </configuration>
</maven-release-plugin>

回答by Monachus

The way i have done it is Performing a Non-interactive Release Using a properties file.

我的做法是使用属性文件执行非交互式发布

You create a release.properties in the root of the aggregator project (the one that has packaging:pom) and for each project you add two properties of the following form:

您在聚合器项目(具有包装:pom 的项目)的根目录中创建一个 release.properties,并为每个项目添加以下形式的两个属性:

project.rel.<groupId>\:<artifactId>=<releaseVersion>
project.dev.<groupId>\:<artifactId>=<nextSnapshotVersion>

if you want to use a particular literal for your tag you add the following property

如果您想为标签使用特定文字,请添加以下属性

scm.tag=<tagLiteral>

The following is an example where both things are done (specify the version of each module and defined the literal to be used to tag in the SCM):

以下是完成两件事的示例(指定每个模块的版本并定义用于在 SCM 中标记的文字):

scm.tag=my-project-0.2.1
project.rel.org.monachus.monkeyisland\:my-project=0.2.1
project.dev.org.monachus.monkeyisland\:my-project=0.2.2-SNAPSHOT
project.rel.org.monachus.monkeyisland\:module-a=0.1.1
project.dev.org.monachus.monkeyisland\:module-a=0.1.2-SNAPSHOT