JoyOfCoding icon indicating copy to clipboard operation
JoyOfCoding copied to clipboard

Use the new/real Maven Wrapper

Open DavidWhitlock opened this issue 3 years ago • 7 comments

It looks like Maven wrapper has been promoted to be a first-class citizen in Maven:

https://maven.apache.org/plugins/maven-wrapper-plugin/index.html

I should recreate the Maven wrapper scripts and jars using that plugin.

DavidWhitlock avatar May 16 '21 14:05 DavidWhitlock

Or maybe not. After upgrading to the latest Maven, I tried running the wrapper:wrapper plugin and I got this error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-wrapper-plugin:3.0.2:wrapper (default-cli) on project student: wrapperVersion not supported for Maven 3.8.1, it must be at least 4. -> [Help 1]

So, this doesn't look like it's quite ready for primetime yet.

DavidWhitlock avatar May 16 '21 14:05 DavidWhitlock

It might be worth giving this a try again.

https://maven.apache.org/wrapper/

https://www.baeldung.com/maven-wrapper

So, it looks like this might do the trick:

mvn -N wrapper:wrapper

DavidWhitlock avatar May 14 '22 16:05 DavidWhitlock

No dice.

It looks like the official Maven Wrapper plugin still requires Maven 4:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-wrapper-plugin:3.0.2:wrapper (default-cli) on project cs410j: wrapperVersion not supported for Maven 3.8.5, it must be at least 4. -> [Help 1]

DavidWhitlock avatar May 14 '22 23:05 DavidWhitlock

I had the same error and have been looking for a long time for a solution. Finally, I found it.

When you just call the goal with wrapper:wrapper, for some reason version 3.0.2 of the plugin is used although there are only higher versions available on Maven Central.

If you call the goal explicitly with the latest plugin version, it works:

mvn org.apache.maven.plugins:maven-wrapper-plugin:3.1.1:wrapper

kiwi-oss avatar Jul 23 '22 08:07 kiwi-oss

Awesome! Thanks for letting me know. I'll give this a try when I start preparing for the Winter offering of my course.

DavidWhitlock avatar Jul 23 '22 15:07 DavidWhitlock

You're welcome! I imagine providing a controlled environment is especially useful in the context of Java courses.

It's definitely a blessing for me who was otherwise stuck on a not-so-recent Maven version from the Ubuntu LTS repository which doesn't work with the latest Java versions.

kiwi-oss avatar Jul 23 '22 21:07 kiwi-oss

Well, the Gilded Rose kata uses the Apache Maven Wrapper: https://github.com/emilybache/GildedRose-Refactoring-Kata/commit/0eab1974d7d8e4924f825885f00c6f5a8e26dd98

So, we should be able to, also.

DavidWhitlock avatar Jan 28 '23 16:01 DavidWhitlock