Skip to content

Commit 510eae8

Browse files
committed
Upgrade netbeans-gradle-tooling to use Gradle 8.11.1
1 parent d10bf81 commit 510eae8

File tree

12 files changed

+90
-65
lines changed

12 files changed

+90
-65
lines changed

extide/gradle/build.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525

2626
<property name="test-unit-sys-prop.test.data.dir" location="test/data"/>
2727
<property name="tooling" value="netbeans-gradle-tooling"/>
28-
<property name="gradle.version" value="7.4" />
28+
<property name="gradle.version" value="8.11.1" />
2929

3030
<target name="-process.release.files" depends="projectized.-process.release.files">
3131
<unzip src="external/gradle-${gradle.version}-bin.zip" dest="external">
3232
<patternset>
33-
<include name="gradle-${gradle.version}/lib/gradle-wrapper-${gradle.version}.jar"/>
33+
<include name="gradle-${gradle.version}/lib/plugins/gradle-wrapper-main-${gradle.version}.jar"/>
3434
</patternset>
3535
<globmapper from="*" to="gradle-wrapper-${gradle.version}-wrapper.jar"/>
3636
</unzip>

extide/gradle/external/binaries-list

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
483F39DCC23C3FB098C00E6A14E0AEBE3D10F00C https://services.gradle.org/distributions/gradle-7.4-bin.zip gradle-7.4-bin.zip
18+
C26B6A81460F9AC40D4CB2911E8FA87F462E6AD8 https://services.gradle.org/distributions/gradle-8.11.1-bin.zip gradle-8.11.1-bin.zip

extide/gradle/external/gradle-7.4-bin-notice.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

extide/gradle/external/gradle-7.4-bin-license.txt renamed to extide/gradle/external/gradle-8.11.1-bin-license.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Name: Gradle
22
Description: Gradle Build System
3-
Version: 7.4
3+
Version: 8.11.1
44
License: Gradle
55
Origin: Gradle Inc.
66
URL: https://gradle.org/
@@ -386,10 +386,11 @@ org.eclipse.jgit:org.eclipse.jgit
386386
------------------------------------------------------------------------------
387387
BSD-style
388388

389-
com.jcraft:jsch
390389
com.jcraft:jzlib
390+
com.github.mwiede:jsch
391391

392-
Copyright (c) 2000-2011 ymnk, JCraft,Inc. All rights reserved.
392+
Copyright (c) 2002-2015 Atsuhiko Yamanaka, JCraft,Inc.
393+
All rights reserved.
393394

