Skip to content

Commit

Permalink
build: update 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 Jan 31, 2024
1 parent 58be88b commit f54fa9e
Show file tree
Hide file tree
Showing 23 changed files with 342 additions and 278 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
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ 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.1.0.52
# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion=8.4
gradleVersion=8.5
channel=nightly
quarkusVersion=3.1.2.Final
lsp4mpVersion=0.10.0
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
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 @@ -362,14 +395,16 @@ 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";
String mavenRepositoryPatch = // language=groovy
"""
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()
}
}
Loading

0 comments on commit f54fa9e

Please sign in to comment.