Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to restrict Major version number update - allowMajorUpdates=false is not respected #11

Closed
uvsmtid opened this issue Jul 25, 2015 · 4 comments
Assignees
Milestone

Comments

@uvsmtid
Copy link

uvsmtid commented Jul 25, 2015

Test

Add org.mockito:mockito-core:1.9.5 dependency to pom.xml.

Update versions disabling major version number updates:

mvn versions:use-latest-versions -DallowMajorUpdates=false

Check results - the major number changes 1 to 2:

                <dependency>
                        <groupId>org.mockito</groupId>
                        <artifactId>mockito-core</artifactId>
-                       <version>1.9.5</version>
+                       <version>2.0.0-beta</version>
                        <scope>test</scope>
                </dependency>

Versions

mvn -version
Apache Maven 3.2.5 (NON-CANONICAL_2015-04-01T06:42:27_mockbuild; 2015-04-01T14:42:27+08:00)
Maven home: /usr/share/maven
Java version: 1.8.0_51, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.51-4.b16.fc22.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.1.2-200.fc22.x86_64", arch: "amd64", family: "unix"
mvn -Dplugin=versions help:describe
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-help-plugin:2.2:describe (default-cli) @ standalone-pom ---
[INFO] org.codehaus.mojo:versions-maven-plugin:2.2

Name: Versions Maven Plugin
Description: Versions Plugin for Maven 2. The Versions Plugin updates the
  versions of components in the POM.
Group Id: org.codehaus.mojo
Artifact Id: versions-maven-plugin
Version: 2.2
Goal Prefix: versions
...

UPDATE: More tests

It is assumed that:

  • if major is allowed, minor and incremental are also allowed;
  • if minor is allowed, incremental is also allowed.

This makes sense because there is normally no semantic relationship between (e.g.) two minor version number when major is different. For example, there is no point to restrict minor and incremental updates in 2.0.8 when major updates are allowed to expect results like 3.0.8 - this is simply impractical as 2.0.8/3.0.8/4.0.8/.../x.0.8 are normally irrelevant versions regardless of common less significant part x.0.8.

Let's test updates for dependency org.apache.maven:maven-plugin-api:2.0.8 which has updates for major, minor, incremental version numbers respectively.

The following dependency was added to pom.xml:

  <dependencies>                                                                
    <dependency>                                                                
      <groupId>org.apache.maven</groupId>                                       
      <artifactId>maven-plugin-api</artifactId>                                 
      <version>2.0.8</version>                                                  
    </dependency>                                                               
  </dependencies>

Expected results

