Skip to content

Gradle Project Can't Regconise and Change Java Source/Binary Level  #5958

Open

Description

@wayne-zhang

Apache NetBeans version

Apache NetBeans 17

What happened

Open a Gradle project by Netbeans, it can't recognize source and binary Java level in build.gradle file. See the screenshot attached.

In this example project, source and binary level set to 1.8 but Netbeans recognized it as 1.5.

Create a new Gradle project, source level sets to 1.5 and can't be changed in Netbeans.

netbeans-gradle-bug

How to reproduce

Open an existing Gradle project that defined source/binary level other than 1.5.

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows 10

JDK

Java 8, Java 11

Apache NetBeans packaging

Apache NetBeans binary zip

Anything else

No response

Are you willing to submit a pull request?

No

Activity

  1. added
    kind:bug
    needs:triage
    on May 18, 2023
  2. added
    Gradle
    and removed
    needs:triage
    on May 18, 2023
  3. lkishalmi commented on May 19, 2023

    @lkishalmi
    Contributor

    I cannot reproduce this one. Using NetBeans 18-rc3.

  4. lkishalmi commented on May 19, 2023

    @lkishalmi
    Contributor

    Additional info. Sample project would be nice!

  5. added
    pending-response
    on May 19, 2023
  6. wayne-zhang commented on May 29, 2023

    @wayne-zhang
    Author

    Hi @lkishalmi,
    I did further test/investigation and found that it is NOT a bug of Gradle plugin actually, it possible caused by my NetBeans workspace has corrupted (I always use the same workspace for any release of NetBeans, I upgrade NetBeans where there is a new release and share the workspace). When I delete the Gradle project that has compilation errors in NetBeans IDE (not in Gradle build console), open the project again, and the compilation error (that caused by source level) disappeared.

    When I copy my project (that has problem) to a different folder, try to upload as an example project to this JIRA, I found it can be opened without any issue. So I found it's a corrupted workspace issue.

    This issue can be closed.

    However, the source/binary target level in Gradle project properties is ALWAYS 1.5 and can't be changed, it will be great if it can set to the correct value (from Gradle build file build.gradle) and can be changed in NetBeans' project configuration.

  7. lkishalmi commented on May 29, 2023

    @lkishalmi
    Contributor

    However, the source/binary target level in Gradle project properties is ALWAYS 1.5 and can't be changed, it will be great if it can set to the correct value (from Gradle build file build.gradle) and can be changed in NetBeans' project configuration.

    Well, that's strange. I think there is some edge case in your project. You might get the project attached or just build NetBeans yourself and debug the following function:

    private Optional<String> fixJavaCompatibility(SourceType sourceType, String flag, Map<SourceType, String> compatibilityMap) {

  8. wayne-zhang commented on May 29, 2023

    @wayne-zhang
    Author

    I used a new workspace and tested, a brand new Gradle project created works (source/binary Java level reads from build.gradle correctly) but open an existing (legacy) Gradle project doesn't work - source/binary level sets to 1.8 but Netbeans reads it as 1.5.

    BigFraction.zip

  9. removed
    pending-response
    on Jan 24, 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:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions