在 Maven 中附加二进制文件的内部版本号
我正在运行 Maven 构建并将文件存储在 Artifactory 中。我面临的一个问题是,当我尝试使用 -snapshot 版本时,它会覆盖 Artifactory 中的二进制文件。我尝试使用 Maven 内部版本号插件,但遇到问题。我提到了这一点 http://blog.codehangover.com/track-every-build- number-with-maven/
下面描述我做了什么?
使用以下行更新了 masterpom.xml。
<前><代码> <插件>org.codehaus.mojo ;buildnumber-maven-plugin ; <版本>1.0-beta-3 <处决> <执行> <阶段>验证 <目标> <目标>创建 <配置>假 假 <格式>${版本}.{0,数字} <项目> <项目>构建编号现在我更新ear和webproject的pom如下
<预置><代码> <构建>${project.artifactId}-${project.version}.${buildNumber}
当我运行mvn clean install时,生成了ear和war,但是当我检查ear内的war时,我发现它像war一样 - 1.0-SNAPSHOT-null.war。我相信war和ear无法获取buildNumber参数。我能够成功生成 buildNUMBER.property 文件,并能够通过运行 buildnumber:create 插件来增加数字。这是我的问题
- 我在这里做错了什么以及为什么没有选择 buildNumber 参数。
- 另外,我想生成所有二进制文件,包括以下格式的 jar 文件:binary-version-Snapshot.${buildNumber}。那么我是否需要更新每个文件的 pom 或任何其他方式来更新它?
- 此外,我们正在使用 Hudson 构建进行持续集成,并且我们希望将开发人员构建与 Hudson 构建号分开。如果我们不想在 Hudson 构建之后签入 buildNumber.properties,我们该如何实现这一点呢?
I am running maven build and storing files in Artifactory. One issue I am facing is when ever I try a -snapshot version it overwrites the binary in Artifactory. I tried using the Maven build number plugin, but running in to issues.I reffered to this
http://blog.codehangover.com/track-every-build-number-with-maven/
Describing below What I did?
Updated the masterpom.xml with following line.
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>buildnumber-maven-plugin</artifactId> <version>1.0-beta-3</version> <executions> <execution> <phase>validate</phase> <goals> <goal>create</goal> </goals> </execution> </executions> <configuration> <doCheck>false</doCheck> <doUpdate>false</doUpdate> <format>${version}.{0,number}</format> <items> <item>buildNumber</item> </items> </configuration> </plugin>
Now I update the pom of ear and webproject as below
<build> <finalName>${project.artifactId}-${project.version}.${buildNumber}</finalName> </build>
When I ran mvn clean install, ear and war got generated but when i checked the war inside the ear I am finding it as some thing like war-1.0-SNAPSHOT-null.war. I believe the war and ear couldn't get the buildNumber parameter. I was able to successfully generate the buildNUmber.property files and was able to increment the number by running the buildnumber:create plugin. Here are my questions
- What I am doing wrong here and why the buildNumber parameter is not picked.
- Also I want to generate all the binaries including jars in the following format binary-version-Snapshot.${buildNumber}. So Do i need to update pom of each file or any other way to update this?
- Also we are using Hudson builds for Continous Integration and we want to separate developers builds with Hudson Build number. How can we achieve this if we don't want to checkin the buildNumber.properties after the Hudson build.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要获取独特的快照,请使用 uniqueVersion 标志(请参阅 James Lorenzen 的博客)。如果您使用 Maven 目标部署:部署文件,则 uniqueVersion 标志默认为 true。在我的公司,我们有以下政策。只有“官方”快照才会进入存储库。 “官方”快照是在我们的参考系统(我们的 Jenkins ci 服务器)上构建的快照。我们不需要快照的独特功能,因为我们让 Jenkins 归档工件。这样,如果我们也愿意,可以使用 Jenkins 随时返回到某个版本。如果构建中断,快照将不会部署到存储库。
对于你的第二个问题;我的理解是你需要更新每个 pom 文件。但既然是一次性的改变,就不应该有太大的负担。
我不完全理解你的第三个问题(“......单独的开发人员使用 Hudson 版本号构建......”)。如果您想为 Hudson 完成的每个构建添加构建号,您有多种选择。
您可以在部署时添加字符串作为分类器。 Maven 将在文件名中添加该分类器(artifactID-version-classifier.jar - 例如 my.company.calendar-0.0.1-Snapshot-Hudson.jar)。将通过将分类器添加到依赖项来检索工件。
向您的 Maven 调用添加另一个参数 - 输出文件名(${project.build.finalName},请参阅 maven docu)
将版本字符串更改为类似
To get unique snapshots use the uniqueVersion flag (see James Lorenzen's Blog). If you use the maven goal deploy:deploy-file the uniqueVersion flag is true by default. At my company we have the following policy. Only "official" snapshots go to the repository. A "official" snapshot is one that was build on our reference system (our Jenkins ci server). We don't need the unique feature for snapshots, since we let Jenkins archive the artifacts. This way we can always go back to a certain version if we would like too by using Jenkins. If the build breaks the snapshot will not be deployed to the repo.
To your 2nd question; my understanding is that you need to update every pom file. But since it is a one time change, it shouldn't be too much of a burden.
I am not completely understanding your 3rd question ("... separate developers builds with Hudson Build number..."). In case you want to add the build number for every build done by Hudson, you have several options.
You can add a string as classifier while deploying. Maven will add that classifier in the filename (artifactID-version-classifier.jar - e.g. my.company.calendar-0.0.1-Snapshot-Hudson.jar). The artifact will be retrieved by adding the classifier to the dependency.
add another parameter to your maven call - outputfilename (${project.build.finalName}, see maven docu)
changing your version string to something like