Gradle Parameter Replacement incompatible with Gradle Version
Apache NetBeans version
Apache NetBeans 22
What happened
NetBeans seems to replace Gradle CLI Parameters with their short form based on GradleCommandLine. When defining a custom build task with the --refresh-dependency flag, this is shortened to -U. The addition of the -U flag to NetBeans came with commit 9bc649bac0bdd83d51a71cce80759252dd213b00. This flag is not supported in Gradle versions below 8:
-
Gradle 7.6.2 Userguide (note that
-Uis missing from the--refresh-dependenciesdocumentation -
Gradle 8.5 Userguide (here
-Uis documented)
Here is the Gradle commit that added the short form for --refresh-dependencies: https://github.com/gradle/gradle/commit/3c0d26f9cb468cec7db41528daae90c1876120e6. This is only included in 8.* releases.
This behavior breaks all custom Gradle tasks using the --refresh-dependencies flag in projects that use a Gradle wrapper < 8.
Language / Project Type / NetBeans Component
Java Gradle Project
How to reproduce
-
Create a Gradle Project with a Gradle 7 wrapper (
gradle init, then./gradlew wrapper --gradle-version 7.6.2). Now./gradlew -Ushould fail withUnknown command-line option '-U'. -
Add a custom task under
Project Properties->Build->Build Actions, with the arguments--refresh-dependencies check -
Execute the new task
-
The Output shows something like this:
JAVA_HOME="/usr/lib/jvm/default" cd <path to project>; ./gradlew --configure-on-demand -U checkHere
--refresh-dependencieshas been replaced with-Uwhich is not supported by the Gradle wrapper. -
The output stays empty and an unexpected exception is reported:
A org.gradle.tooling.exceptions.UnsupportedBuildArgumentException has occurred.
If you are running the [latest](https://netbeans.apache.org/download) version of NetBeans you can [report this](https://netbeans.apache.org/nb/report-issue), including a copy of your messages.log file as an attachment.
The messages.log file is located in [this folder](file:///home/me/.netbeans/22/var/log/).
Here is the messages.log file: messages.log
Did this work correctly in an earlier version?
Apache NetBeans 21
Operating System
Linux
JDK
openjdk 17.0.11 2024-04-16
Apache NetBeans packaging
Third-party package
Anything else
This should have worked even on NetBeans 22 before the commit 9bc649bac0bdd83d51a71cce80759252dd213b00.
This might also affect other Gradle flags, I only noticed it for --refresh-dependencies until now.
I would suggest not replacing user supplied arguments or to keep track of the minimum required Gradle version for each flag and only replace flags that are actually supported.
I'm using the netbeans-bin AUR package which uses the Release zip from https://downloads.apache.org/netbeans/netbeans/22/netbeans-22-bin.zip but this bug is also reproducible in Ubuntu and shouldn't depend on the packaging.
Are you willing to submit a pull request?
No