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

Version constraints break 'use-latest-versions' when property-based versions are present #243

Closed
robsykes24 opened this issue Dec 8, 2017 · 1 comment

Comments

@robsykes24
Copy link

robsykes24 commented Dec 8, 2017

Description:

In version 2.2 of the versions-maven-plugin, the 'use-latest-versions' would ignore versions that were declared as a property. This issue has already been identified by #99 and #109. However, this change in behavior also introduces another problem documented in this issue where the specification of version constraints ( allowMajorUpdates, DallowMinorUpdates, allowIncrementalUpdates) breaks when a property-based version is encountered. Ideally it would be beneficial to have the behavior of the 2.2 version restored as it would eliminate this issue and also restore the ability to use a combination of property-based and non-property based versions within a given pom. The versions could then be managed via the 'update-property' and 'use-latest-versions' goals respectively without conflict.

There may be a relationship to #205

Test Case (developed using with Maven 3.5.0)

Project 'a'

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>test</groupId>
    <artifactId>a</artifactId>

    <version>1.0.1-0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>${project.artifactId}</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties> 
</project>

Project 'b'

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>test</groupId>
    <artifactId>b</artifactId>

    <version>1.0.2-0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>${project.artifactId}</name>

    <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <dependency.a.version>1.0.4-SNAPSHOT</dependency.a.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>test</groupId>
                <artifactId>a</artifactId>
                <version>${dependency.a.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>

File Structure:

test
├── a
│   └── pom.xml
└── b
    └── pom.xml

Test setup:

Stage 1.0.1-0-SNAPSHOT and 1.0.2-0-SNAPSHOT versions of project 'a'

(cd a; mvn clean install)
(cd a; mvn build-helper:parse-version versions:set -DgenerateBackupPoms=false -DnewVersion='${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}-${parsedVersion.nextBuildNumber}-SNAPSHOT')
(cd a; mvn clean install)

Build 'b' that depends on version 1.0.1-0-SNAPSHOT of 'a' (verifies build works)

(cd b; mvn clean install)

Test steps:

Attempt to bump version to next incremental snapshot buildnumber using specific version of versions-maven-plugin (version > 2.2):

(cd b; mvn org.codehaus.mojo:versions-maven-plugin:2.5:use-latest-versions -DgenerateBackupPoms=false -DallowMajorUpdates=false -DallowMinorUpdates=false -DallowIncrementalUpdates=false -DallowSnapshots=true)

Results with versions-maven-plugin > 2.2:

[ERROR] Failed to execute goal org.codehaus.mojo:versions-maven-plugin:2.5:use-latest-versions (default-cli) on project b: Execution default-cli of goal org.codehaus.mojo:versions-maven-plugin:2.5:use-latest-versions failed: Invalid segment, 2, for the 1 segment version: '${dependency.a.version}' -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.

Attempt to bump version to next incremental snapshot buildnumber using specific version of versions-maven-plugin (version = 2.2):

(cd b; mvn org.codehaus.mojo:versions-maven-plugin:2.2:use-latest-versions -DgenerateBackupPoms=false -DallowMajorUpdates=false -DallowMinorUpdates=false -DallowIncrementalUpdates=false -DallowSnapshots=true)

Results with versions-maven-plugin = 2.2:

Nothing changes since the version is declared as a property

Attempt to bump version without constraints using specific version of versions-maven-plugin:

(cd b; mvn org.codehaus.mojo:versions-maven-plugin:2.5:use-latest-versions -DgenerateBackupPoms=false -DallowSnapshots=true)

Results with versions-maven-plugin > 2.2:

The property is replaced with the new version

git diff b/pom.xml
diff --git a/b/pom.xml b/b/pom.xml
index f893352..318627f 100644
--- a/b/pom.xml
+++ b/b/pom.xml
@@ -19,7 +19,7 @@
             <dependency>
                 <groupId>test</groupId>
                 <artifactId>a</artifactId>
-                <version>${dependency.a.version}</version>
+                <version>1.0.1-1-SNAPSHOT</version>
             </dependency>
         </dependencies>
     </dependencyManagement>

Results with versions-maven-plugin = 2.2:

Nothing changes since the version is declared as a property

copybara-service bot pushed a commit to google/auto that referenced this issue Oct 22, 2020
Process:
  ( for F in common factory service value; do ( mvn org.codehaus.mojo:versions-maven-plugin:2.8.1:update-properties org.codehaus.mojo:versions-maven-plugin:2.8.1:use-latest-releases -f $F/pom.xml ); done && mvn org.codehaus.mojo:versions-maven-plugin:2.8.1:use-latest-versions -f value/src/it/gwtserializer/pom.xml )
  Then undid the Compile-Testing update in value/pom.xml. It somehow breaks things.
  (Someday I will remember -DgenerateBackupPoms=false....)

For some reason, gwtserializer responds to use-latest-versions but not to use-latest-releases, even though it's updating GWT to a release (just as in one of the other POMs).

We don't use use-latest-versions everywhere not just because it could theoretically pick a non-release versions but also because use-latest-versions replaces variable usages like ${guava-version} by inlining the value into them: mojohaus/versions#243

I would have updated the plugins in addition to the deps, but oddly the plugin does not support this: https://stackoverflow.com/q/34032262/28465

RELNOTES=n/a
PiperOrigin-RevId: 338485304
copybara-service bot pushed a commit to google/auto that referenced this issue Oct 22, 2020
Process:
  ( for F in common factory service value; do ( mvn org.codehaus.mojo:versions-maven-plugin:2.8.1:update-properties org.codehaus.mojo:versions-maven-plugin:2.8.1:use-latest-releases -f $F/pom.xml ); done && mvn org.codehaus.mojo:versions-maven-plugin:2.8.1:use-latest-versions -f value/src/it/gwtserializer/pom.xml )
  Then undid the Compile-Testing update in value/pom.xml. It somehow breaks things.
  And I undid the google-java-format update in factory/pom.xml. It isn't compatible with JDK8/9, which is what Travis is set up for. (And then I flailed around for 15 minutes because Maven didn't rebuild some files when I changed JDKs, producing mystery failures. Argh. Perhaps we should set `<useIncrementalCompilation>` to `false` everywhere.)
  (Someday I will remember -DgenerateBackupPoms=false....)

For some reason, gwtserializer responds to use-latest-versions but not to use-latest-releases, even though it's updating GWT to a release (just as in one of the other POMs).

We don't use use-latest-versions everywhere not just because it could theoretically pick a non-release versions but also because use-latest-versions replaces variable usages like ${guava-version} by inlining the value into them: mojohaus/versions#243

I would have updated the plugins in addition to the deps, but oddly the plugin does not support this: https://stackoverflow.com/q/34032262/28465

Fixes #919, #918, #917, #915, #914, #911, #908, #906, #904, #903, #901, #900, #899

RELNOTES=n/a
PiperOrigin-RevId: 338485304
copybara-service bot pushed a commit to google/auto that referenced this issue Oct 22, 2020
Process:
  ( for F in common factory service value; do ( mvn org.codehaus.mojo:versions-maven-plugin:2.8.1:update-properties org.codehaus.mojo:versions-maven-plugin:2.8.1:use-latest-releases -f $F/pom.xml ); done && mvn org.codehaus.mojo:versions-maven-plugin:2.8.1:use-latest-versions -f value/src/it/gwtserializer/pom.xml )
  Then undid the Compile-Testing update in value/pom.xml. It somehow breaks things.
  And I undid the google-java-format update in factory/pom.xml. It isn't compatible with JDK8/9, which is what Travis is set up for. (And then I flailed around for 15 minutes because Maven didn't rebuild some files when I changed JDKs, producing mystery failures. Argh. Perhaps we should set `<useIncrementalCompilation>` to `false` everywhere.)
  And *then* I undid the auto-service upgrade in value/processor/pom.xml. It causes problems but only under JDK9: https://travis-ci.org/github/google/auto/jobs/738096563 The error isn't in generated code, so I suspect a compiler bug. (But my quick search didn't find a filed OpenJDK issue.)
  (Someday I will remember -DgenerateBackupPoms=false....)

For some reason, gwtserializer responds to use-latest-versions but not to use-latest-releases, even though it's updating GWT to a release (just as in one of the other POMs).

We don't use use-latest-versions everywhere not just because it could theoretically pick a non-release versions but also because use-latest-versions replaces variable usages like ${guava-version} by inlining the value into them: mojohaus/versions#243

I would have updated the plugins in addition to the deps, but oddly the plugin does not support this: https://stackoverflow.com/q/34032262/28465

Fixes #919, #918, #917, #915, #914, #911, #908, #906, #904, #903, #901, #900, #899

RELNOTES=n/a
PiperOrigin-RevId: 338485304
copybara-service bot pushed a commit to google/auto that referenced this issue Oct 22, 2020
Process:
  ( for F in common factory service value; do ( mvn org.codehaus.mojo:versions-maven-plugin:2.8.1:update-properties org.codehaus.mojo:versions-maven-plugin:2.8.1:use-latest-releases -f $F/pom.xml ); done && mvn org.codehaus.mojo:versions-maven-plugin:2.8.1:use-latest-versions -f value/src/it/gwtserializer/pom.xml )
  Then undid the Compile-Testing update in value/pom.xml. It somehow breaks things.
  And I undid the google-java-format update in factory/pom.xml. It isn't compatible with JDK8/9, which is what Travis is set up for. (And then I flailed around for 15 minutes because Maven didn't rebuild some files when I changed JDKs, producing mystery failures. Argh. Perhaps we should set `<useIncrementalCompilation>` to `false` everywhere.)
  And *then* I undid the auto-service upgrade in value/processor/pom.xml. It causes problems but only under JDK9: https://travis-ci.org/github/google/auto/jobs/738096563 The error isn't in generated code, so I suspect a compiler bug. (But my quick search didn't find a filed OpenJDK issue.)
  (Someday I will remember -DgenerateBackupPoms=false....)

For some reason, gwtserializer responds to use-latest-versions but not to use-latest-releases, even though it's updating GWT to a release (just as in one of the other POMs).

We don't use use-latest-versions everywhere not just because it could theoretically pick a non-release versions but also because use-latest-versions replaces variable usages like ${guava-version} by inlining the value into them: mojohaus/versions#243

I would have updated the plugins in addition to the deps, but oddly the plugin does not support this: https://stackoverflow.com/q/34032262/28465

Fixes #919, #918, #917, #915, #914, #911, #908, #906, #904, #903, #901, #900, #899

RELNOTES=n/a
PiperOrigin-RevId: 338507900
@github-actions github-actions bot added the Stale label Oct 19, 2021
@slachiewicz slachiewicz removed the Stale label Oct 27, 2021
@slachiewicz slachiewicz reopened this Oct 27, 2021
@jarmoniuk
Copy link
Contributor

Looks like the old behaviour has been reverted by #340. Can be closed @slachiewicz

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

3 participants