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

versions:display-plugin-updates does not understand maven-enforcer-plugin #48

Closed
caseboltj opened this issue Jan 14, 2016 · 21 comments
Closed

Comments

@caseboltj
Copy link

(This is more of a "did this tracker get lost in the transition to mojohaus" tracker than a new issue...)

I removed the deprecated prerequisites stanza from my POM in favor of using the enforcer plugin.

Now, when running versions:display-plugin-updates, existing updates are not found and a message is displayed stating that I need to add the prereqs info back into the POM.

According to http://stackoverflow.com/questions/29344809/versionsdisplay-plugin-updates-does-not-understand-maven-enforcer-plugin , there was a tracker (MVERSIONS-272) on codehaus for this issue.

I searched open and closed trackers here at mojohaus, and did not find anything.

Did the original tracker get closed, or did it just miss the transition?

@informatik01
Copy link

Here is the archived version of that issue page:
https://web.archive.org/web/20150514123930/http://jira.codehaus.org/browse/MVERSIONS-272

@brunchboy
Copy link

Yes, it seems that I am now in a damned-if-I-do, damned-if-I-don’t situation. I have added the enforcer plugin, but if I leave the prerequisites stanza in my pom.xml then I get a warning about it being deprecated when I build, and if I omit it, I get an error when I try to run versions:display-plugin-updates. Is there a correct answer?

@khmarbaise
Copy link
Member

The current version (2.3) of versions-maven-plugin does not correctly handle that. The correct way since Maven 3 is to remove the prerequisites for non-plugin projects. But the problem is located in the versions-maven-plugin.

@ptamarit
Copy link

ptamarit commented Jun 7, 2017

Hi,

If this can help, here are some example with Maven v3.5.0 and versions plugin v2.4 using the command mvn versions:display-plugin-updates:

  • Using prerequisites triggers a Maven warning but is well understood by the versions plugin.
  • Using enforcer works well with Maven but triggers an error with the versions plugin.

pom-prereq.txt
out-prereq.txt
pom-enforcer.txt
out-enforcer.txt

Cheers,
Pablo

@garretwilson
Copy link

Is there a correct answer?

@brunchboy , no, apparently not. @dannil gave a good summary here: #173 (comment)

@brunchboy
Copy link

Sigh, indeed, I keep hoping a fixed version of the plugin will be released, but have been disappointed so far.

@PascalSchumacher
Copy link

PascalSchumacher commented Oct 10, 2017

A fix would be very nice as this is very confusing and the output of versions:display-plugin-updates is basically useless if you use the correct way and enforce the maven version with the enforcer plugin :(

@dje1990 dje1990 mentioned this issue Nov 12, 2017
@adamvoss
Copy link

Confusingly, the plugin even tells me to use the enforcer despite not respecting the setting:

[ERROR] Project does not define required minimum version of Maven.
[ERROR] Update the pom.xml to contain maven-enforcer-plugin to
[ERROR] force the maven version which is needed to build this project.
[ERROR] See https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html

@PascalSchumacher
Copy link

A release containing this would be highly appreciated.

@garretwilson
Copy link

So is this fixed now?

@PascalSchumacher
Copy link

@garretwilson It works for me when I use versions-maven-plugin 2.7.

@garretwilson
Copy link

Woohoo! Yeah, I just tried it. I had to add the Maven Enforcer Plugin indicating a minimum Maven version of 3.0.5, but then it worked and I didn't have to use that incorrect <prerequisites> tag anymore. Thanks so much everyone!!

@brunchboy
Copy link

@garretwilson I am not having the same luck, I still get the complaints about missing prerequisites even after adding explicit entries for versions-maven-plugin 2.7 and maven-enforcer-plugin 3.0.0-M2 configured to requireMavenVersion 3.0.5 (my Maven version is actually 3.5.4). What am I missing?

@garretwilson
Copy link

You might try looking at the latest version of our GlobalMentor parent POM I just updated it this morning to fix this problem. We haven't yet released his artifact to Maven Central, so if you find a problem in it let me know! Hopefully it will point you to what you're missing—or indicate something I missed.

@brunchboy
Copy link

Thanks, I think the problem was that I was only specifying the versions-maven-plugin version in the my reporting plugins section, because the sample configuration XML I had found contained elements that were not valid in the build section. Adding the plugin itself, without that reporting configuration, seemed to do the trick. But I also noticed you have an entire pluginManagement section that I lacked, so I added that to specify versions for all the plugins, including some that mvn versions:display-plugin-updates was complaining had no specified version, and everything seems happy now. Woo hoo! Hopefully I can go back to knowing nothing about Maven for another year or so. 😉

@caseboltj
Copy link
Author

Thanks everyone for staying on this! As the originator of this issue, I can report that the fix is working as advertised for me.

@cowwoc
Copy link

cowwoc commented Feb 10, 2019

Another thing to watch out for is that your enforcer execution should have an id of enforce-maven as mentioned at https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html as opposed to enforce-versions as mentioned at https://maven.apache.org/enforcer/maven-enforcer-plugin/usage.html. It's unfortunate that the enforcer's own documentation gets it wrong.

brunchboy added a commit to Deep-Symmetry/beat-link that referenced this issue Feb 10, 2019
@brunchboy
Copy link

Interesting, what cares about the id?

@cowwoc
Copy link

cowwoc commented Feb 11, 2019

@brunchboy My understanding of this is a bit fuzzy but going by https://maven.apache.org/guides/mini/guide-default-execution-ids.html each plugin has a default execution id. If you want to override its default configuration (for example, by default the enforcer plugin does nothing) then you must specify the execution id you're trying to override. That way if a user invokes an unrelated task (e.g. mvn clean install ... notice that they didn't explicitly invoke enforcer) then when the enforcer plugin runs it'll use your overridden configuration.

I hope that helps.

odl-github pushed a commit to opendaylight/odlparent that referenced this issue Mar 12, 2019
Our Maven configuration matches best practices: we no longer specify
prerequisite and use the enforcer to specify the version of Maven we
need. Unfortunately the default version of versions-maven-plugin
doesn’t recognise this and complains about our valid configuration
with a confusing message (see
mojohaus/versions#48 for
details). This patch enforces version 2.7 which works.

Change-Id: I9af5d7803132c1ee5735d0797f37d2434cf812cf
Signed-off-by: Stephen Kitt <[email protected]>
odl-github pushed a commit to opendaylight/odlparent that referenced this issue Mar 19, 2019
Our Maven configuration matches best practices: we no longer specify
prerequisite and use the enforcer to specify the version of Maven we
need. Unfortunately the default version of versions-maven-plugin
doesn’t recognise this and complains about our valid configuration
with a confusing message (see
mojohaus/versions#48 for
details). This patch enforces version 2.7 which works.

Change-Id: I9af5d7803132c1ee5735d0797f37d2434cf812cf
Signed-off-by: Stephen Kitt <[email protected]>
(cherry picked from commit 8577b13)
@jakub-bochenski
Copy link

The plugin documentation wasn't updated and it still talks about "taking care of Maven version prerequisites."

@onacit
Copy link
Contributor

onacit commented Aug 13, 2022

Is this problem fixed, really?

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