Maven 发布属性

发布于 2024-07-23 21:02:25 字数 813 浏览 7 评论 0原文

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

示例:

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: : 

最好做这样的事情:

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 

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

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

提前致谢。

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?

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.

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.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

晚雾 2024-07-30 21:02:25
mvn -B release:prepare release:perform

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

与所有 Maven 的东西一样,您可以对抗这种命名约定并遇到很多麻烦,或者屈服并决定您的版本和标签将采用 Maven 方式并免费获得很多。 我与之抗争,但失败了。 如果您要使用它,这只是您必须完全放弃 Maven 的众多方法之一。

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

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.

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.

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

你是年少的欢喜 2024-07-30 21:02:25

部分答案,在您的 评论之后:

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

未经测试的代码警告

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

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

Partial answer, after your comment:

To change the tag name, use the -Dtag=xxx argument to release:prepare. See the release:prepare documentation for details.

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:

<maven-release-plugin>
   <configuration>
       <tag>parent-${releaseVersion}</tag>
   </configuration>
</maven-release-plugin>
半岛未凉 2024-07-30 21:02:25

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

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

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

如果您想为标记使用特定的文字,请添加以下内容以下

scm.tag=<tagLiteral>

是完成这两项操作的示例(指定每个模块的版本并定义用于在 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

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:

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.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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文