Skip to content

Commit

Permalink
build: update minimum required IJ version to 2023.1
Browse files Browse the repository at this point in the history
Signed-off-by: Fred Bricon <[email protected]>
  • Loading branch information
fbricon authored and angelozerr committed Mar 21, 2024
1 parent 0889e65 commit 03585c3
Show file tree
Hide file tree
Showing 37 changed files with 161 additions and 73 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ When editing `application.properties` files, you have access to:

## Requirements

* Intellij IDEA 2022.3 or more recent (we **try** to support the last 4 major IDEA releases)
* Intellij IDEA 2023.1 or more recent (we **try** to support the last 4 major IDEA releases)
* Java JDK (or JRE) 17 or more recent

Expand Down
9 changes: 9 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ dependencies {
})

testImplementation("com.redhat.devtools.intellij:intellij-common-ui-test-library:0.2.0")

// And now for some serious HACK!!!
// Starting with 2023.1, all gradle tests fail importing projects with a:
// com.intellij.openapi.externalSystem.model.ExternalSystemException: Unable to load class 'org.codehaus.plexus.logging.Logger'
// Hence adding a jar containing the missing class, to the test classpath
// The version matches the jar found in the IJ version used to compile the project
// This is so wrong/ridiculous!
testImplementation("org.eclipse.sisu:org.eclipse.sisu.plexus:0.3.4")

testImplementation("org.assertj:assertj-core:3.19.0")
}

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ pluginRepositoryUrl=https://github.com/redhat-developer/intellij-quarkus
# NO SPACES AROUND THE EQUALS SIGN!!
pluginVersion=1.30.1-SNAPSHOT
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild=223
pluginSinceBuild=231
#pluginUntilBuild=233.*
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
platformType=IC
platformVersion=2022.3
platformVersion=2023.1
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformPlugins=com.intellij.java, maven, gradle-java, properties, yaml, com.redhat.devtools.intellij.telemetry:1.1.0.52
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.psi.PsiElement;
import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.testFramework.utils.module.ModuleAssertions;
import com.intellij.usageView.UsageInfo;
import com.intellij.util.CommonProcessors;
import com.intellij.util.containers.ContainerUtil;
import org.assertj.core.api.Assertions;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -80,19 +80,8 @@ protected void assertModulesContains(String... expectedNames) {
assertModulesContains(myProject, expectedNames);
}

public static void assertModules(@NotNull Project project, String... expectedNames) {
Module[] actual = ModuleManager.getInstance(project).getModules();
List<String> actualNames = new ArrayList<>();

for (Module m : actual) {
actualNames.add(m.getName());
}

Assertions.assertThat(actualNames).containsExactlyInAnyOrder(expectedNames);
}

protected void assertModules(String... expectedNames) {
assertModules(myProject, expectedNames);
ModuleAssertions.assertModules(myProject, expectedNames);
}

