Skip to content

Gradle Parameter Replacement incompatible with Gradle Version #7442

Open

Description

@vbrandl

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 9bc649b. This flag is not supported in Gradle versions below 8:

Here is the Gradle commit that added the short form for --refresh-dependencies: gradle/gradle@3c0d26f. 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 -U should fail with Unknown 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 check
    

    Here --refresh-dependencies has been replaced with -U which 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 9bc649b.

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

Activity

  1. added
    kind:bug
    needs:triage
    on Jun 6, 2024
  2. added
    Gradle
    on Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Gradlekind:bugneeds:triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions