From fba0c302c4c9e847fcd1feb587fbc362e2b4fde7 Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Wed, 8 May 2024 19:50:11 +0200 Subject: [PATCH] Temporarily downgrade gradle module language level - resolves a "Project Problems" regression - temporary until proper fix is implemented --- extide/gradle/nbproject/project.properties | 4 +- .../newproject/GradleInitPanelVisual.java | 4 +- .../gradle/output/GradleProcessorFactory.java | 23 ++++++----- .../spi/newproject/GradleInitWizard.java | 38 ++++++++++--------- .../spi/newproject/TemplateOperation.java | 7 ++-- 5 files changed, 42 insertions(+), 34 deletions(-) diff --git a/extide/gradle/nbproject/project.properties b/extide/gradle/nbproject/project.properties index 8666db6808cf..aa352d0d3fd9 100644 --- a/extide/gradle/nbproject/project.properties +++ b/extide/gradle/nbproject/project.properties @@ -17,8 +17,8 @@ file.reference.netbeans-gradle-tooling.jar=release/modules/gradle/netbeans-gradle-tooling.jar is.autoload=true -javac.source=17 -javac.target=17 +javac.source=1.8 +javac.target=1.8 javac.compilerargs=-Xlint -Xlint:-serial javadoc.arch=${basedir}/arch.xml javadoc.apichanges=${basedir}/apichanges.xml diff --git a/extide/gradle/src/org/netbeans/modules/gradle/newproject/GradleInitPanelVisual.java b/extide/gradle/src/org/netbeans/modules/gradle/newproject/GradleInitPanelVisual.java index af9a859de853..61e9a964a11b 100644 --- a/extide/gradle/src/org/netbeans/modules/gradle/newproject/GradleInitPanelVisual.java +++ b/extide/gradle/src/org/netbeans/modules/gradle/newproject/GradleInitPanelVisual.java @@ -228,7 +228,7 @@ void read(WizardDescriptor settings) { if (settings.getProperty(PROP_JAVA_VERSIONS) != null) { List javaVersions = (List) settings.getProperty(PROP_JAVA_VERSIONS); - DefaultComboBoxModel versionModel = new DefaultComboBoxModel<>(javaVersions.toArray(Integer[]::new)); + DefaultComboBoxModel versionModel = new DefaultComboBoxModel<>(javaVersions.toArray(new Integer[0])); cbJavaVersion.setModel(versionModel); if (settings.getProperty(PROP_JAVA_VERSION) != null) { @@ -241,7 +241,7 @@ void read(WizardDescriptor settings) { if (settings.getProperty(PROP_TEST_FRAMEWORKS) != null) { List testframeworks = (List) settings.getProperty(PROP_TEST_FRAMEWORKS); - DefaultComboBoxModel frameworkModel = new DefaultComboBoxModel<>(testframeworks.toArray(TestFramework[]::new)); + DefaultComboBoxModel frameworkModel = new DefaultComboBoxModel<>(testframeworks.toArray(new TestFramework[0])); cbTestFramework.setModel(frameworkModel); if (settings.getProperty(PROP_TEST_FRAMEWORK) != null) { cbTestFramework.setSelectedItem(settings.getProperty(PROP_TEST_FRAMEWORK)); diff --git a/extide/gradle/src/org/netbeans/modules/gradle/output/GradleProcessorFactory.java b/extide/gradle/src/org/netbeans/modules/gradle/output/GradleProcessorFactory.java index 7231c382bd6c..fd528f433bbb 100644 --- a/extide/gradle/src/org/netbeans/modules/gradle/output/GradleProcessorFactory.java +++ b/extide/gradle/src/org/netbeans/modules/gradle/output/GradleProcessorFactory.java @@ -33,6 +33,9 @@ import java.io.File; import java.net.MalformedURLException; import java.net.URL; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -56,18 +59,18 @@ public class GradleProcessorFactory implements OutputProcessorFactory { @Override public Set createOutputProcessors(RunConfig cfg) { - return Set.of( + return Collections.unmodifiableSet(new HashSet<>(Arrays.asList( GRADLE_PROCESSOR, JAVAC_PROCESSOR, GROOVYC_PROCESSOR, new WarningModeAllProcessor(cfg) - ); + ))); } + private static final Pattern GRADLE_ERROR = Pattern.compile("(Build file|Script) '(.*)\\.gradle' line: ([0-9]+)"); public static final OutputProcessor GRADLE_PROCESSOR = new OutputProcessor() { - private static final Pattern GRADLE_ERROR = Pattern.compile("(Build file|Script) '(.*)\\.gradle' line: ([0-9]+)"); @Override public boolean processLine(OutputDisplayer out, String line) { @@ -90,9 +93,9 @@ public boolean processLine(OutputDisplayer out, String line) { } }; - public static final OutputProcessor JAVAC_PROCESSOR = new OutputProcessor() { + private static final Pattern JAVA_ERROR = Pattern.compile("(.*)\\.java\\:([0-9]+)\\: (error|warning)\\:(.*)"); - private static final Pattern JAVA_ERROR = Pattern.compile("(.*)\\.java\\:([0-9]+)\\: (error|warning)\\:(.*)"); + public static final OutputProcessor JAVAC_PROCESSOR = new OutputProcessor() { @Override public boolean processLine(OutputDisplayer out, String line) { @@ -118,10 +121,10 @@ public boolean processLine(OutputDisplayer out, String line) { } }; - public static final OutputProcessor GROOVYC_PROCESSOR = new OutputProcessor() { + private static final Pattern GROOVY_ERROR = Pattern.compile("(.*)\\.groovy\\: ([0-9]+)\\: (.+)"); + private static final Pattern COLUMN_INFO = Pattern.compile(" @ line ([0-9]+), column ([0-9]+)\\.$"); - private static final Pattern GROOVY_ERROR = Pattern.compile("(.*)\\.groovy\\: ([0-9]+)\\: (.+)"); - private static final Pattern COLUMN_INFO = Pattern.compile(" @ line ([0-9]+), column ([0-9]+)\\.$"); + public static final OutputProcessor GROOVYC_PROCESSOR = new OutputProcessor() { @Override public boolean processLine(OutputDisplayer out, String line) { @@ -156,9 +159,9 @@ public boolean processLine(OutputDisplayer out, String line) { }; - public static final OutputProcessor URL_PROCESSOR = new OutputProcessor() { + private static final Pattern URL_PATTERN = Pattern.compile("(((https?|ftp|file)://|file:/)[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|])"); - private static final Pattern URL_PATTERN = Pattern.compile("(((https?|ftp|file)://|file:/)[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|])"); + public static final OutputProcessor URL_PROCESSOR = new OutputProcessor() { @Override public boolean processLine(OutputDisplayer out, String line) { diff --git a/extide/gradle/src/org/netbeans/modules/gradle/spi/newproject/GradleInitWizard.java b/extide/gradle/src/org/netbeans/modules/gradle/spi/newproject/GradleInitWizard.java index 981278ce2b31..56fdfe17e459 100644 --- a/extide/gradle/src/org/netbeans/modules/gradle/spi/newproject/GradleInitWizard.java +++ b/extide/gradle/src/org/netbeans/modules/gradle/spi/newproject/GradleInitWizard.java @@ -19,8 +19,10 @@ package org.netbeans.modules.gradle.spi.newproject; import java.io.File; +import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import org.netbeans.modules.gradle.newproject.GradleInitPanel; import org.netbeans.spi.project.ui.support.CommonProjectActions; import org.openide.WizardDescriptor; @@ -49,10 +51,11 @@ public enum GradleDSL { @Override public String toString() { - return switch(this) { - case GROOVY -> Bundle.LBL_DSL_GROOVY(); - case KOTLIN -> Bundle.LBL_DSL_KOTLIN(); - }; + switch(this) { + case GROOVY: return Bundle.LBL_DSL_GROOVY(); + case KOTLIN: return Bundle.LBL_DSL_KOTLIN(); + default: throw new IllegalStateException("update switch"); + } } } @@ -88,16 +91,17 @@ public String getId() { @Override public String toString() { - return switch(this) { - case CPP_TEST -> Bundle.LBL_TFW_CPP_TEST(); - case JUNIT -> Bundle.LBL_TFW_JUNIT(); - case JUNIT_5 -> Bundle.LBL_TFW_JUNIT_5(); - case KOTLIN_TEST -> Bundle.LBL_TFW_KOTLIN_TEST(); - case SCALA_TEST -> Bundle.LBL_TFW_SCALA_TEST(); - case SPOCK -> Bundle.LBL_TFW_SPOCK(); - case TESTNG -> Bundle.LBL_TFW_TESTNG(); - case XCTEST -> Bundle.LBL_TFW_XCTEST(); - }; + switch(this) { + case CPP_TEST: return Bundle.LBL_TFW_CPP_TEST(); + case JUNIT: return Bundle.LBL_TFW_JUNIT(); + case JUNIT_5: return Bundle.LBL_TFW_JUNIT_5(); + case KOTLIN_TEST: return Bundle.LBL_TFW_KOTLIN_TEST(); + case SCALA_TEST: return Bundle.LBL_TFW_SCALA_TEST(); + case SPOCK: return Bundle.LBL_TFW_SPOCK(); + case TESTNG: return Bundle.LBL_TFW_TESTNG(); + case XCTEST: return Bundle.LBL_TFW_XCTEST(); + default: throw new IllegalStateException("update switch"); + } } } @@ -108,7 +112,7 @@ public String toString() { private TestFramework preferredTestFramework; private List javaVersions; private List testFrameworks; - private List important = List.of(); + private List important = Collections.emptyList(); private GradleInitWizard(String type, String title) { this.type = type; @@ -211,14 +215,14 @@ protected void collectOperations(TemplateOperation ops, Map para List open = important.stream() .map((s) -> packageBase != null ? s.replace("${package}", packageBase.replace('.', '/')) : s) //NOI18N .map((s) -> s.replace("${projectName}", name)) //NOI18N - .toList(); + .collect(Collectors.toList()); ops.addProjectPreload(root, open); } @Override protected List> createPanels() { - return List.of(new GradleInitPanel()); + return Collections.singletonList(new GradleInitPanel()); } @Override diff --git a/extide/gradle/src/org/netbeans/modules/gradle/spi/newproject/TemplateOperation.java b/extide/gradle/src/org/netbeans/modules/gradle/spi/newproject/TemplateOperation.java index 9697aa92c481..8eeadadc7121 100644 --- a/extide/gradle/src/org/netbeans/modules/gradle/spi/newproject/TemplateOperation.java +++ b/extide/gradle/src/org/netbeans/modules/gradle/spi/newproject/TemplateOperation.java @@ -23,6 +23,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStreamReader; +import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Reader; import java.io.Writer; @@ -353,8 +354,8 @@ public Set execute() { args.add("--use-defaults"); try ( - var out = new EscapeProcessingOutputStream(new GradlePlainEscapeProcessor(io, false)); - var err = new EscapeProcessingOutputStream(new GradlePlainEscapeProcessor(io, false)) + OutputStream out = new EscapeProcessingOutputStream(new GradlePlainEscapeProcessor(io, false)); + OutputStream err = new EscapeProcessingOutputStream(new GradlePlainEscapeProcessor(io, false)) ) { BuildLauncher gradleInit = pconn.newBuild().forTasks(args.toArray(new String[0])); if (GradleSettings.getDefault().isOffline()) { @@ -488,7 +489,7 @@ private static final class PreloadProject extends BaseOperationStep { final List importantFiles; public PreloadProject(File dir) { - this(dir, List.of()); + this(dir, Collections.emptyList()); } public PreloadProject(File dir, List importantFiles) {