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

Temporarily downgrade gradle module language level #7367

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions extide/gradle/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void read(WizardDescriptor settings) {

if (settings.getProperty(PROP_JAVA_VERSIONS) != null) {
List<Integer> javaVersions = (List<Integer>) settings.getProperty(PROP_JAVA_VERSIONS);
DefaultComboBoxModel<Integer> versionModel = new DefaultComboBoxModel<>(javaVersions.toArray(Integer[]::new));
DefaultComboBoxModel<Integer> versionModel = new DefaultComboBoxModel<>(javaVersions.toArray(new Integer[0]));
cbJavaVersion.setModel(versionModel);

if (settings.getProperty(PROP_JAVA_VERSION) != null) {
Expand All @@ -241,7 +241,7 @@ void read(WizardDescriptor settings) {

if (settings.getProperty(PROP_TEST_FRAMEWORKS) != null) {
List<TestFramework> testframeworks = (List<TestFramework>) settings.getProperty(PROP_TEST_FRAMEWORKS);
DefaultComboBoxModel<TestFramework> frameworkModel = new DefaultComboBoxModel<>(testframeworks.toArray(TestFramework[]::new));
DefaultComboBoxModel<TestFramework> 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -56,18 +59,18 @@ public class GradleProcessorFactory implements OutputProcessorFactory {

@Override
public Set<? extends OutputProcessor> 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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not throw from toString - if this is user visible the name might look strange, but still conveys the meaning.

Suggested change
default: throw new IllegalStateException("update switch");
default: return name();

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah but I am sure @lkishalmi will fix this properly during NB 23, so we can't really arrive at a situation where enums are added (which are btw a few lines above the toString()) without anyone noticing it.

}
}
}

Expand Down Expand Up @@ -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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
default: throw new IllegalStateException("update switch");
default: return name();

}
}
}

Expand All @@ -108,7 +112,7 @@ public String toString() {
private TestFramework preferredTestFramework;
private List<Integer> javaVersions;
private List<TestFramework> testFrameworks;
private List<String> important = List.of();
private List<String> important = Collections.emptyList();

private GradleInitWizard(String type, String title) {
this.type = type;
Expand Down Expand Up @@ -211,14 +215,14 @@ protected void collectOperations(TemplateOperation ops, Map<String, Object> para
List<String> 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<? extends WizardDescriptor.Panel<WizardDescriptor>> createPanels() {
return List.of(new GradleInitPanel());
return Collections.singletonList(new GradleInitPanel());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -353,8 +354,8 @@ public Set<FileObject> 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()) {
Expand Down Expand Up @@ -488,7 +489,7 @@ private static final class PreloadProject extends BaseOperationStep {
final List<String> importantFiles;

public PreloadProject(File dir) {
this(dir, List.of());
this(dir, Collections.emptyList());
}

public PreloadProject(File dir, List<String> importantFiles) {
Expand Down