Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Force update of snapshots/releases" - what does it mean

In a Maven project, on selecting "Update project", there is an option called "Force update of snapshots/releases". What does it do?

like image 539
Dev Singh Avatar asked Feb 13 '17 03:02

Dev Singh


2 Answers

"Force update of snapshots/releases" is like running following command

mvn -U install

-U is also be used alternatively as --update-snapshot. See here.

Eclipse's m2eclipse plugin internally calls the same using maven-core API.

See setUpdateSnapshots method.

like image 185
GauravJ Avatar answered Nov 05 '22 13:11

GauravJ


In the world of Maven, any project or component must have its own version. The value of the version may be 1.0.0, 1.3-alpha-4, 2.0, 2.1-SNAPSHOT or 2.1-20091214.221414-13. Among them, 1.0, 1.3-alpha-4 and 2.0 are stable release versions, while 2.1-SNAPSHOT and 2.1-20091214.221414-13 are unstable snapshot versions.

Why does Maven distinguish between release and snapshot versions? Simple 1.0.0, 1.2, 2.1, etc. is not enough? Why even 2.1-SNAPSHOT, or even long 2.1-20091214.221414-13? Imagine this situation, Zhang in the development of module A version 2.1, the version has not yet officially released, together with the development of module A module B, which is developed by Xiao Zhang Ji family members, B function depends on the A The In the development process, Zhang often need to build their own latest output, to the quarter MM, for her development and integration debugging, the question is, how does this work? If you keep updating version 2.1.1, 2.1.2, 2.1.3 .... First of all, Xiao Zhang and quarter MM both need to frequently change the POM, if there are more modules dependent on the module A, will involve more POM changes; Second, a large number of versions actually contains only a small difference, this will Resulting in abuse of version number. Maven's snapshot version mechanism is to solve the above problem. In this example, Xiao Zhang only need to set the version of module A to 2.1-SNAPSHOT, and then released to the PW, in the process of publishing, Maven will automatically for the component timestamp. For example: 2.1-20091214.221414-13 on December 14, 2009 22:14 14 seconds of the 13th snapshot. With this timestamp, Maven will be able to find the latest file in the repository 2.1-SNAPSHOT version at any time. At this time, the season MM configuration for the module A 2.1-SNAPSHOT version of the dependency, when she component module B, Maven will automatically check from the warehouse module A 2.1-SNAPSHOT the latest component, when found to be updated when the download The By default, Maven checks an update every day (controlled by the repository's updatePolicy), and the user can also use the command line -U to force Maven to check for updates, such as: mvn clean install-U. Based on the snapshot version mechanism, Zhang can deploy the component to the warehouse after the build is successful, and the quarter MM can not take into account the building of module A, and she can ensure that you can get the latest available snapshot widgets for module A at all times. Requires additional manual operation.

like image 1
lpgad Avatar answered Nov 05 '22 12:11

lpgad