protected void assertContentRoots(String moduleName, String... expectedRoots) {
Expand Down Expand Up @@ -464,7 +453,12 @@ public void onSuccess(@Nullable final DataNode<ProjectData> externalProject) {
System.err.println("Got null External project after import");
return;
}
ApplicationManager.getApplication().getService(ProjectDataManager.class).importData(externalProject, myProject);
try {
ApplicationManager.getApplication().getService(ProjectDataManager.class).importData(externalProject, myProject);
} catch (Throwable ex) {
ex.printStackTrace(System.err);
error.set(Couple.of("Exception occurred in `ProjectDataManager.importData` (see output for the details)", null));
}
System.out.println("External project was successfully imported");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.platform.testFramework.io.ExternalResourcesChecker;
import com.intellij.testFramework.ExtensionTestUtil;
import com.intellij.testFramework.IdeaTestUtil;
import com.intellij.testFramework.RunAll;
Expand All @@ -47,6 +48,7 @@
import org.intellij.lang.annotations.Language;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.java.JdkVersionDetector;
import org.jetbrains.plugins.gradle.frameworkSupport.buildscript.GradleBuildScriptBuilderUtil;
import org.jetbrains.plugins.gradle.service.execution.GradleExternalTaskConfigurationType;
Expand All @@ -73,10 +75,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Properties;
import java.util.*;
import java.util.function.Consumer;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
Expand All @@ -88,7 +87,7 @@
@RunWith(Parameterized.class)
public abstract class GradleImportingTestCase extends JavaExternalSystemImportingTestCase {
public static final String BASE_GRADLE_VERSION = VersionMatcherRule.BASE_GRADLE_VERSION;
protected static final String GRADLE_JDK_NAME = "Gradle JDK";
public static final String GRADLE_JDK_NAME = "Gradle JDK";
private static final int GRADLE_DAEMON_TTL_MS = 10000;

@Rule public TestName name = new TestName();
Expand All @@ -103,6 +102,8 @@ public abstract class GradleImportingTestCase extends JavaExternalSystemImportin
private PathAssembler.LocalDistribution myDistribution;

private final Ref<Couple<String>> deprecationError = Ref.create();
private final StringBuilder deprecationTextBuilder = new StringBuilder();
private int deprecationTextLineCount = 0;

@Override
public void setUp() throws Exception {
Expand All @@ -111,7 +112,7 @@ public void setUp() throws Exception {

super.setUp();

WriteAction.runAndWait(this::configureJDKTable);
WriteAction.runAndWait(this::configureJdkTable);
System.setProperty(ExternalSystemExecutionSettings.REMOTE_PROCESS_IDLE_TTL_IN_MS_KEY, String.valueOf(GRADLE_DAEMON_TTL_MS));

ExtensionTestUtil.maskExtensions(UnknownSdkResolver.EP_NAME, List.of(TestUnknownSdkResolver.INSTANCE), getTestRootDisposable());
Expand All @@ -121,19 +122,34 @@ public void setUp() throws Exception {
cleanScriptsCacheIfNeeded();
}

private void configureJDKTable() throws Exception {
protected void configureJdkTable() {
cleanJdkTable();
ArrayList<Sdk> jdks = new ArrayList<>(Arrays.asList(createJdkFromJavaHome()));
populateJdkTable(jdks);
}

protected void cleanJdkTable() {
removedSdks.clear();
for (Sdk sdk : ProjectJdkTable.getInstance().getAllJdks()) {
ProjectJdkTable.getInstance().removeJdk(sdk);
if (GRADLE_JDK_NAME.equals(sdk.getName())) continue;
removedSdks.add(sdk);
}
}

protected void populateJdkTable(@NotNull List<Sdk> jdks) {
for (Sdk jdk : jdks) {
ProjectJdkTable.getInstance().addJdk(jdk);
}
}

private Sdk createJdkFromJavaHome() {
VirtualFile jdkHomeDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(myJdkHome));
JavaSdk javaSdk = JavaSdk.getInstance();
SdkType javaSdkType = javaSdk == null ? SimpleJavaSdkType.getInstance() : javaSdk;
Sdk jdk = SdkConfigurationUtil.setupSdk(new Sdk[0], jdkHomeDir, javaSdkType, true, null, GRADLE_JDK_NAME);
assertNotNull("Cannot create JDK for " + myJdkHome, jdk);
ProjectJdkTable.getInstance().addJdk(jdk);
return jdk;
}

@Override
Expand Down Expand Up @@ -359,11 +375,28 @@ protected void handleDeprecationError(Couple<String> errorInfo) {
@Override
protected void printOutput(@NotNull String text, boolean stdOut) {
if (text.contains("This is scheduled to be removed in Gradle")) {
deprecationError.set(Couple.of("Deprecation warning from Gradle", text));
deprecationTextLineCount = 15;
}
if (deprecationTextLineCount > 0) {
deprecationTextBuilder.append(text);
deprecationTextLineCount--;
if (deprecationTextLineCount == 0) {
deprecationError.set(Couple.of("Deprecation warning from Gradle", deprecationTextBuilder.toString()));
deprecationTextBuilder.setLength(0);
}
}
super.printOutput(text, stdOut);
}

@Override
protected void handleImportFailure(@NotNull String errorMessage, @Nullable String errorDetails) {
var combinedMessage = errorMessage + "\n" + errorDetails;
if (combinedMessage.contains("org.gradle.wrapper.Download.download") && combinedMessage.contains("java.net.SocketException")) {
ExternalResourcesChecker.reportUnavailability("Gradle distribution service", null);
}
super.handleImportFailure(errorMessage, errorDetails);
}

public void importProject(@NonNls @Language("Groovy") String config) throws IOException {
importProject(config, null);
}
Expand Down Expand Up @@ -395,7 +428,7 @@ protected ImportSpec createImportSpec() {

@NotNull
protected String injectRepo(@NonNls @Language("Groovy") String config) {
String mavenRepositoryPatch = // language=groovy
String mavenRepositoryPatch =
"""
allprojects {
repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ open class TestGradleBuildScriptBuilder(

override fun apply(action: TestGradleBuildScriptBuilder.() -> Unit) = applyKt(action)

fun applyPlugin(plugin: String) =
withPrefix { call("apply", argument("plugin", code(plugin))) }

fun withTask(name: String) = withTask(name, null)
fun withTask(name: String, type: String?) = withTask(name, type, null)
fun withTask(name: String, type: String?, dependsOn: String?) = withTask(name, type, dependsOn) {}
Expand Down Expand Up @@ -109,7 +106,7 @@ open class TestGradleBuildScriptBuilder(
addBuildScriptClasspath(jarFile)
addBuildScriptClasspath("com.google.code.gson:gson:2.8.2")
addBuildScriptClasspath("com.google.guava:guava:25.1-jre")
applyPlugin("'org.jetbrains.gradle.plugin.idea-ext'")
applyPlugin("org.jetbrains.gradle.plugin.idea-ext")
}

override fun withBuildScriptMavenCentral() =
Expand Down Expand Up @@ -157,16 +154,16 @@ open class TestGradleBuildScriptBuilder(
private inner class TestGradleBuildScriptChildBuilder : TestGradleBuildScriptBuilder(gradleVersion) {

override fun withJavaPlugin() =
applyPlugin("'java'")
applyPlugin("java")

override fun withJavaLibraryPlugin() =
if (isSupportedJavaLibraryPlugin(gradleVersion))
applyPlugin("'java-library'")
applyPlugin("java-library")
else
applyPlugin("'java'")
applyPlugin("java")

override fun withIdeaPlugin() =
applyPlugin("'idea'")
applyPlugin("idea")
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ public class VersionMatcherRule extends TestWatcher {
{"4.0"}, /*{"4.1"}, {"4.2"}, {"4.3"}, {"4.4"}, {"4.5.1"}, {"4.6"}, {"4.7"}, {"4.8"}, {"4.9"},*/ {"4.10.3"},
{"5.0"}, /*{"5.1"}, {"5.2"}, {"5.3.1"}, {"5.4.1"}, {"5.5.1"},*/ {"5.6.2"},
{"6.0"}, /* {"6.0.1"}, {"6.1"}, {"6.2"}, {"6.3"}, {"6.4"}, {"6.8.3"}, */ {"6.9"},
{"7.0.2"}, /* {"7.1"}, {"7.2"}, */ {"7.4"}, {"7.5.1"}
{"7.0.2"}, /* {"7.1"}, {"7.2"}, {"7.4"}, {"7.5.1"}, */ {"7.6"},
{"8.0"}
};
public static final String BASE_GRADLE_VERSION = "7.5.1";
public static final String BASE_GRADLE_VERSION = "8.0";

@Nullable
private CustomMatcher<String> myMatcher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static com.intellij.util.containers.ContainerUtil.set;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assume.assumeThat;
Expand Down Expand Up @@ -150,7 +149,7 @@ public void setUp() throws Exception {
boolean isCompositeBuildsSupported = _gradleVersion.compareTo(GradleVersion.version("3.1")) >= 0;
final ProjectImportAction projectImportAction = new ProjectImportAction(false, isCompositeBuildsSupported);
projectImportAction.addProjectImportModelProvider(new ClassSetImportModelProvider(getModels(),
ContainerUtil.<Class<?>>set(IdeaProject.class)));
Collections.<Class<?>>singleton(IdeaProject.class)));
BuildActionExecuter<ProjectImportAction.AllModels> buildActionExecutor = connection.action(projectImportAction);
GradleExecutionSettings executionSettings = new GradleExecutionSettings(null, null, DistributionType.BUNDLED, false);
GradleExecutionHelper.attachTargetPathMapperInitScript(executionSettings);
Expand Down Expand Up @@ -184,7 +183,7 @@ public boolean matches(Object item) {

@NotNull
public static Set<Class<?>> getToolingExtensionClasses() {
return set(
return ContainerUtil.set(
// external-system-rt.jar
ExternalSystemSourceType.class,
// gradle-tooling-extension-api jar
Expand Down
Loading

0 comments on commit 03585c3

Please sign in to comment.