kelemen / netbeans-gradle-project

This project is a NetBeans plugin able to open Gradle based Java projects. The implementation is based on Geertjan Wielenga's plugin.
172 stars 57 forks source link

Platform Priority Fails -- option panel #369

Open aplatypus opened 6 years ago

aplatypus commented 6 years ago

Hi ...

The Gradle plugin is not letting me tell Netbeans to use Java 8. I tried to two obvious approaches to correct this but for some reason the platform Gradle uses limits me to Java 1.7. It is a little difficult to believe really.

Desired result:

The build.gradle file has:

sourceCompatibility = '1.8'
targetCompatibility = '1.8'

In addition when the program runs it appears to be picking up the designate Java 1.7 source, see:

The critical point here is that gradle build successfully builds from the command line but Netbeans is showing errors for Java 8 structures and it will not run because Netbeans thinks there are errors.

First Approach

  1. I clicked on Netbeans: Tools / Options and Miscellaneous.
  2. Selected [Gradle] panel
  3. Click on Category: "Platform Priority"
  4. Moved "JDK 1.8" from line #5 to top of the list, as instructed
  5. Pressed [Apply] button

Result:

Second Approach

  1. I clicked on Netbeans: Run / Project Configuration / Customize
  2. For the purposes of the exercise, I just selected one gradle profile: "localhost build"
  3. There are 5 x Java platforms showing from Tools/Java Platforms menu
  4. "Platform for Build Scripts"
    1. Un-check "[] Inherit"
    2. Select drop-down list platforms -- fails to show current list
    3. Only 2 Platforms show on the "Platform for Build Scripts" drop-down list. Both are Java 7 platform configurations.
  5. "Target platform"
    1. Un-check "[] Inherit"
    2. Select drop-down list platforms -- does not show current list
    3. Only shows the same 2 Java 1.7 Platforms shown before.
  6. Press OK -- but nothing has changed.
  7. Evidently the gradle config is not picking up the current list of Platforms

Attempting to set "Global Defaults" profile:

  1. Select "Global Defaults" from the Customize panel
  2. "Platform for Build Scripts"
    1. Un-check "[] Inherit"
    2. Select drop-down list platforms -- Appears to show the current list
    3. Select "JDK 1.8" platform
  3. "Target platform"
    1. Un-check "[] Inherit"
    2. Select drop-down list platforms -- Again, it does not show current list
    3. Only shows the same 2 Java 1.7 Platforms shown before.
  4. Press [OK]
  5. Reopen the Customize panel
  6. Select "Global Defaults"
  7. "Platform for Build Scripts" --> selected platform = "JDK 1.7"
    • This has changed back
    • I also discovered that "Build platform" will only change one of the only two Java 7 platforms showing on other panels and examples.
  8. "Target platform" --> selected platform = "JDK 1.7"
    • It will change to the other one of the only two platforms showing

Result:

The net result is there appears to be NO way to change platform so that it "sticks". Unreliable and introducing errors.

kelemen commented 6 years ago

The JDK list in the project properties are grouped by JDK version number, so I guess that 1.8 disapears because you have the same directory selected for JDK 8 as for 7. This hypotesis is consistent with what you see in the global settings because JDKs are saved based on their root folder (so the plugin won't really remember the order if they are essentially the same). Also, the priority list is simply meant for the plugin to distinguish between JDKs with the same version number, it will not affect JDKs with different version number.

aplatypus commented 6 years ago

The Java (JDK) platforms on Netbeans are ALL in different directories, for example.

Now, JDK 1.8 doesn't even show on the list sometimes. I have no idea what "... because you have the same directory selected for JDK 8 as for 7", is meant to say. They are definitely different.

If the "Platform Priority" doesn't do anything, then it should be removed from the panel. It is most confusing to have a button that does nothing.

Of course that begs the question of HOW one is able to select a different platform with Gradle.

Choosing platforms for Ant and Maven projects has always performed effortlessly.

A solution is needed. Can we delete some cache or user directory setting so things will work (correctly)?

kelemen commented 6 years ago

Platform priority is necessary when you have multiple JDKs with the same version. It is just not important for you.

Simply selecting the JDK in the project properties should work, and I have never seen it not to work. Can you send me your config/Preferences/org/netbeans/gradle/project-defaults.xml file if I can spot something in it?

Still I believe that NB reports the same version for multiple JDKs. Anyway, I have pushed some changes showing the version number of the platforms as the plugin sees it. Can you (build the plugin from the sources and) check what is displayed in the platform priority list?