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

Using goal "versions:use-next-releases" with "Apache Maven Invoker" fail on maven-3.8.7 #890

Closed
eitan-rosenberg opened this issue Dec 31, 2022 · 52 comments · Fixed by #891
Closed
Labels
Milestone

Comments

@eitan-rosenberg
Copy link

Hi,

I just replaced apache-maven-3.8.6 with apache-maven-3.8.7.

I got a fresh repository.

I am using org.apache.maven.shared.invoker.DefaultInvoker to run maven programmatically for some years now with no problems.

I post my goals using Apache Maven Invoker using invocationRequest (org.apache.maven.shared.invoker.DefaultInvocationRequest).
the invocationRequest is set to show Errors (invocationRequest.setShowErrors(true));

When using "versions:use-next-releases" the invoker fail.

I am including the log:
Document07.txt

please help...

Happy new year

@jarmoniuk
Copy link
Contributor

The goal does not find any newer versions of your dependency. Due to a regression introduced in #813 (introduced in version 2.14.0), it now raises an ArrayOutOfBoundException, which I'm going to fix now.

Please try with any release prior to 2.14.0 (e.g. 2.13.0).

Did you expect to find any newer version of the dependency artifact?

@eitan-rosenberg
Copy link
Author

I manualy change one of dependency to use previous release and I have the same problem.

@jarmoniuk
Copy link
Contributor

Could you show me the logs of your using 2.13.0 and reaching the same problem?

@eitan-rosenberg
Copy link
Author

I am not sure I understand I just upgrade from 3.8.6 to 3.8.7.
I downloaded apache-maven-3.8.7-bin.zip and use it to replace my maven installation. (Deleting the old content and unzipping )

No problems with 3.8.6.

@jarmoniuk
Copy link
Contributor

Background info:

The problem occurred when I removed the check on versions.getNewerVersions(dep.getVersion(), false).length > 0 before doing

Optional.of(versions.getNewerVersions(dep.getVersion(), false)[0])

So the fix uses Stream.findFirst() instead:

Arrays.stream(versions.getNewerVersions(dep.getVersion(), false)).findFirst()

@eitan-rosenberg
Copy link
Author

What do I need to do ?

@jarmoniuk
Copy link
Contributor

@eitan-rosenberg there are two things here:

  1. ArrayOutOfBoundException which is caused by above

  2. No newer versions found, which might be a regression of Maven 3.8.7. You need to report this to https://issues.apache.org/jira/projects/MNG/issues

To do 2), you need to first request an account by mailing to private@maven.apache.org

@eitan-rosenberg
Copy link
Author

OK

@jarmoniuk
Copy link
Contributor

By the way, you don't need to delete your old maven installation, you can just execute mvn.exe from your installation directory or update the PATH accordingly (saw that you're using Windows).

Granted, I don't know exactly how you're using Maven.

@eitan-rosenberg
Copy link
Author

I am one man shop so I just replace the old stuff with the new one.
( I am a 71 old retired programmer...)

@jarmoniuk
Copy link
Contributor

That's great!

Could you tell me a bit how you're using Maven? You don't need to launch it from Java. You can just type mvn versions:use-next-releases to use the latest version of the plugin or mvn org.codehaus.mojo:versions-maven-plugin:<version>:use-next-releases to use the <version> version.

@eitan-rosenberg
Copy link
Author

eitan-rosenberg commented Dec 31, 2022 via email

@michael-o
Copy link
Member

Interesting, I need a solid reproducer to verify the bug with Maven 3.8.7.

@eitan-rosenberg
Copy link
Author

I am back from the sunny outside
How can I help ?

@eitan-rosenberg
Copy link
Author

We can use Zoom if you want

@eitan-rosenberg
Copy link
Author

Hi,

How I use Maven:

AS I told you, I am a retired programmer.
I started back in 1973, and I worked on many platforms (Some of them are museum piece like this one https://en.wikipedia.org/wiki/IBM_System/360_Model_20)
My latest platform was SAP (https://people.sap.com/rosenberg.eitan)

Now days I use Java as a mental exercise...

I have many independent projects that use a variety of dependencies that covers desktop, clients,servers etc.

I use Maven only for dependencies maintenance.

I wrote some code that is making my life easier...
In order to trace dependencies updates I go through all my source folders and generate what I call "aggregated pom" in this pom I have all the dependencies that I use.
This POM is used as input to "versions:display-dependency-updates" so I get a list of dependencies update.
The list of dependencies update allows me to search all the projects that use the updated dependencies and for each project apply "versions:use-next-releases"

My environment:

  • IDE eclipse-java-2022-12
  • java openjdk-19.0.1
  • Maven 3.8.7

@jarmoniuk
Copy link
Contributor

I see. Thanks for this info.

So I guess you're invoking the plugin from a bespoke Java routine and parsing the output of "display-dependency-updates" and acting on it. If that's the case, perhaps "dependency-update-report" would be a better fit with its XML output -- easy to parse and act upon.

It would be nice to have an API to be able to act on the intermediate results on update results, but an API is not there yet (still in plans).

@eitan-rosenberg
Copy link
Author

eitan-rosenberg commented Dec 31, 2022

I will look into that.
At the moment I simply manualy copy the output from display-dependency-updates.
And put it in in a file like so:
org.apache.commons:commons-lang3
org.apache.commons:commons-collections4

And I get:

image

@michael-o
Copy link
Member

@ajarmoniuk Please ping me when you can boil down that it is not this plugin, but Maven 3.8.7.

@jarmoniuk
Copy link
Contributor

@michael-o all but the ArrayIndexOutOfBoundException reported at the beginning is not about the plugin, but about Maven 3.8.7

And for the array overflow error there's already a trivial PR ready to be reviewed.

@jarmoniuk
Copy link
Contributor

jarmoniuk commented Dec 31, 2022

@eitan-rosenberg I suggest that we move this discussion elsewhere. This is very off-topic.

@jarmoniuk
Copy link
Contributor

@slawekjaranowski please review the PR and close if ready :)

@slawekjaranowski
Copy link
Member

@ajarmoniuk this #891 was merged - should be linked with this issue?

@jarmoniuk
Copy link
Contributor

@slawekjaranowski yes

@slawekjaranowski
Copy link
Member

Ok, should we close this ... ?
What about issues in Maven - can we reproduce it?

@jarmoniuk
Copy link
Contributor

Ok, should we close this ... ? What about issues in Maven - can we reproduce it?

We could try.

@eitan-rosenberg could you please modify the execution parameters of Maven to include debug output, and attach the debug log here?

The option to do so is --debug or -X.

@jarmoniuk
Copy link
Contributor

Also, ideally the "aggregated" pom.xml.

@eitan-rosenberg
Copy link
Author

I will set:

from javadoc Sets the debug mode of the Maven invocation. Equivalent of -X and --debug
invocationRequest.setDebug(true);

@eitan-rosenberg
Copy link
Author

eitan-rosenberg commented Dec 31, 2022

The "aggregated" pom.xml is just for "versions:display-dependency-updates" .
But here it is
aggregated.pom.16874594201279121271.xml.txt

@eitan-rosenberg
Copy link
Author

Log +debug for "versions:display-dependency-updates"

versions.display.dependency.updates.1895807250027797560.log

@eitan-rosenberg
Copy link
Author

Log +debug for "versions:use-next-releases"

versions.use.next.releases.734989394141596249.log

@jarmoniuk
Copy link
Contributor

Some dependencies which we can't really trace/work upon:

    <dependency>
      <groupId>JOOQ.Coder</groupId>
      <artifactId>JOOQ.Coder</artifactId>
      <version>1.0</version>
      <scope>system</scope>
      <systemPath>${env.JAVA_JARS}/JOOQ.Coder/JOOQ.Coder.jar</systemPath>
    </dependency>
    
    <dependency>
      <groupId>MyEmployee.jar</groupId>
      <artifactId>MyEmployee.jar</artifactId>
      <version>1.0</version>
      <scope>system</scope>
      <systemPath>${env.JAVA_JARS}/myEmployee/MyEmployee.jar</systemPath>
    </dependency>
    
    <dependency>
      <groupId>MyFileLock.jar</groupId>
      <artifactId>MyFileLock.jar</artifactId>
      <version>1.0</version>
      <scope>system</scope>
      <systemPath>${env.JAVA_JARS}/myFileLock/MyFileLock.jar</systemPath>
    </dependency>
    
    <dependency>
      <groupId>MyJava_FX_Tools.jar</groupId>
      <artifactId>MyJava_FX_Tools.jar</artifactId>
      <version>1.0</version>
      <scope>system</scope>
      <systemPath>${env.JAVA_JARS}/myJava_FX_Tools/MyJava_FX_Tools.jar</systemPath>
    </dependency>
    
    <dependency>
      <groupId>MyLogger.jar</groupId>
      <artifactId>MyLogger.jar</artifactId>
      <version>1.0</version>
      <scope>system</scope>
      <systemPath>${env.JAVA_JARS}/myLogger/MyLogger.jar</systemPath>
    </dependency>

@eitan-rosenberg
Copy link
Author

Just kill them, it is homegrown

@eitan-rosenberg
Copy link
Author

The "aggregated" pom.xml is just for "versions:display-dependency-updates" .
There is no problems there

@jarmoniuk
Copy link
Contributor

jarmoniuk commented Dec 31, 2022

Results for display-dependency-updates from 2.15.0-SNAPSHOT are the same across 3.8.6 and 3.8.7:

[INFO] --- versions-maven-plugin:2.15.0-SNAPSHOT:display-dependency-updates (default-cli) @ MyArtifactId ---
[INFO] The following dependencies in Dependencies have newer versions:
[INFO]   com.icegreen:greenmail ....................... 1.6.12 -> 2.0.0-alpha-2
[INFO]   io.vavr:vavr ................................. 0.10.4 -> 1.0.0-alpha-4
[INFO]   org.apache.maven:maven-core ................... 3.8.7 -> 4.0.0-alpha-3
[INFO]   org.apache.maven.archetypes:maven-archetype-quickstart .... 1.1 -> 1.4
[INFO]   org.apache.mina:mina-core .......................... 2.2.1 -> 3.0.0-M2
[INFO]   org.eclipse.jetty:jetty-client .............. 11.0.13 -> 12.0.0.alpha3
[INFO]   org.eclipse.jetty:jetty-server .............. 11.0.13 -> 12.0.0.alpha3
[INFO]   org.openjfx:javafx-swing .............................. 19 -> 20-ea+11
[INFO]   org.openjfx:javafx-web ................................ 19 -> 20-ea+11

use-next-releases with 2.15.0-SNAPSHOT did the job with 3.8.7:

[INFO] --- versions-maven-plugin:2.15.0-SNAPSHOT:use-next-releases (default-cli) @ MyArtifactId ---
[INFO] Updated com.icegreen:greenmail:jar:1.6.12 to version 2.0.0-alpha-1
[INFO] Updated io.vavr:vavr:jar:0.10.4 to version 1.0.0-alpha-2
[INFO] Updated org.apache.maven:maven-core:jar:3.8.7 to version 4.0.0-alpha-2
[INFO] Updated org.apache.maven.archetypes:maven-archetype-quickstart:jar:1.1 to version 1.3
[INFO] Updated org.apache.mina:mina-core:jar:2.2.1 to version 3.0.0-M1
[INFO] Updated org.eclipse.jetty:jetty-client:jar:11.0.13 to version 12.0.0.alpha0
[INFO] Updated org.eclipse.jetty:jetty-server:jar:11.0.13 to version 12.0.0.alpha0
[INFO] Updated org.openjfx:javafx-swing:jar:19 to version 19-ea+2
[INFO] Updated org.openjfx:javafx-web:jar:19 to version 19-ea+2

So, I was unable to reproduce the problem with the patched version.

However, the problem does appear with 2.14.2. So, the array overflow was the reason and had nothing to do with Maven.

@jarmoniuk
Copy link
Contributor

@eitan-rosenberg if you want, you can pull the newest snapshot from here (it's already patched) or use 2.13.0, which does not have the bug.

@michael-o
Copy link
Member

So no Maven issue here?

@jarmoniuk
Copy link
Contributor

So no Maven issue here?

No Maven issue.

@jarmoniuk
Copy link
Contributor

Why did 3.8.7 enable the problem though? 🤔

@jarmoniuk
Copy link
Contributor

jarmoniuk commented Dec 31, 2022

AH, it did not, the problem also appears on 3.8.6. So it was a false track. ‼️

@eitan-rosenberg
Copy link
Author

Did you manage to reproduce the error ?

@jarmoniuk
Copy link
Contributor

Did you manage to reproduce the error ?

Yes, on both 3.8.7 and 3.8.6. It does not appear if you use an older version of the plugin or if you pull the newest snapshot and use it.

@eitan-rosenberg
Copy link
Author

Great news....
Any idea when the fix will be included in the normal :
https://maven.apache.org/download.cgi
Download ?

@jarmoniuk
Copy link
Contributor

jarmoniuk commented Dec 31, 2022

It's not Maven. As for the plugin, I guess in a couple of weeks. But you can just change the way how you ibvoke the plugin;

Use mvn org.codehaus.mojo:versions-maven-plugin:2.13.0:use-next-releases instead.

@eitan-rosenberg
Copy link
Author

eitan-rosenberg commented Dec 31, 2022

I change the code like you sugested

private static final String VERSIONS_USE_NEXT_RELEASES = "org.codehaus.mojo:versions-maven-plugin:2.13.0:use-next-releases";

invocationRequest.setGoals(List.of(VERSIONS_USE_NEXT_RELEASES));

It is working !!!
Thank you.
Happy new year !!!

@jarmoniuk
Copy link
Contributor

You can either pull it using Eclipse (import a new project using the VCS import wizard and then git, checkout from https://github.com/mojohaus/versions.git or git@github.com:mojohaus/versions.git if you imported a key), or download the compressed sources from https://github.com/mojohaus/versions/archive/refs/heads/master.zip

And then you can compile and install them somewhere on your local directory using mvn install.

Then your local repository will contain org.codehaus.versions:versions-maven-plugin:2.15.0-SNAPSHOT, which you can use.

@eitan-rosenberg
Copy link
Author

I change the code like you sugested:

private static final String VERSIONS_USE_NEXT_RELEASES = "org.codehaus.mojo:versions-maven-plugin:2.13.0:use-next-releases";

invocationRequest.setGoals(List.of(VERSIONS_USE_NEXT_RELEASES));

It is working !!!
Thank you.
Happy new year !!!

@jarmoniuk
Copy link
Contributor

@slawekjaranowski we can close this one.

Happy New Year, everyone!

@eitan-rosenberg
Copy link
Author

Hello,

Maven 3.9.0 came out today.

I assume that versions-maven-plugin:2.15.0 is not included in Maven 3.9.0.

Regards.

@jarmoniuk
Copy link
Contributor

Hi. It's not a part of Maven.

@eitan-rosenberg
Copy link
Author

Ok thanks,
So any idea when 2.15.0 will come down to my local repository ?

@eitan-rosenberg
Copy link
Author

Good morning
version 2.15.0 seems to work so far
Many thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants