Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Project Dictated JVM for Gradle Discovery #4985

Merged

Conversation

lkishalmi
Copy link
Contributor

There would be more commits after this one. Need to iron out the following things:

  • Use the Project dictated Gradle Version in most cases. Revert back to the supplied one only if the project JVM is misaligned.
  • Project problem provider should only report misaligned project JVM and Gradle version, also offer a fix to select project JVM
  • Move Gradle Compile customizer options to Gradle Execution
  • Offer better Gradle JVM Selection made it available on Root project only.

@lkishalmi lkishalmi added the Gradle [ci] enable "build tools" tests label Nov 18, 2022
@lkishalmi lkishalmi added this to the NB17 milestone Nov 18, 2022
@lkishalmi lkishalmi changed the title Minimal support to use project JVM for Gradle Discovery Use Project Dictated JVM for Gradle Discovery Nov 18, 2022
@mbien mbien linked an issue Nov 18, 2022 that may be closed by this pull request
@matthiasblaesing
Copy link
Contributor

My personal worst-case is developing for liferay-portal. It uses a custom patched gradle version and requires JDK 8 to build. This seems to improve the situation a lot! This is not yet a comprehensive test, but this is what I did:

I build NetBeans from this branch. Additionally I had to adjust the gradle deamon settings like this (~/.gradle/gradle.properties):

org.gradle.jvmargs=-Xms512m -Xmx4g
liferay.home=/home/matthias/src/liferay-portal/bundles/

The first option give the gradle daemon enough space to handle the projects and the second is needed as the liferay build system sets this property from the ant invocation that starts the build. I have to restructure the build minimally, so that the grade wrapper is found. I build liferay once using ant all, then I copy the gradle directory from the main directory to modules. In the modules/gradle/wrapper/gradle-wrapper.properties I change the distributionUrl to distributionUrl=../../../tools/gradle-6.9.2-LIFERAY-PATCHED1-bin.zip. Finally the patched gradle needs to be renamed to fit the gradle versioning scheme from gradle-6.9.2.LIFERAY-PATCHED-1-bin.zip to gradle-6.9.2-LIFERAY-PATCHED1-bin.zip .

Project loading takes time, but it feels nice to be able to open the projects in a sane manner. Thank you!

@matthiasblaesing
Copy link
Contributor

As an update: I noticed, that I tested running on OpenJDK 11, but it also works on JDK 17 if I patch the GradleDistributionManager

diff --git a/extide/gradle/src/org/netbeans/modules/gradle/api/execute/GradleDistributionManager.java b/extide/gradle/src/org/netbeans/modules/gradle/api/execute/GradleDistributionManager.java
index c468f0737a1e..366b0574a8b1 100644
--- a/extide/gradle/src/org/netbeans/modules/gradle/api/execute/GradleDistributionManager.java
+++ b/extide/gradle/src/org/netbeans/modules/gradle/api/execute/GradleDistributionManager.java
@@ -532,7 +532,8 @@ public final class GradleDistributionManager {
          * @return <code>true</code> if this version is supported with the runtime JDK.
          */
         public boolean isCompatibleWithSystemJava() {
-            return isCompatibleWithJava(JAVA_VERSION);
+            return true;
+//            return isCompatibleWithJava(JAVA_VERSION);
         }
 
         /**

@lkishalmi
Copy link
Contributor Author

Yes, that's a trivial patch for the first bulletpoint. It's on my radar, just got slammed with work in the last few weeks.

@lkishalmi lkishalmi marked this pull request as ready for review November 27, 2022 01:36
@lkishalmi
Copy link
Contributor Author

Well, this form is a good enough implementation, without major changes.

The GradleProjectConnection got rid of the "compatible" connection thing, So NetBeans does not try override the Gradle distribution in any case. The javaHome is set there so other places where ProjectConnection is needed, has the Java home and the Gradle Distribution set.

The Java vs Gradle version mismatch problem only triggered, if the Project Java setting is off.

I'm going to create a new update branch for NB16, where this and a few other fixes would go, as I think the Gradle support in base NB16 is not that great.

@matthiasblaesing
Copy link
Contributor

Works for me. Build from this branch, ensured JDK 17 is active and was able to load liferay project after setting its JDK to 8. Thank you!

@sdedic
Copy link
Member

sdedic commented Nov 29, 2022

@errael
Copy link
Contributor

errael commented Nov 29, 2022

@sdedic

Question: should <some_link> still a warning message ?

I think the link is messed up.

@lkishalmi lkishalmi added the 16u1 label Dec 6, 2022
@lkishalmi
Copy link
Contributor Author

Question: should be https://github.com/lkishalmi/netbeans/blob/gradle-use-project-java-for-discovery/extide/gradle/src/org/netbeans/modules/gradle/execute/GradleDaemonExecutor.java#L312 still a warning message ?

(link corrected)

I think yes, it should be a Warning message. Though it is now displayed if the JVM set on project is not compatible with the Gradle in use. In that case the IDE would still try to use the "built-in" Gradle. It would be elegant to have a resolver for this problem. That's for a later time though...

@lkishalmi lkishalmi merged commit 33c8074 into apache:master Dec 6, 2022
lkishalmi added a commit to lkishalmi/netbeans that referenced this pull request Dec 6, 2022
@lkishalmi lkishalmi removed the 16u1 label Dec 6, 2022
pepness pushed a commit to pepness/incubator-netbeans that referenced this pull request Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gradle [ci] enable "build tools" tests Need Squashing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gradle projects dictate NetBeans' JDK runtime
5 participants