Skip to content

Commit

Permalink
chore: move minimum required IJ version to 2022.3
Browse files Browse the repository at this point in the history
Signed-off-by: Fred Bricon <[email protected]>
  • Loading branch information
fbricon committed Dec 14, 2023
1 parent 9c783b5 commit dde549a
Show file tree
Hide file tree
Showing 14 changed files with 258 additions and 222 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.2 or more recent (we **try** to support the last 4 major IDEA releases)
* Intellij IDEA 2022.3 or more recent (we **try** to support the last 4 major IDEA releases)
* Java JDK (or JRE) 17 or more recent

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=222
pluginSinceBuild=223
#pluginUntilBuild=233.*
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
platformType=IC
platformVersion=2022.2.3
platformVersion=2022.3
# 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.0.0.44
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ protected void assertContentRootExcludes(String moduleName, String contentRoot,

private void doAssertContentFolders(String moduleName, @NotNull JpsModuleSourceRootType<?> rootType, String... expected) {
final ContentEntry[] contentRoots = getContentRoots(moduleName);
Arrays.sort(contentRoots, Comparator.comparing(ContentEntry::getUrl));
final String rootUrl = contentRoots.length > 1 ? ExternalSystemApiUtil.getExternalProjectPath(getModule(moduleName)) : null;
doAssertContentFolders(rootUrl, contentRoots, rootType, expected);
}
Expand Down Expand Up @@ -424,7 +425,7 @@ protected void ignoreData(Predicate<? super DataNode<?>> booleanFunction, final
for (DataNode<?> node : nodes) {
node.visit(dataNode -> dataNode.setIgnored(ignored));
}
ApplicationManager.getApplication().getService(ProjectDataManager.class).importData(projectDataNode, myProject, true);
ApplicationManager.getApplication().getService(ProjectDataManager.class).importData(projectDataNode, myProject);
}

protected void importProject(@NonNls String config, Boolean skipIndexing) throws IOException {
Expand Down Expand Up @@ -463,7 +464,7 @@ 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, true);
ApplicationManager.getApplication().getService(ProjectDataManager.class).importData(externalProject, myProject);
System.out.println("External project was successfully imported");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.CompilerModuleExtension;
import com.intellij.openapi.roots.OrderEnumerator;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.packaging.artifacts.Artifact;
import com.intellij.packaging.artifacts.ArtifactManager;
import com.intellij.packaging.impl.compiler.ArtifactCompileScope;
import com.intellij.platform.externalSystem.testFramework.ExternalSystemImportingTestCase;
import com.intellij.task.ProjectTaskManager;
import com.intellij.testFramework.CompilerTester;
import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.util.ExceptionUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.io.TestFileSystemItem;
import com.intellij.platform.externalSystem.testFramework.ExternalSystemImportingTestCase;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.concurrency.Promise;

Expand Down Expand Up @@ -134,9 +136,16 @@ protected void assertArtifactOutput(String artifactName, TestFileSystemItem fs)
}

protected void assertModuleOutputs(String moduleName, String... outputs) {
String[] outputPaths = ContainerUtil.map2Array(CompilerPaths.getOutputPaths(new Module[]{getModule(moduleName)}), String.class,
Module module = getModule(moduleName);
String[] outputPaths = ContainerUtil.map2Array(CompilerPaths.getOutputPaths(new Module[]{module}), String.class,
s -> getAbsolutePath(s));
assertUnorderedElementsAreEqual(outputPaths, outputs);
String[] outputPathsFromEnumerator = ContainerUtil.map2Array(
OrderEnumerator.orderEntries(module).withoutSdk().withoutLibraries().withoutDepModules().classes().getUrls(),
String.class,
VfsUtilCore::urlToPath
);
assertUnorderedElementsAreEqual(outputPathsFromEnumerator, outputs);
}

protected void assertModuleOutput(String moduleName, String output, String testOutput) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import com.intellij.openapi.roots.ui.configuration.UnknownSdkResolver;
import com.intellij.openapi.ui.TestDialog;
import com.intellij.openapi.ui.TestDialogManager;
import com.intellij.openapi.util.Couple;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
Expand Down Expand Up @@ -55,7 +57,7 @@
import org.jetbrains.plugins.gradle.settings.GradleSystemSettings;
import org.jetbrains.plugins.gradle.tooling.VersionMatcherRule;
import org.jetbrains.plugins.gradle.util.GradleConstants;
import org.jetbrains.plugins.gradle.util.GradleJvmSupportMatriciesKt;
import org.jetbrains.plugins.gradle.util.GradleJvmSupportMatrices;
import org.jetbrains.plugins.gradle.util.GradleUtil;
import org.junit.Assume;
import org.junit.Rule;
Expand Down Expand Up @@ -100,6 +102,8 @@ public abstract class GradleImportingTestCase extends JavaExternalSystemImportin
private final List<Sdk> removedSdks = new SmartList<>();
private PathAssembler.LocalDistribution myDistribution;

private final Ref<Couple<String>> deprecationError = Ref.create();

@Override
public void setUp() throws Exception {
assumeThat(gradleVersion, versionMatcherRule.getMatcher());
Expand Down Expand Up @@ -183,6 +187,10 @@ protected GradleVersion getCurrentGradleBaseVersion() {
return GradleVersion.version(gradleVersion).getBaseVersion();
}

public @NotNull VirtualFile getProjectRoot() {
return myProjectRoot;
}

protected void assumeTestJavaRuntime(@NotNull JavaVersion javaRuntimeVersion) {
int javaVer = javaRuntimeVersion.feature;
GradleVersion gradleBaseVersion = getCurrentGradleBaseVersion();
Expand Down Expand Up @@ -210,7 +218,7 @@ private static String requireWslJdkHome(@NotNull WSLDistribution distribution) {

public static @NotNull String requireJdkHome(@NotNull GradleVersion gradleVersion) {
JavaVersion javaRuntimeVersion = JavaVersion.current();
if (GradleJvmSupportMatriciesKt.isSupported(gradleVersion, javaRuntimeVersion)) {
if (GradleJvmSupportMatrices.isSupported(gradleVersion, javaRuntimeVersion)) {
return IdeaTestUtil.requireRealJdkHome();
}
// fix exception of FJP at JavaHomeFinder.suggestHomePaths => ... => EnvironmentUtil.getEnvironmentMap => CompletableFuture.<clinit>
Expand All @@ -220,12 +228,12 @@ private static String requireWslJdkHome(@NotNull WSLDistribution distribution) {
if (JdkUtil.checkForJdk(path)) {
JdkVersionDetector.JdkVersionInfo jdkVersionInfo = JdkVersionDetector.getInstance().detectJdkVersionInfo(path);
if (jdkVersionInfo == null) continue;
if (GradleJvmSupportMatriciesKt.isSupported(gradleVersion, jdkVersionInfo.version)) {
if (GradleJvmSupportMatrices.isSupported(gradleVersion, jdkVersionInfo.version)) {
return path;
}
}
}
fail("Cannot find JDK for Gradle, checked paths: " + paths);
fail("Cannot find JDK for Gradle " + gradleVersion.getVersion() + ", checked paths: " + paths);
return null;
}

Expand Down Expand Up @@ -256,6 +264,12 @@ public void tearDown() throws Exception {
TestDialogManager.setTestDialog(TestDialog.DEFAULT);
CompilerTestUtil.deleteBuildSystemDirectory(myProject);
},
() -> {
deprecationError.set(null);
if (isGradleNewerOrSameAs("7.0")) {
GradleSystemSettings.getInstance().setGradleVmOptions("");
}
},
super::tearDown
).run();
}
Expand Down Expand Up @@ -330,10 +344,27 @@ protected void importProjectUsingSingeModulePerGradleProject(@NonNls @Language("
@Override
protected void importProject(@NonNls @Language("Groovy") String config, Boolean skipIndexing) throws IOException {
config = injectRepo(config);
if (isGradleNewerOrSameAs("7.0")) {
GradleSystemSettings.getInstance().setGradleVmOptions("-Dorg.gradle.warning.mode=fail");
}
super.importProject(config, skipIndexing);
handleDeprecationError(deprecationError.get());
}

protected void importProject(@NonNls @Language("Groovy") String config) throws IOException {
protected void handleDeprecationError(Couple<String> errorInfo) {
if (errorInfo == null) return;
handleImportFailure(errorInfo.first, errorInfo.second);
}

@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));
}
super.printOutput(text, stdOut);
}

public void importProject(@NonNls @Language("Groovy") String config) throws IOException {
importProject(config, null);
}

Expand All @@ -342,8 +373,10 @@ protected void importProject(@NonNls @Language("Groovy") String config) throws I
.addPrefix(MAVEN_REPOSITORY_PATCH_PLACE, "");
}

protected @NotNull String script(@NotNull Consumer<TestGradleBuildScriptBuilder> configure) {
return TestGradleBuildScriptBuilder.Companion.buildscript(this, configure);
public @NotNull String script(@NotNull Consumer<TestGradleBuildScriptBuilder> configure) {
var builder = createBuildScriptBuilder();
configure.accept(builder);
return builder.generate();
}

protected @NotNull String getJUnitTestAnnotationClass() {
Expand All @@ -363,13 +396,15 @@ protected ImportSpec createImportSpec() {
@NotNull
protected String injectRepo(@NonNls @Language("Groovy") String config) {
String mavenRepositoryPatch =
"allprojects {\n" +
" repositories {\n" +
" maven {\n" +
" url 'https://repo.labs.intellij.net/repo1'\n" +
" }\n" +
" }\n" +
"}\n";
"""
allprojects {
repositories {
maven {
url 'https://repo.labs.intellij.net/repo1'
}
}
}
""";
if (config.contains(MAVEN_REPOSITORY_PATCH_PLACE)) {
return config.replace(MAVEN_REPOSITORY_PATCH_PLACE, mavenRepositoryPatch);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ open class TestGradleBuildScriptBuilder(
}
}

override fun generate(): String {
if (this !is TestGradleBuildScriptChildBuilder) {
// Needed to identify how was created test script
code("// $LICENCE")
}
return super.generate()
}

private inner class TestGradleBuildScriptChildBuilder : TestGradleBuildScriptBuilder(gradleVersion) {

override fun withJavaPlugin() =
Expand All @@ -162,24 +170,12 @@ open class TestGradleBuildScriptBuilder(
}

companion object {
const val LICENCE = "Build script is generated by TestGradleBuildScriptBuilder"

const val IDEA_EXT_PLUGIN_VERSION = "1.1.3"

@JvmStatic
fun extPluginVersionIsAtLeast(version: String) =
Version.parseVersion(IDEA_EXT_PLUGIN_VERSION)!! >= Version.parseVersion(version)!!

@JvmStatic
fun buildscript(gradleVersion: GradleVersion, configure: Consumer<TestGradleBuildScriptBuilder>) =
buildscript(gradleVersion, configure::accept)

fun buildscript(gradleVersion: GradleVersion, configure: TestGradleBuildScriptBuilder.() -> Unit) =
TestGradleBuildScriptBuilder(gradleVersion).apply(configure).generate()

@JvmStatic
fun GradleImportingTestCase.buildscript(configure: Consumer<TestGradleBuildScriptBuilder>) =
buildscript(configure::accept)

fun GradleImportingTestCase.buildscript(configure: TestGradleBuildScriptBuilder.() -> Unit) =
createBuildScriptBuilder().apply(configure).generate()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,31 @@
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.gradle.tooling.annotation.TargetVersions;
import org.jetbrains.plugins.gradle.tooling.util.VersionMatcher;
import org.jetbrains.plugins.gradle.util.GradleJvmSupportMatrices;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;

/**
* @author Vladislav.Soroka
*/
import java.util.Arrays;

public class VersionMatcherRule extends TestWatcher {

/**
* !When adding new versions here change also list in Idea_Tests_BuildToolsTests in Intellij Teamcity configuration
* Note: When adding new versions here change also lists:<br/>
* - Idea_Tests_BuildToolsTests<br/>
* - Intellij Teamcity configuration<br/>
* - {@link VersionMatcherRule#BASE_GRADLE_VERSION}<br/>
* - {@link GradleJvmSupportMatrices#SUPPORTED_JAVA_VERSIONS}<br/>
* - {@link GradleJvmSupportMatrices#SUPPORTED_GRADLE_VERSIONS}<br/>
* - {@link GradleJvmSupportMatrices#COMPATIBILITY}
*/
public static final Object[][] SUPPORTED_GRADLE_VERSIONS = {
public static final String[][] SUPPORTED_GRADLE_VERSIONS = {
{"3.0"}, /*{"3.1"}, {"3.2"}, {"3.3"}, {"3.4"},*/ {"3.5"},
{"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.0.2"}, /* {"7.1"}, {"7.2"}, */ {"7.4"}, {"7.5.1"}
};
public static final String BASE_GRADLE_VERSION = String.valueOf(SUPPORTED_GRADLE_VERSIONS[SUPPORTED_GRADLE_VERSIONS.length - 1][0]);
public static final String BASE_GRADLE_VERSION = "7.5.1";

@Nullable
private CustomMatcher<String> myMatcher;
Expand All @@ -56,7 +62,7 @@ protected void starting(Description d) {
final TargetVersions targetVersions = d.getAnnotation(TargetVersions.class);
if (targetVersions == null) return;

myMatcher = new CustomMatcher<String>("Gradle version '" + targetVersions.value() + "'") {
myMatcher = new CustomMatcher<String>("Gradle version '" + Arrays.toString(targetVersions.value()) + "'") {
@Override
public boolean matches(Object item) {
return item instanceof String && new VersionMatcher(GradleVersion.version(item.toString())).isVersionMatch(targetVersions);
Expand Down
Loading

0 comments on commit dde549a

Please sign in to comment.