Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to change the version number of a maven project

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "how to modify the version number of the maven project". In the daily operation, I believe that many people have doubts about how to modify the version number of the maven project. The editor consulted all kinds of materials and sorted out a simple and easy-to-use method of operation. I hope it will be helpful to answer the doubt of "how to modify the version number of the maven project". Next, please follow the editor to study!

1. Brief introduction

The versions-maven-plugin plug-in can manage the project version

Especially when there are large quantum modules in the Maven project.

You can modify the pom version number in batches

The plug-in updates the parent module to the specified version number

Then update the child module with the same version number as the parent module

The problem of manual modification and omission can be avoided.

two。 Use 2.1. Modify the version number

Cmd enters the root directory of the Maven project and runs the command:

Mvn-f "pom.xml" versions:set-DoldVersion=*-DnewVersion=1.2.0-SNAPSHOT-DprocessAllModules=true-DallowSnapshots=true-DgenerateBackupPoms=true

After the modification is successful, all module version numbers are changed to 1.2.0-SNAPSHAOT.

Simplified command:

Mvn versions:set-DnewVersion=1.2.0-SNAPSHOT

This command is equivalent to the previous command

Setting parameters displayed by personal recommendation

It is convenient to modify the parameters later.

2.2. Return the version number mvn versions:revert

Note that generateBackupPoms is set to true (default)

To have pom.xml.versionsBackup backup files.

Otherwise, the version number cannot be returned without backup files.

Or use the undo function provided by the version management tool

For example, git rollback directly to the original version:

Git reset-hard origin/master

2.3. Confirm the modified version number mvn versions:commit

View the modified pom file and confirm if there are no problems

This command deletes the pom backup file that is generated when the version number is modified.

2.4. Modify the version number directly without confirmation

Set generateBackupPoms to false

Then modify pom directly and no backup file will be generated

There is no need to use commit to reconfirm

However, you cannot use the revert command to return the version number.

Mvn versions:set-DnewVersion=1.2.0-SNAPSHOT-DgenerateBackupPoms=false

3. Parameter description parameter default value indicates whether allowSnapshotsfalse is updated-snapshot snapshot version artifactId$ {project.artifactId} specifies whether artifactIdgenerateBackupPomstrue generates backup files for backing back version number groupId$ {project.groupId} specify groupIdnewVersion

Set the new version number nextSnapshotfalse update version number for the next snapshot version number oldVersion$ {project.version} specify the version number that needs to be updated can use the default'* 'processAllModulesfalse whether to update all modules in the directory whether or not to declare whether the parent-child node processDependenciestrue updates depends on its version number processParenttrue updates the parent node version number processPluginstrue updates the version number in the plug-in processProjecttrue updates the version number of the module itself removeSnapshotfalse removes the snapshot snapshot version Whether to update the matching version (e. G. / project / version) explicitly specified in the sub-module for release stable updateMatchingVersionstrue

More commands and usage

Please refer to the official website of versions-maven-plugin.

4. Use skills

Modify the version number in order to better use the plug-in

Reduce unnecessary revision of version number

It is recommended that the Maven project follow the following specifications:

1. Keep the same version of all modules in the same project

two。 Child modules uniformly inherit the version of the parent module

3. Uniformly define the dependent version numbers of all sub-modules in the section of the top-level module Pom. Do not add version numbers when adding dependencies in sub-modules.

4. Use SNAPSHOT in the development and testing phase

5. Production release using RELEASE

6. The new version iteration modifies only the version in the parent POM and the parent POM version on which the child module depends

At this point, the study on "how to change the version number of the maven project" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report