394395
Redistribution and use in source and binary forms, with or without
395396
modification, are permitted provided that the following conditions are met:
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
=========================================================================
2+
== NOTICE file corresponding to the section 4 d of ==
3+
== the Apache License, Version 2.0, ==
4+
== in this case for the Gradle distribution. ==
5+
=========================================================================
6+
7+
This product includes software developed by
8+
The Apache Software Foundation (http://www.apache.org/).
9+
10+
It includes the following other software:
11+
12+
Groovy (http://groovy-lang.org)
13+
SLF4J (http://www.slf4j.org)
14+
JUnit (http://www.junit.org)
15+
JCIFS (http://jcifs.samba.org)
16+
HttpClient (https://hc.apache.org/httpcomponents-client-4.5.x/)
17+
18+
For licenses, see the LICENSE file.
19+
20+
If any software distributed with Gradle does not have an Apache 2 License, its license is explicitly listed in the
21+
LICENSE file.

extide/gradle/external/gradle-wrapper-7.4-license.txt renamed to extide/gradle/external/gradle-wrapper-8.11.1-license.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Name: Gradle Wrapper
22
Description: Gradle Wrapper
3-
Version: 7.4
3+
Version: 8.11.1
44
License: Apache-2.0
55
Origin: Gradle Inc.
66
URL: https://gradle.org/

extide/gradle/nbproject/project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ extra.module.files=\
4242
# These properties are used for compiling the netbeans-gradle-tooling library
4343
# It shall be built on the lowest language level that the Gradle integration supports
4444
tooling.javac.release=8
45-
tooling.gradle.version=7.4
45+
tooling.gradle.version=8.11.1

extide/gradle/netbeans-gradle-tooling/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ distributionBase=GRADLE_USER_HOME
1919
distributionPath=wrapper/dists
2020
zipStoreBase=GRADLE_USER_HOME
2121
zipStorePath=wrapper/dists
22-
distributionUrl=../../../external/gradle-7.4-bin.zip
22+
distributionUrl=../../../external/gradle-8.11.1-bin.zip

extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/GradleInternalAdapter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void setModel(NbProjectInfoModel model) {
9292
}
9393

9494
protected boolean isFixedValue(String description, ValueSupplier.ExecutionTimeValue etv) {
95-
return etv.isFixedValue();
95+
return etv.hasFixedValue();
9696
}
9797

9898
public boolean isMutableType(Object potentialValue) {
@@ -192,17 +192,17 @@ protected <T, E extends Throwable> Optional<T> safeCall(ExceptionCallable<T, E>
192192
}
193193
}
194194

195-
public static class Gradle76 extends GradleInternalAdapter {
195+
public static class GradlePre76 extends GradleInternalAdapter {
196196
private static Optional<Method> refHasValue;
197197

198-
public Gradle76(Project project) {
198+
public GradlePre76(Project project) {
199199
super(project);
200200
}
201201

202202
@Override
203203
protected boolean isFixedValue(String description, ValueSupplier.ExecutionTimeValue etv) {
204204
if (refHasValue == null) {
205-
refHasValue = safeCall(() -> ValueSupplier.ExecutionTimeValue.class.getMethod("hasFixedValue"), "Gradle 7.6+ ExecutionTimeValue");
205+
refHasValue = safeCall(() -> ValueSupplier.ExecutionTimeValue.class.getMethod("isFixedValue"), "Gradle <7.6 ExecutionTimeValue");
206206
}
207207
if (refHasValue.isPresent()) {
208208
return safeCall(() -> (Boolean)refHasValue.get().invoke(etv), description).orElse(false);

extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.java

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public ValueAndType(Class type) {
223223

224224
NbProjectInfoBuilder(Project project) {
225225
this.project = project;
226-
this.adapter = sinceGradleOrDefault("7.6", () -> new GradleInternalAdapter.Gradle76(project), () -> new GradleInternalAdapter(project));
226+
this.adapter = sinceGradleOrDefault("7.6", () -> new GradleInternalAdapter(project), () -> new GradleInternalAdapter.GradlePre76(project));
227227
}
228228

229229
private NbProjectInfoModel model = new NbProjectInfoModel();
@@ -367,11 +367,19 @@ private String dependenciesAsString(Task t, TaskDependency td) {
367367
}
368368

369369
private void detectConfigurationArtifacts(NbProjectInfoModel model) {
370+
// JDK-8301046: Don't use Configuration::getName as a method reference. The bug, when
371+
// compiling `Configuration::getName` against Gradle >= 8.4, causes javac to pick the
372+
// wrong receiver target (invokeinterface on Named::getName) in the lambda bootstrap
373+
// method params rather than the (correct per JLS) invokevirtual on the callsite's
374+
// erasure type (Configuration). This will break at runtime when calling Gradle <8.4,
375+
// as in earlier versions the Configuration class does not implement Named, and throws
376+
// a BootstrapMethodError wrapping a LambdaConversionException. The lambda form:
377+
// `c -> c.getName()` bootstraps correctly but costs an extra method def/indirection.
370378
List<Configuration> configs = project.getConfigurations()
371379
.stream()
372380
.filter(Configuration::isCanBeConsumed)
373381
.filter(c -> !c.isCanBeResolved())
374-
.sorted(Comparator.comparing(Configuration::getName))
382+
.sorted(Comparator.comparing(c -> c.getName())) // JDK-8301046
375383
.collect(Collectors.toList());
376384
Map<String, Object> data = new HashMap<>();
377385
for (Configuration c : configs) {
@@ -1362,18 +1370,24 @@ private void detectArtifacts(NbProjectInfoModel model) {
13621370
}
13631371
}
13641372
Map<String, Object> archives = new HashMap<>();
1365-
beforeGradle("5.2", () -> {
1366-
// The jar.getCassifier() and jar.getArchievePath() are deprecated since 5.2
1367-
// These methods got removed in 8.0
1368-
project.getTasks().withType(Jar.class).forEach(jar -> {
1369-
archives.put(jar.getClassifier(), jar.getArchivePath());
1370-
});
1371-
});
1372-
sinceGradle("5.2", () -> {
1373-
project.getTasks().withType(Jar.class).forEach(jar -> {
1374-
archives.put(jar.getArchiveClassifier().get(), jar.getDestinationDirectory().file(jar.getArchiveFileName().get()).get().getAsFile());
1375-
});
1376-
});
1373+
Consumer<Jar> jarToArchivesClassifierAndPath =
1374+
sinceGradleOrDefault(
1375+
"5.2",
1376+
() -> jar -> archives.put(jar.getArchiveClassifier().get(), jar.getDestinationDirectory().file(jar.getArchiveFileName().get()).get().getAsFile()),
1377+
() -> {
1378+
// The jar.getCassifier() and jar.getArchievePath() are deprecated since 5.2
1379+
// These methods got removed in 8.0
1380+
Method getClassifier = Jar.class.getMethod("getClassifier");
1381+
Method getArchivePath = Jar.class.getMethod("getArchivePath");
1382+
return jar -> {
1383+
try {
1384+
archives.put((String) getClassifier.invoke(jar), (File) getArchivePath.invoke(jar));
1385+
} catch (ReflectiveOperationException e) {
1386+
sneakyThrow(e);
1387+
}
1388+
};
1389+
});
1390+
project.getTasks().withType(Jar.class).forEach(jarToArchivesClassifierAndPath);
13771391
model.getInfo().put("archives", archives);
13781392
}
13791393

@@ -1567,17 +1581,7 @@ private void detectDependencies(NbProjectInfoModel model) {
15671581
Function<ProjectDependency, Project> projDependencyToProject =
15681582
sinceGradleOrDefault(
15691583
"9.0",
1570-
() -> {
1571-
Method getPath = ProjectDependency.class.getMethod("getPath");
1572-
return dep -> {
1573-
try {
1574-
String path = (String) getPath.invoke(dep);
1575-
return project.findProject(path);
1576-
} catch (ReflectiveOperationException e) {
1577-
throw new UnsupportedOperationException(e);
1578-
}
1579-
};
1580-
},
1584+
() -> dep -> project.findProject(dep.getPath()), // getPath() added in Gradle 8.11
15811585
() -> ProjectDependency::getDependencyProject); // removed in Gradle 9
15821586

15831587
visibleConfigurations.forEach(it -> {
@@ -1884,22 +1888,25 @@ interface ExceptionCallable<T, E extends Throwable> {
18841888
private static <T extends Throwable> void sneakyThrow(Throwable exception) throws T {
18851889
throw (T) exception;
18861890
}
1887-
1888-
private <T, E extends Throwable> T sinceGradleOrDefault(String version, ExceptionCallable<T, E> c, Supplier<T> def) {
1891+
1892+
private <T, E extends Throwable> T sinceGradleOrDefault(
1893+
String version, ExceptionCallable<T, E> c, ExceptionCallable<T, E> def) {
1894+
ExceptionCallable<T, E> impl;
18891895
if (GRADLE_VERSION.compareTo(GradleVersion.version(version)) >= 0) {
1890-
try {
1891-
return c.call();
1892-
} catch (RuntimeException | Error e) {
1893-
throw e;
1894-
} catch (Throwable t) {
1895-
sneakyThrow(t);
1896-
return null;
1897-
}
1896+
impl = c;
18981897
} else if (def != null) {
1899-
return def.get();
1898+
impl = def;
19001899
} else {
19011900
return null;
19021901
}
1902+
try {
1903+
return impl.call();
1904+
} catch (RuntimeException | Error e) {
1905+
throw e;
1906+
} catch (Throwable t) {
1907+
sneakyThrow(t);
1908+
return null;
1909+
}
19031910
}
19041911

19051912
private <T, E extends Throwable> T sinceGradle(String version, ExceptionCallable<T, E> c) {

0 commit comments

Comments
 (0)