Given 2.0.8 the following version are expected version numbers:

  • major: 3.3.3 (the latest at the time of testing);
  • minor: 2.2.1 (the latest in 2.x.x at the time of testing);
  • incremental: 2.0.11 (the latest in 2.0.x` at the time of testing).

No changes allowed: SUCCESS

mvn versions:use-latest-versions -DallowMajorUpdates=false -DallowMinorUpdates=false -DallowIncrementalUpdates=false

No changes in pom.xml as expected.

incremental=true: FAILURE

mvn versions:use-latest-versions -DallowMajorUpdates=false -DallowMinorUpdates=false -DallowIncrementalUpdates=true

diff:

   <dependencies>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-api</artifactId>
-      <version>2.0.8</version>
+      <version>2.1.0-M1</version>
     </dependency>
   </dependencies>

Why would it jump from 2.0.8 to 2.1.0 (let alone suffix M1) when only incremental number 8 was allowed to be changed?

minor=true: FAILURE

mvn versions:use-latest-versions -DallowMajorUpdates=false -DallowMinorUpdates=true

diff:

   <dependencies>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-api</artifactId>
-      <version>2.0.8</version>
+      <version>3.0-beta-3</version>
     </dependency>
   </dependencies>

Why would it jump from 2.0.8 to 3.0 (let alone suffix beta-3) when only minor number 0 was allowed to be changed?

major=true: SUCCESS

mvn versions:use-latest-versions -DallowMajorUpdates=true

diff:

   <dependencies>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-api</artifactId>
-      <version>2.0.8</version>
+      <version>3.3.3</version>
     </dependency>
   </dependencies>

This update is as expected.

@jdileonardo
Copy link
Contributor

Would that mean allowMinorrUpdates is not respected either?

@uvsmtid
Copy link
Author

uvsmtid commented Aug 6, 2015

@DiJu519, I guess it would.

I added new section "UPDATE: More tests" into issue main body. It thoroughly addresses your question. Look at the case "incremental=true: FAILURE" where property allowMinorUpdates is set to false while there are still changes in minor version number.

In fact, the way this plugin works breaks any assumptions. This makes me wonder if I even understand intentions of all these properties (or anyone uses its functionality at all).

@stagrlee
Copy link

stagrlee commented Sep 8, 2015

I did some testing on this as well with a repo with non-textual semantic versions (ie, no RC, BETA, ALPHA stuff), only numeric triples (xx.yy.zz) with some SNAPSHOTS and got good results, except if the upper bound was equivalent with a -SNAPSHOT. Since I think it is a bit different bug, I logged a separate issue #22

khmarbaise added a commit that referenced this issue Feb 25, 2017
 o Added integration tests to prove that current behaviour is wrong.
khmarbaise added a commit that referenced this issue Feb 25, 2017
 o Added integration tests to prove that the current behaviour is wrong.
khmarbaise added a commit that referenced this issue Mar 18, 2017
 o Added integration tests to prove that the current behaviour is wrong.
 o Added first implementation to fix issue.
khmarbaise added a commit that referenced this issue Mar 18, 2017
 o Added integration tests to prove that the current behaviour is wrong.
 o Added first implementation to fix issue.
khmarbaise added a commit that referenced this issue Mar 18, 2017
 o Added integration tests to prove that the current behaviour is wrong.
 o Added implementation to fix issue.
@khmarbaise khmarbaise added this to the 3.0.0 milestone Mar 18, 2017
khmarbaise added a commit that referenced this issue Mar 18, 2017
 o Added integration tests to prove that the current behaviour is wrong.
 o Added implementation to fix issue.
@khmarbaise khmarbaise self-assigned this May 27, 2017
@jdileonardo
Copy link
Contributor

jdileonardo commented Jan 12, 2018

@khmarbaise this may need to be re-opened

This same issue is present in the UseLatestSnapshots Goal.

Seems d214f34 fixed all but that goal.

Hitting it now locally

[DEBUG]   (f) allowIncrementalUpdates = true
[DEBUG]   (f) allowMajorUpdates = false
[DEBUG]   (f) allowMinorUpdates = false
[DEBUG]   (f) allowSnapshots = false
[DEBUG]   (f) excludeReactor = true
[DEBUG]   (f) generateBackupPoms = false
[DEBUG]   (f) includesList = 
[DEBUG]   (f) localRepository =       id: local
      url: file:///home/jdileonardo/.m2/repository/
   layout: default
snapshots: [enabled => true, update => always]
 releases: [enabled => true, update => always]

[DEBUG] Looking for latest snapshot of A.B.C:D.E:jar:2.40.6

[INFO] Upper bound: 2.41.0
[DEBUG] Candidate versions [2.40.7-SNAPSHOT, 2.41.0-SNAPSHOT]
[INFO] Updated A.B.C:D.E:jar:2.40.6 to version 2.41.0-SNAPSHOT

jdileonardo pushed a commit to jdileonardo/versions-maven-plugin that referenced this issue Jan 26, 2018
Adding MajorMinorPatch filtering to UseLatestSnapshots goal

Change-Id: Iae00c0ccd956fccdfca8f208bc5d18fa28625876
jdileonardo pushed a commit to jdileonardo/versions-maven-plugin that referenced this issue Feb 23, 2018
Adding MajorMinorPatch filtering to UseLatestSnapshots goal

Change-Id: Iae00c0ccd956fccdfca8f208bc5d18fa28625876
@olamy olamy mentioned this issue Jun 12, 2018
olamy pushed a commit that referenced this issue Jun 12, 2018
Adding MajorMinorPatch filtering to UseLatestSnapshots goal

Change-Id: Iae00c0ccd956fccdfca8f208bc5d18fa28625876
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants