maven icon indicating copy to clipboard operation
maven copied to clipboard

Maven wrapper broken with maven 4.0.0-beta-5 and above (solved issue included)

Open hazendaz opened this issue 6 months ago • 2 comments

Affected version

4.0.0-beta-5, 4.0.0-rc-1, 4.0.0-rc-2, 4.0.0-rc-3, 4.0.0-rc-4

Bug description

See https://github.com/apache/maven-wrapper/issues/325 for further details and issue.

Maven 4.0.0-beta-5 and above changed to use selective MAVEN_MAIN_CLASS. Because maven wrapper very closely mimics mavens own mvn and mvn.cmd, any changes would need ported to the maven wrapper. However, to some degree that breaks backwards compatibility since its a maven 4 item only but would work by fixing wrapper as noted (probably more than I did). I think it would be better though to add the defaulting when missing inside maven itself rather than expect the script pass a defaulted value along so that there is no breaking maven wrapper.

This line

if "%MAVEN_MAIN_CLASS%"=="" @set MAVEN_MAIN_CLASS=org.apache.maven.cling.MavenCling

Can we do this inside maven itself when missing instead? That would immediately fix the maven wrapper issue. Since its the internals throwing errors, I suspect that answer is yes.

hazendaz avatar Jun 26 '25 14:06 hazendaz

This looks similar to the issue I was mentioning in https://github.com/apache/maven/pull/1750#issuecomment-2417841944

To which @gnodet replied with:

I suppose we could make it default to org.apache.maven.cling.MavenCling ...

DidierLoiseau avatar Jul 07 '25 13:07 DidierLoiseau

This is currently out of control from Maven. Maven uses plexus classworlds to bootstrap the java JVM and it does not seem a good idea to make it dependant on Maven. I'm investigating replacing it, so this may be an opportunity to fix it, but not short term.

The locations inside maven already default to org.apache.maven.cling.MavenCling, but unfortunately, none of them is in java, as they are in the shell scripts and in the m2.conf.

gnodet avatar Oct 10 '25 07:10 gnodet