From 4db03de8dd54810db4019b272813ee273125e2b9 Mon Sep 17 00:00:00 2001 From: William Price Date: Mon, 8 Sep 2025 21:32:31 -0500 Subject: [PATCH] Upgrade netbeans-gradle-tooling to use Gradle 8.11.1 --- extide/gradle/build.xml | 4 +- extide/gradle/external/binaries-list | 2 +- .../gradle/external/gradle-7.4-bin-notice.txt | 1 - ...ense.txt => gradle-8.11.1-bin-license.txt} | 7 +- .../external/gradle-8.11.1-bin-notice.txt | 21 ++++ ....txt => gradle-wrapper-8.11.1-license.txt} | 2 +- extide/gradle/nbproject/project.properties | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- .../gradle/tooling/GradleInternalAdapter.java | 8 +- .../gradle/tooling/NbProjectInfoBuilder.java | 101 +++++++++++------- .../netbeans/nbbuild/extlibs/ignored-overlaps | 22 ++-- nbbuild/licenses/Gradle | 5 +- 12 files changed, 110 insertions(+), 67 deletions(-) delete mode 100644 extide/gradle/external/gradle-7.4-bin-notice.txt rename extide/gradle/external/{gradle-7.4-bin-license.txt => gradle-8.11.1-bin-license.txt} (99%) create mode 100644 extide/gradle/external/gradle-8.11.1-bin-notice.txt rename extide/gradle/external/{gradle-wrapper-7.4-license.txt => gradle-wrapper-8.11.1-license.txt} (99%) diff --git a/extide/gradle/build.xml b/extide/gradle/build.xml index 8159212a045e..2ad39d7ad386 100644 --- a/extide/gradle/build.xml +++ b/extide/gradle/build.xml @@ -25,12 +25,12 @@ - + - + diff --git a/extide/gradle/external/binaries-list b/extide/gradle/external/binaries-list index cc189311b3a1..d1bf02375ab7 100644 --- a/extide/gradle/external/binaries-list +++ b/extide/gradle/external/binaries-list @@ -15,4 +15,4 @@ # specific language governing permissions and limitations # under the License. -483F39DCC23C3FB098C00E6A14E0AEBE3D10F00C https://services.gradle.org/distributions/gradle-7.4-bin.zip gradle-7.4-bin.zip +C26B6A81460F9AC40D4CB2911E8FA87F462E6AD8 https://services.gradle.org/distributions/gradle-8.11.1-bin.zip gradle-8.11.1-bin.zip diff --git a/extide/gradle/external/gradle-7.4-bin-notice.txt b/extide/gradle/external/gradle-7.4-bin-notice.txt deleted file mode 100644 index 8b137891791f..000000000000 --- a/extide/gradle/external/gradle-7.4-bin-notice.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/extide/gradle/external/gradle-7.4-bin-license.txt b/extide/gradle/external/gradle-8.11.1-bin-license.txt similarity index 99% rename from extide/gradle/external/gradle-7.4-bin-license.txt rename to extide/gradle/external/gradle-8.11.1-bin-license.txt index adc0ab0c932f..fdbb86d69dc7 100644 --- a/extide/gradle/external/gradle-7.4-bin-license.txt +++ b/extide/gradle/external/gradle-8.11.1-bin-license.txt @@ -1,6 +1,6 @@ Name: Gradle Description: Gradle Build System -Version: 7.4 +Version: 8.11.1 License: Gradle Origin: Gradle Inc. URL: https://gradle.org/ @@ -386,10 +386,11 @@ org.eclipse.jgit:org.eclipse.jgit ------------------------------------------------------------------------------ BSD-style -com.jcraft:jsch com.jcraft:jzlib +com.github.mwiede:jsch -Copyright (c) 2000-2011 ymnk, JCraft,Inc. All rights reserved. +Copyright (c) 2002-2015 Atsuhiko Yamanaka, JCraft,Inc. +All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/extide/gradle/external/gradle-8.11.1-bin-notice.txt b/extide/gradle/external/gradle-8.11.1-bin-notice.txt new file mode 100644 index 000000000000..00a36efcde24 --- /dev/null +++ b/extide/gradle/external/gradle-8.11.1-bin-notice.txt @@ -0,0 +1,21 @@ +========================================================================= +== NOTICE file corresponding to the section 4 d of == +== the Apache License, Version 2.0, == +== in this case for the Gradle distribution. == +========================================================================= + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + +It includes the following other software: + +Groovy (http://groovy-lang.org) +SLF4J (http://www.slf4j.org) +JUnit (http://www.junit.org) +JCIFS (http://jcifs.samba.org) +HttpClient (https://hc.apache.org/httpcomponents-client-4.5.x/) + +For licenses, see the LICENSE file. + +If any software distributed with Gradle does not have an Apache 2 License, its license is explicitly listed in the +LICENSE file. diff --git a/extide/gradle/external/gradle-wrapper-7.4-license.txt b/extide/gradle/external/gradle-wrapper-8.11.1-license.txt similarity index 99% rename from extide/gradle/external/gradle-wrapper-7.4-license.txt rename to extide/gradle/external/gradle-wrapper-8.11.1-license.txt index a187c423bc7b..05cecbb15c7b 100644 --- a/extide/gradle/external/gradle-wrapper-7.4-license.txt +++ b/extide/gradle/external/gradle-wrapper-8.11.1-license.txt @@ -1,6 +1,6 @@ Name: Gradle Wrapper Description: Gradle Wrapper -Version: 7.4 +Version: 8.11.1 License: Apache-2.0 Origin: Gradle Inc. URL: https://gradle.org/ diff --git a/extide/gradle/nbproject/project.properties b/extide/gradle/nbproject/project.properties index f6aa03d7a12a..4f0184139aa4 100644 --- a/extide/gradle/nbproject/project.properties +++ b/extide/gradle/nbproject/project.properties @@ -42,4 +42,4 @@ extra.module.files=\ # These properties are used for compiling the netbeans-gradle-tooling library # It shall be built on the lowest language level that the Gradle integration supports tooling.javac.release=8 -tooling.gradle.version=7.4 +tooling.gradle.version=8.11.1 diff --git a/extide/gradle/netbeans-gradle-tooling/gradle/wrapper/gradle-wrapper.properties b/extide/gradle/netbeans-gradle-tooling/gradle/wrapper/gradle-wrapper.properties index 8f796e3ee603..f46945d7ac08 100644 --- a/extide/gradle/netbeans-gradle-tooling/gradle/wrapper/gradle-wrapper.properties +++ b/extide/gradle/netbeans-gradle-tooling/gradle/wrapper/gradle-wrapper.properties @@ -19,4 +19,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=../../../external/gradle-7.4-bin.zip +distributionUrl=../../../external/gradle-8.11.1-bin.zip diff --git a/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/GradleInternalAdapter.java b/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/GradleInternalAdapter.java index 95a753f6b83c..e203998086f2 100644 --- a/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/GradleInternalAdapter.java +++ b/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/GradleInternalAdapter.java @@ -92,7 +92,7 @@ public void setModel(NbProjectInfoModel model) { } protected boolean isFixedValue(String description, ValueSupplier.ExecutionTimeValue etv) { - return etv.isFixedValue(); + return etv.hasFixedValue(); } public boolean isMutableType(Object potentialValue) { @@ -192,17 +192,17 @@ protected Optional safeCall(ExceptionCallable } } - public static class Gradle76 extends GradleInternalAdapter { + public static class GradlePre76 extends GradleInternalAdapter { private static Optional refHasValue; - public Gradle76(Project project) { + public GradlePre76(Project project) { super(project); } @Override protected boolean isFixedValue(String description, ValueSupplier.ExecutionTimeValue etv) { if (refHasValue == null) { - refHasValue = safeCall(() -> ValueSupplier.ExecutionTimeValue.class.getMethod("hasFixedValue"), "Gradle 7.6+ ExecutionTimeValue"); + refHasValue = safeCall(() -> ValueSupplier.ExecutionTimeValue.class.getMethod("isFixedValue"), "Gradle <7.6 ExecutionTimeValue"); } if (refHasValue.isPresent()) { return safeCall(() -> (Boolean)refHasValue.get().invoke(etv), description).orElse(false); diff --git a/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.java b/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.java index 7a62d2d8dd2e..30d0e5e28fbb 100644 --- a/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.java +++ b/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.java @@ -50,7 +50,6 @@ import java.util.Set; import java.util.function.Consumer; import java.util.function.Function; -import java.util.function.Supplier; import java.util.regex.Pattern; import java.util.stream.Collectors; import org.codehaus.groovy.runtime.InvokerHelper; @@ -203,6 +202,28 @@ class NbProjectInfoBuilder { private static final GradleVersion GRADLE_VERSION = GradleVersion.current().getBaseVersion(); + /** Jar.getClassifier() was deprecated since Gradle 5.2, removed in 8.0 */ + private static final Method GRADLE_JAR_GET_CLASSIFIER; + + /** Jar.getArchivePath() was deprecated since Gradle 5.2, removed in 8.0 */ + private static final Method GRADLE_JAR_GET_ARCHIVEPATH; + + static { + Method getClassifier = null; + Method getArchivePath = null; + if (GRADLE_VERSION.compareTo(GradleVersion.version("8.0")) < 0) { + try { + getClassifier = Jar.class.getMethod("getClassifier"); + getArchivePath = Jar.class.getMethod("getArchivePath"); + } catch (ReflectiveOperationException e) { + LOG.error("Did not find expected method(s) on {}", Jar.class, e); + } + } + // null on newer versions + GRADLE_JAR_GET_CLASSIFIER = getClassifier; + GRADLE_JAR_GET_ARCHIVEPATH = getArchivePath; + } + final Project project; final GradleInternalAdapter adapter; @@ -223,7 +244,7 @@ public ValueAndType(Class type) { NbProjectInfoBuilder(Project project) { this.project = project; - this.adapter = sinceGradleOrDefault("7.6", () -> new GradleInternalAdapter.Gradle76(project), () -> new GradleInternalAdapter(project)); + this.adapter = sinceGradleOrDefault("7.6", () -> new GradleInternalAdapter(project), () -> new GradleInternalAdapter.GradlePre76(project)); } private NbProjectInfoModel model = new NbProjectInfoModel(); @@ -367,11 +388,19 @@ private String dependenciesAsString(Task t, TaskDependency td) { } private void detectConfigurationArtifacts(NbProjectInfoModel model) { + // JDK-8301046: Don't use Configuration::getName as a method reference. The bug, when + // compiling `Configuration::getName` against Gradle >= 8.4, causes javac to pick the + // wrong receiver target (invokeinterface on Named::getName) in the lambda bootstrap + // method params rather than the (correct per JLS) invokevirtual on the callsite's + // erasure type (Configuration). This will break at runtime when calling Gradle <8.4, + // as in earlier versions the Configuration class does not implement Named, and throws + // a BootstrapMethodError wrapping a LambdaConversionException. The lambda form: + // `c -> c.getName()` bootstraps correctly but costs an extra method def/indirection. List configs = project.getConfigurations() .stream() .filter(Configuration::isCanBeConsumed) .filter(c -> !c.isCanBeResolved()) - .sorted(Comparator.comparing(Configuration::getName)) + .sorted(Comparator.comparing(c -> c.getName())) // JDK-8301046 .collect(Collectors.toList()); Map data = new HashMap<>(); for (Configuration c : configs) { @@ -1361,19 +1390,22 @@ private void detectArtifacts(NbProjectInfoModel model) { model.noteProblem(e, false); } } - Map archives = new HashMap<>(); - beforeGradle("5.2", () -> { - // The jar.getCassifier() and jar.getArchievePath() are deprecated since 5.2 - // These methods got removed in 8.0 - project.getTasks().withType(Jar.class).forEach(jar -> { - archives.put(jar.getClassifier(), jar.getArchivePath()); - }); - }); - sinceGradle("5.2", () -> { - project.getTasks().withType(Jar.class).forEach(jar -> { - archives.put(jar.getArchiveClassifier().get(), jar.getDestinationDirectory().file(jar.getArchiveFileName().get()).get().getAsFile()); - }); - }); + Map archives = new HashMap<>(); + Consumer jarToArchivesClassifierAndPath = + sinceGradleOrDefault( + "5.2", + () -> jar -> archives.put(jar.getArchiveClassifier().get(), jar.getDestinationDirectory().file(jar.getArchiveFileName().get()).get().getAsFile()), + () -> jar -> { + try { + archives.put( + (String) GRADLE_JAR_GET_CLASSIFIER.invoke(jar), + (File) GRADLE_JAR_GET_ARCHIVEPATH.invoke(jar)); + } catch (ReflectiveOperationException e) { + sneakyThrow(e); + } + } + ); + project.getTasks().withType(Jar.class).forEach(jarToArchivesClassifierAndPath); model.getInfo().put("archives", archives); } @@ -1567,17 +1599,7 @@ private void detectDependencies(NbProjectInfoModel model) { Function projDependencyToProject = sinceGradleOrDefault( "9.0", - () -> { - Method getPath = ProjectDependency.class.getMethod("getPath"); - return dep -> { - try { - String path = (String) getPath.invoke(dep); - return project.findProject(path); - } catch (ReflectiveOperationException e) { - throw new UnsupportedOperationException(e); - } - }; - }, + () -> dep -> project.findProject(dep.getPath()), // getPath() added in Gradle 8.11 () -> ProjectDependency::getDependencyProject); // removed in Gradle 9 visibleConfigurations.forEach(it -> { @@ -1884,22 +1906,25 @@ interface ExceptionCallable { private static void sneakyThrow(Throwable exception) throws T { throw (T) exception; } - - private T sinceGradleOrDefault(String version, ExceptionCallable c, Supplier def) { + + private T sinceGradleOrDefault( + String version, ExceptionCallable c, ExceptionCallable def) { + ExceptionCallable impl; if (GRADLE_VERSION.compareTo(GradleVersion.version(version)) >= 0) { - try { - return c.call(); - } catch (RuntimeException | Error e) { - throw e; - } catch (Throwable t) { - sneakyThrow(t); - return null; - } + impl = c; } else if (def != null) { - return def.get(); + impl = def; } else { return null; } + try { + return impl.call(); + } catch (RuntimeException | Error e) { + throw e; + } catch (Throwable t) { + sneakyThrow(t); + return null; + } } private T sinceGradle(String version, ExceptionCallable c) { diff --git a/nbbuild/antsrc/org/netbeans/nbbuild/extlibs/ignored-overlaps b/nbbuild/antsrc/org/netbeans/nbbuild/extlibs/ignored-overlaps index 12b5748a1a75..3bda126aaa2b 100644 --- a/nbbuild/antsrc/org/netbeans/nbbuild/extlibs/ignored-overlaps +++ b/nbbuild/antsrc/org/netbeans/nbbuild/extlibs/ignored-overlaps @@ -52,19 +52,15 @@ enterprise/websvc.restlib/external/jakarta.xml.bind-api-2.3.3.jar ide/xml.jaxb.a enterprise/websvc.restlib/external/osgi.core-8.0.0.jar platform/libs.osgi/external/osgi.core-8.0.0.jar # gradle is used at build-time, so we can ignore the duplicates -extide/gradle/external/gradle-7.4-bin.zip enterprise/libs.amazon/external/ion-java-1.0.2.jar -extide/gradle/external/gradle-7.4-bin.zip ide/c.google.guava.failureaccess/external/failureaccess-1.0.3.jar -extide/gradle/external/gradle-7.4-bin.zip ide/c.jcraft.jzlib/external/jzlib-1.1.3.jar -extide/gradle/external/gradle-7.4-bin.zip ide/libs.commons_compress/external/commons-compress-1.27.1.jar -extide/gradle/external/gradle-7.4-bin.zip ide/o.apache.commons.lang/external/commons-lang-2.6.jar -extide/gradle/external/gradle-7.4-bin.zip ide/o.eclipse.jgit/external/org.eclipse.jgit-7.2.0.202503040940-r.jar -extide/gradle/external/gradle-7.4-bin.zip java/debugger.jpda.truffle/external/antlr4-runtime-4.7.2.jar -extide/gradle/external/gradle-7.4-bin.zip java/maven.embedder/external/apache-maven-3.9.11-bin.zip -extide/gradle/external/gradle-7.4-bin.zip platform/libs.junit4/external/hamcrest-core-1.3.jar -extide/gradle/external/gradle-7.4-bin.zip platform/libs.junit4/external/junit-4.13.2.jar -extide/gradle/external/gradle-7.4-bin.zip platform/libs.testng/external/jcommander-1.78.jar -extide/gradle/external/gradle-7.4-bin.zip enterprise/cloud.oracle/external/httpclient-4.5.13.jar -extide/gradle/external/gradle-7.4-bin.zip platform/o.apache.commons.codec/external/commons-codec-1.18.0.jar +extide/gradle/external/gradle-8.11.1-bin.zip extide/o.apache.tools.ant.module/external/apache-ant-1.10.14-bin.zip +extide/gradle/external/gradle-8.11.1-bin.zip ide/o.apache.commons.lang/external/commons-lang-2.6.jar +extide/gradle/external/gradle-8.11.1-bin.zip ide/slf4j.api/external/slf4j-api-1.7.36.jar +extide/gradle/external/gradle-8.11.1-bin.zip java/maven.embedder/external/apache-maven-3.9.11-bin.zip +extide/gradle/external/gradle-8.11.1-bin.zip nbbuild/external/jsoup-1.15.3.jar +extide/gradle/external/gradle-8.11.1-bin.zip platform/libs.junit4/external/hamcrest-core-1.3.jar +extide/gradle/external/gradle-8.11.1-bin.zip platform/libs.junit4/external/junit-4.13.2.jar +extide/gradle/external/gradle-8.11.1-bin.zip platform/libs.junit5/external/opentest4j-1.3.0.jar +extide/gradle/external/gradle-8.11.1-bin.zip platform/libs.testng/external/jcommander-1.78.jar # These are the endorsed version of the javaee apis and create libraries, so they are better kept separate enterprise/javaee.api/external/javax.annotation-api-1.2.jar enterprise/javaee7.api/external/javax.annotation-api-1.2.jar diff --git a/nbbuild/licenses/Gradle b/nbbuild/licenses/Gradle index b684305657f3..bcde15711bb2 100644 --- a/nbbuild/licenses/Gradle +++ b/nbbuild/licenses/Gradle @@ -377,10 +377,11 @@ org.eclipse.jgit:org.eclipse.jgit ------------------------------------------------------------------------------ BSD-style -com.jcraft:jsch com.jcraft:jzlib +com.github.mwiede:jsch -Copyright (c) 2000-2011 ymnk, JCraft,Inc. All rights reserved. +Copyright (c) 2002-2015 Atsuhiko Yamanaka, JCraft,Inc. +All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: