diff --git a/README.md b/README.md index 018120415..949b7b80b 100644 --- a/README.md +++ b/README.md @@ -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 ​ diff --git a/gradle.properties b/gradle.properties index 4230ef583..ee4efcb9e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/intellij-community/platform/external-system-api/testFramework/src/com/intellij/platform/externalSystem/testFramework/ExternalSystemImportingTestCase.java b/intellij-community/platform/external-system-api/testFramework/src/com/intellij/platform/externalSystem/testFramework/ExternalSystemImportingTestCase.java index a8e6e6740..7ba9c8294 100644 --- a/intellij-community/platform/external-system-api/testFramework/src/com/intellij/platform/externalSystem/testFramework/ExternalSystemImportingTestCase.java +++ b/intellij-community/platform/external-system-api/testFramework/src/com/intellij/platform/externalSystem/testFramework/ExternalSystemImportingTestCase.java @@ -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); } @@ -424,7 +425,7 @@ protected void ignoreData(Predicate> 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 { @@ -463,7 +464,7 @@ public void onSuccess(@Nullable final DataNode 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"); } diff --git a/intellij-community/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/JavaExternalSystemImportingTestCase.java b/intellij-community/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/JavaExternalSystemImportingTestCase.java index bb1ceb8c4..8353864dc 100644 --- a/intellij-community/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/JavaExternalSystemImportingTestCase.java +++ b/intellij-community/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/JavaExternalSystemImportingTestCase.java @@ -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; @@ -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) { diff --git a/intellij-community/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleJvmSupportMatricies.kt b/intellij-community/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleJvmSupportMatricies.kt deleted file mode 100644 index 08698288e..000000000 --- a/intellij-community/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleJvmSupportMatricies.kt +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -package org.jetbrains.plugins.gradle.util - -import com.intellij.util.lang.JavaVersion -import org.gradle.util.GradleVersion - -const val MINIMUM_SUPPORTED_JAVA = 7 -const val MAXIMUM_SUPPORTED_JAVA = 16 - -fun isSupported(gradleVersion: GradleVersion, javaVersion: JavaVersion): Boolean { - val baseVersion = gradleVersion.baseVersion - val featureVersion = javaVersion.feature - return when { - // Gradle 7.2 and java 17 are partially compatible - // https://github.com/gradle/gradle/issues/16857 - baseVersion >= GradleVersion.version("7.2") -> featureVersion in 8..17 - // https://docs.gradle.org/7.0/release-notes.html#java-16 - baseVersion >= GradleVersion.version("7.0") -> featureVersion in 8..16 - // https://docs.gradle.org/6.7/release-notes.html#java-15 - baseVersion >= GradleVersion.version("6.7") -> featureVersion in 8..15 - // many builds might work with Java 15 but there are some known issues https://github.com/gradle/gradle/issues/13532 - baseVersion >= GradleVersion.version("6.3") -> featureVersion in 8..14 - baseVersion >= GradleVersion.version("6.0") -> featureVersion in 8..13 - baseVersion >= GradleVersion.version("5.4.1") -> featureVersion in 8..12 - baseVersion >= GradleVersion.version("5.0") -> featureVersion in 8..11 - baseVersion >= GradleVersion.version("4.1") -> featureVersion in 7..9 - baseVersion >= GradleVersion.version("4.0") -> featureVersion in 7..8 - else -> featureVersion in 7..8 - } -} - -fun suggestGradleVersion(javaVersion: JavaVersion): GradleVersion? { - val featureVersion = javaVersion.feature - return when { - isSupported(GradleVersion.current(), javaVersion) -> GradleVersion.current() - featureVersion in 8..17 -> GradleVersion.version("7.2") - // https://docs.gradle.org/5.0/release-notes.html#potential-breaking-changes - featureVersion == 7 -> GradleVersion.version("4.10.3") - else -> null - } -} - -fun suggestJavaVersion(gradleVersion: GradleVersion): JavaVersion { - val baseVersion = gradleVersion.baseVersion - return when { - baseVersion >= GradleVersion.version("7.2") -> JavaVersion.compose(17) - baseVersion >= GradleVersion.version("7.0") -> JavaVersion.compose(16) - baseVersion >= GradleVersion.version("6.7") -> JavaVersion.compose(15) - baseVersion >= GradleVersion.version("6.3") -> JavaVersion.compose(14) - baseVersion >= GradleVersion.version("6.0") -> JavaVersion.compose(13) - baseVersion >= GradleVersion.version("5.4.1") -> JavaVersion.compose(12) - baseVersion >= GradleVersion.version("5.0") -> JavaVersion.compose(11) - baseVersion >= GradleVersion.version("4.1") -> JavaVersion.compose(9) - else -> JavaVersion.compose(8) - } -} - -fun suggestOldestCompatibleGradleVersion(javaVersion: JavaVersion): GradleVersion? { - val featureVersion = javaVersion.feature - return when { - featureVersion >= 17 -> GradleVersion.version("7.2") - featureVersion >= 16 -> GradleVersion.version("7.0") - featureVersion >= 15 -> GradleVersion.version("6.7") - featureVersion >= 14 -> GradleVersion.version("6.3") - featureVersion >= 13 -> GradleVersion.version("6.0") - featureVersion >= 12 -> GradleVersion.version("5.4.1") - featureVersion >= 11 -> GradleVersion.version("4.8") - featureVersion >= 7 -> GradleVersion.version("3.0") - else -> null - } -} - -fun suggestOldestCompatibleJavaVersion(gradleVersion: GradleVersion): JavaVersion { - val baseVersion = gradleVersion.baseVersion - return when { - baseVersion >= GradleVersion.version("5.0") -> JavaVersion.compose(8) - else -> JavaVersion.compose(7) - } -} diff --git a/intellij-community/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleImportingTestCase.java b/intellij-community/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleImportingTestCase.java index e8c4e8a79..ee9ea362d 100644 --- a/intellij-community/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleImportingTestCase.java +++ b/intellij-community/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleImportingTestCase.java @@ -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; @@ -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; @@ -100,6 +102,8 @@ public abstract class GradleImportingTestCase extends JavaExternalSystemImportin private final List removedSdks = new SmartList<>(); private PathAssembler.LocalDistribution myDistribution; + private final Ref> deprecationError = Ref.create(); + @Override public void setUp() throws Exception { assumeThat(gradleVersion, versionMatcherRule.getMatcher()); @@ -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(); @@ -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. @@ -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; } @@ -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(); } @@ -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 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); } @@ -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 configure) { - return TestGradleBuildScriptBuilder.Companion.buildscript(this, configure); + public @NotNull String script(@NotNull Consumer configure) { + var builder = createBuildScriptBuilder(); + configure.accept(builder); + return builder.generate(); } protected @NotNull String getJUnitTestAnnotationClass() { @@ -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); } diff --git a/intellij-community/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/TestGradleBuildScriptBuilder.kt b/intellij-community/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/TestGradleBuildScriptBuilder.kt index ddeb23245..bd1cf264a 100644 --- a/intellij-community/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/TestGradleBuildScriptBuilder.kt +++ b/intellij-community/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/TestGradleBuildScriptBuilder.kt @@ -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() = @@ -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) = - buildscript(gradleVersion, configure::accept) - - fun buildscript(gradleVersion: GradleVersion, configure: TestGradleBuildScriptBuilder.() -> Unit) = - TestGradleBuildScriptBuilder(gradleVersion).apply(configure).generate() - - @JvmStatic - fun GradleImportingTestCase.buildscript(configure: Consumer) = - buildscript(configure::accept) - - fun GradleImportingTestCase.buildscript(configure: TestGradleBuildScriptBuilder.() -> Unit) = - createBuildScriptBuilder().apply(configure).generate() } } \ No newline at end of file diff --git a/intellij-community/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/VersionMatcherRule.java b/intellij-community/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/VersionMatcherRule.java index 77d5a8626..a36ca8ff5 100644 --- a/intellij-community/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/VersionMatcherRule.java +++ b/intellij-community/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/VersionMatcherRule.java @@ -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:
+ * - Idea_Tests_BuildToolsTests
+ * - Intellij Teamcity configuration
+ * - {@link VersionMatcherRule#BASE_GRADLE_VERSION}
+ * - {@link GradleJvmSupportMatrices#SUPPORTED_JAVA_VERSIONS}
+ * - {@link GradleJvmSupportMatrices#SUPPORTED_GRADLE_VERSIONS}
+ * - {@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 myMatcher; @@ -56,7 +62,7 @@ protected void starting(Description d) { final TargetVersions targetVersions = d.getAnnotation(TargetVersions.class); if (targetVersions == null) return; - myMatcher = new CustomMatcher("Gradle version '" + targetVersions.value() + "'") { + myMatcher = new CustomMatcher("Gradle version '" + Arrays.toString(targetVersions.value()) + "'") { @Override public boolean matches(Object item) { return item instanceof String && new VersionMatcher(GradleVersion.version(item.toString())).isVersionMatch(targetVersions); diff --git a/intellij-community/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/annotation/TargetVersions.java b/intellij-community/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/annotation/TargetVersions.java index dec248afc..63842f537 100644 --- a/intellij-community/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/annotation/TargetVersions.java +++ b/intellij-community/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/annotation/TargetVersions.java @@ -23,7 +23,7 @@ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.METHOD}) public @interface TargetVersions { - String value(); + String[] value(); boolean checkBaseVersions() default true; } diff --git a/intellij-community/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/AbstractModelBuilderTest.java b/intellij-community/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/AbstractModelBuilderTest.java index 3a04719f8..f9ea8378c 100644 --- a/intellij-community/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/AbstractModelBuilderTest.java +++ b/intellij-community/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/AbstractModelBuilderTest.java @@ -1,4 +1,4 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.plugins.gradle.tooling.builder; import com.amazon.ion.IonType; @@ -13,7 +13,6 @@ import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.lang.JavaVersion; -import gnu.trove.THash; import it.unimi.dsi.fastutil.objects.Object2ObjectMap; import org.codehaus.groovy.runtime.typehandling.ShortTypeHandling; import org.gradle.internal.impldep.com.google.common.collect.Multimap; @@ -38,7 +37,7 @@ import org.jetbrains.plugins.gradle.tooling.VersionMatcherRule; import org.jetbrains.plugins.gradle.tooling.internal.init.Init; import org.jetbrains.plugins.gradle.util.GradleConstants; -import org.jetbrains.plugins.gradle.util.GradleJvmSupportMatriciesKt; +import org.jetbrains.plugins.gradle.util.GradleJvmSupportMatrices; import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -89,7 +88,7 @@ public AbstractModelBuilderTest(@NotNull String gradleVersion) { } @Parameterized.Parameters(name = "{index}: with Gradle-{0}") - public static Collection data() { + public static Collection data() { return Arrays.asList(VersionMatcherRule.SUPPORTED_GRADLE_VERSIONS); } @@ -170,8 +169,8 @@ public void setUp() throws Exception { public static void assumeGradleCompatibleWithJava(@NotNull String gradleVersion) { assumeTrue("Gradle version [" + gradleVersion + "] is incompatible with Java version [" + JavaVersion.current() + "]", - GradleJvmSupportMatriciesKt.isSupported(GradleVersion.version(gradleVersion), - JavaVersion.current())); + GradleJvmSupportMatrices.isSupported(GradleVersion.version(gradleVersion), + JavaVersion.current())); if (GradleVersion.version(gradleVersion).getBaseVersion().compareTo(GradleVersion.version("4.8")) < 0) { assumeThat(JavaVersion.current().feature, new CustomMatcher("Java version older than 9") { @@ -194,8 +193,6 @@ public static Set> getToolingExtensionClasses() { Init.class, Multimap.class, ShortTypeHandling.class, - // trove4j jar - THash.class, // fastutil Object2ObjectMap.class, // ion-java jar diff --git a/intellij-community/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/util/VersionMatcher.java b/intellij-community/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/util/VersionMatcher.java index 09f28a811..248aa273c 100644 --- a/intellij-community/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/util/VersionMatcher.java +++ b/intellij-community/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/util/VersionMatcher.java @@ -1,6 +1,8 @@ // Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.gradle.tooling.util; +import com.intellij.openapi.util.Condition; +import com.intellij.util.containers.ContainerUtil; import org.gradle.util.GradleVersion; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -24,6 +26,15 @@ public boolean isVersionMatch(@Nullable TargetVersions targetVersions) { return isVersionMatch(targetVersions.value(), targetVersions.checkBaseVersions()); } + public boolean isVersionMatch(@Nullable String[] targetVersions, final boolean checkBaseVersions) { + return ContainerUtil.all(targetVersions, new Condition() { + @Override + public boolean value(String it) { + return isVersionMatch(it, checkBaseVersions); + } + }); + } + public boolean isVersionMatch(@Nullable String targetVersions, boolean checkBaseVersions) { if (targetVersions == null || targetVersions.isEmpty()) return true; diff --git a/intellij-community/plugins/maven/testFramework/src/com/intellij/maven/testFramework/MavenImportingTestCase.java b/intellij-community/plugins/maven/testFramework/src/com/intellij/maven/testFramework/MavenImportingTestCase.java index 25a3d3d1b..d36e3bf9a 100644 --- a/intellij-community/plugins/maven/testFramework/src/com/intellij/maven/testFramework/MavenImportingTestCase.java +++ b/intellij-community/plugins/maven/testFramework/src/com/intellij/maven/testFramework/MavenImportingTestCase.java @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.maven.testFramework; import com.intellij.application.options.CodeStyle; @@ -53,6 +53,7 @@ import org.jetbrains.jps.model.java.JavaSourceRootProperties; import org.jetbrains.jps.model.java.JavaSourceRootType; import org.jetbrains.jps.model.module.JpsModuleSourceRootType; +import org.junit.Assume; import java.io.File; import java.util.*; @@ -70,11 +71,21 @@ public abstract class MavenImportingTestCase extends MavenTestCase { protected MavenReadContext myReadContext; protected MavenResolvedContext myResolvedContext; protected MavenImportedContext myImportedContext; + protected MavenImportingResult myImportingResult; protected MavenSourcesGeneratedContext mySourcesGeneratedContext; protected MavenPluginResolvedContext myPluginResolvedContext; + private final Set FAILED_IN_MASTER = + ContainerUtil.set("MavenProjectsManagerTest.testUpdatingProjectsWhenMovingModuleFile", + "MavenProjectsManagerTest.testUpdatingProjectsWhenAbsentManagedProjectFileAppears", + "MavenProjectsManagerTest.testAddingManagedFileAndChangingAggregation", + "MavenProjectsManagerWatcherTest.testChangeConfigInOurProjectShouldCallUpdatePomFile", + "MavenProjectsManagerWatcherTest.testIncrementalAutoReload"); + @Override protected void setUp() throws Exception { + Assume.assumeFalse(FAILED_IN_MASTER.contains(getClass().getSimpleName() + "." + getName())); + VfsRootAccess.allowRootAccess(getTestRootDisposable(), PathManager.getConfigPath()); super.setUp(); @@ -109,27 +120,44 @@ protected void tearDown() throws Exception { ); } + @Override + protected boolean useDirectoryBasedProjectFormat() { + return true; + } + + public boolean isWorkspaceImport() { + return MavenProjectImporter.isImportToWorkspaceModelEnabled(myProject); + } + public boolean supportModuleGroups() { - return !MavenProjectImporter.isImportToWorkspaceModelEnabled() - && !MavenProjectImporter.isImportToTreeStructureEnabled(myProject); + return !isWorkspaceImport() + && !MavenProjectImporter.isLegacyImportToTreeStructureEnabled(myProject); } public boolean supportsKeepingManualChanges() { - return !MavenProjectImporter.isImportToWorkspaceModelEnabled(); + return !isWorkspaceImport(); + } + + public boolean supportsImportOfNonExistingFolders() { + return isWorkspaceImport(); } public boolean supportsKeepingModulesFromPreviousImport() { - return !MavenProjectImporter.isImportToWorkspaceModelEnabled() - && !MavenProjectImporter.isImportToTreeStructureEnabled(myProject); + return !isWorkspaceImport() + && !MavenProjectImporter.isLegacyImportToTreeStructureEnabled(myProject); + } + + public boolean supportsLegacyKeepingFoldersFromPreviousImport() { + return !isWorkspaceImport(); } - public boolean supportsKeepingFoldersFromPreviousImport() { - return !MavenProjectImporter.isImportToWorkspaceModelEnabled(); + public boolean supportsKeepingFacetsFromPreviousImport() { + return !isWorkspaceImport(); } public boolean supportsCreateAggregatorOption() { - return !MavenProjectImporter.isImportToWorkspaceModelEnabled() - && !MavenProjectImporter.isImportToTreeStructureEnabled(myProject); + return !isWorkspaceImport() + && !MavenProjectImporter.isLegacyImportToTreeStructureEnabled(myProject); } protected void stopMavenImportManager() { @@ -148,8 +176,10 @@ protected void setUpInWriteAction() throws Exception { } protected String mn(String parent, String moduleName) { - if (!MavenProjectImporter.isImportToTreeStructureEnabled(myProject)) return moduleName; - return parent + "." + moduleName; + if (MavenProjectImporter.isLegacyImportToTreeStructureEnabled(myProject)) { + return parent + "." + moduleName; + } + return moduleName; } protected void assertModules(String... expectedNames) { @@ -174,16 +204,7 @@ protected void assertContentRoots(String moduleName, String... expectedRoots) { for (ContentEntry e : getContentRoots(moduleName)) { actual.add(e.getUrl()); } - - for (int i = 0; i < expectedRoots.length; i++) { - expectedRoots[i] = VfsUtilCore.pathToUrl(expectedRoots[i]); - } - - assertUnorderedPathsAreEqual(actual, Arrays.asList(expectedRoots)); - } - - protected void assertSources(String moduleName, String... expectedSources) { - doAssertContentFolders(moduleName, JavaSourceRootType.SOURCE, expectedSources); + assertUnorderedPathsAreEqual(actual, ContainerUtil.map(expectedRoots, root -> VfsUtilCore.pathToUrl(root))); } protected void assertGeneratedSources(String moduleName, String... expectedSources) { @@ -199,21 +220,45 @@ protected void assertGeneratedSources(String moduleName, String... expectedSourc doAssertContentFolders(contentRoot, folders, expectedSources); } + protected void assertSources(String moduleName, String... expectedSources) { + doAssertContentFolders(moduleName, JavaSourceRootType.SOURCE, expectedSources); + } + + protected void assertContentRootSources(String moduleName, String contentRoot, String... expectedSources) { + ContentEntry root = getContentRoot(moduleName, contentRoot); + doAssertContentFolders(root, root.getSourceFolders(JavaSourceRootType.SOURCE), expectedSources); + } + protected void assertResources(String moduleName, String... expectedSources) { doAssertContentFolders(moduleName, JavaResourceRootType.RESOURCE, expectedSources); } + protected void assertContentRootResources(String moduleName, String contentRoot, String... expectedSources) { + ContentEntry root = getContentRoot(moduleName, contentRoot); + doAssertContentFolders(root, root.getSourceFolders(JavaResourceRootType.RESOURCE), expectedSources); + } + protected void assertTestSources(String moduleName, String... expectedSources) { doAssertContentFolders(moduleName, JavaSourceRootType.TEST_SOURCE, expectedSources); } + protected void assertContentRootTestSources(String moduleName, String contentRoot, String... expectedSources) { + ContentEntry root = getContentRoot(moduleName, contentRoot); + doAssertContentFolders(root, root.getSourceFolders(JavaSourceRootType.TEST_SOURCE), expectedSources); + } + protected void assertTestResources(String moduleName, String... expectedSources) { doAssertContentFolders(moduleName, JavaResourceRootType.TEST_RESOURCE, expectedSources); } + protected void assertContentRootTestResources(String moduleName, String contentRoot, String... expectedSources) { + ContentEntry root = getContentRoot(moduleName, contentRoot); + doAssertContentFolders(root, root.getSourceFolders(JavaResourceRootType.TEST_RESOURCE), expectedSources); + } + protected void assertExcludes(String moduleName, String... expectedExcludes) { ContentEntry contentRoot = getContentRoot(moduleName); - doAssertContentFolders(contentRoot, Arrays.asList(contentRoot.getExcludeFolders()), false, expectedExcludes); + doAssertContentFolders(contentRoot, Arrays.asList(contentRoot.getExcludeFolders()), expectedExcludes); } protected void assertContentRootExcludes(String moduleName, String contentRoot, String... expectedExcudes) { @@ -230,13 +275,8 @@ protected MavenProjectsTree getProjectsTree() { return myProjectsManager.getProjectsTree(); } - private static void doAssertContentFolders(ContentEntry e, final List folders, String... expected) { - doAssertContentFolders(e, folders, true, expected); - } - private static void doAssertContentFolders(ContentEntry e, final List folders, - boolean checkOrder, String... expected) { List actual = new ArrayList<>(); for (ContentFolder f : folders) { @@ -251,18 +291,8 @@ private static void doAssertContentFolders(ContentEntry e, actual.add(folderUrl); } - if (MavenProjectImporter.isImportToWorkspaceModelEnabled()) { - // The new workspace model currently doesn't return source folders in the same order that they were added. - // Actually, we don't care about the source folders order as it shouldn't affect functionality. - checkOrder = false; - } - - if (checkOrder) { - assertOrderedElementsAreEqual(actual, Arrays.asList(expected)); - } - else { - assertUnorderedElementsAreEqual(actual, Arrays.asList(expected)); - } + assertSameElements("Unexpected list of folders in content root " + e.getUrl(), + actual, Arrays.asList(expected)); } protected void assertModuleOutput(String moduleName, String output, String testOutput) { @@ -429,6 +459,14 @@ protected Module getModule(final String name) { return m; } + protected void assertMavenizedModule(final String name) { + assertTrue(MavenProjectsManager.getInstance(myProject).isMavenizedModule(getModule(name))); + } + + protected void assertNotMavenizedModule(final String name) { + assertFalse(MavenProjectsManager.getInstance(myProject).isMavenizedModule(getModule(name))); + } + private ContentEntry getContentRoot(String moduleName) { ContentEntry[] ee = getContentRoots(moduleName); List roots = new ArrayList<>(); @@ -443,10 +481,14 @@ private ContentEntry getContentRoot(String moduleName) { } private ContentEntry getContentRoot(String moduleName, String path) { - for (ContentEntry e : getContentRoots(moduleName)) { + ContentEntry[] roots = getContentRoots(moduleName); + for (ContentEntry e : roots) { if (e.getUrl().equals(VfsUtilCore.pathToUrl(path))) return e; } - throw new AssertionError("content root not found"); + throw new AssertionError("content root not found in module " + moduleName + ":" + + "\nExpected root: " + path + + "\nExisting roots:" + + "\n" + StringUtil.join(roots, it -> " * " + it.getUrl(), "\n")); } public ContentEntry[] getContentRoots(String moduleName) { @@ -499,7 +541,7 @@ protected void doImportProjects(final List files, boolean failOnRea importViaNewFlow(files, failOnReadingError, Collections.emptyList(), profiles); } else { - doImportProjects(files, failOnReadingError, Collections.emptyList(), profiles); + doImportProjectsLegacyWay(files, failOnReadingError, Collections.emptyList(), profiles); } } @@ -510,12 +552,13 @@ protected final void importViaNewFlow(final List files, boolean fai myProjectsManager.initForTests(); myProjectsManager.getProjectsTree().setExplicitProfiles(new MavenExplicitProfiles(Arrays.asList(profiles), disabledProfiles)); MavenImportingManager importingManager = MavenImportingManager.getInstance(myProject); - Promise promise = importingManager.openProjectAndImport( + myImportingResult = importingManager.openProjectAndImport( new FilesList(files), getMavenImporterSettings(), getMavenGeneralSettings(), MavenImportSpec.EXPLICIT_IMPORT - ).getFinishPromise().onSuccess(p -> { + ); + Promise promise = myImportingResult.getFinishPromise().onSuccess(p -> { Throwable t = p.getError(); if (t != null) { if (t instanceof RuntimeException) throw (RuntimeException)t; @@ -524,10 +567,6 @@ protected final void importViaNewFlow(final List files, boolean fai myImportedContext = p.getContext(); myReadContext = myImportedContext.getReadContext(); myResolvedContext = myImportedContext.getResolvedContext(); - DependencySearchService depService = myReadContext.getProject().getServiceIfCreated(DependencySearchService.class); - if (depService != null) { - depService.updateProviders(); - } }); try { @@ -571,7 +610,7 @@ protected final void importViaNewFlow(final List files, boolean fai PlatformTestUtil.waitForFuture(future, 60_000);*/ } - protected void doImportProjects(final List files, boolean failOnReadingError, + protected void doImportProjectsLegacyWay(final List files, boolean failOnReadingError, List disabledProfiles, String... profiles) { assertFalse(ApplicationManager.getApplication().isWriteAccessAllowed()); initProjectsManager(false); @@ -595,7 +634,7 @@ protected void doImportProjects(final List files, boolean failOnRea } protected void waitForImportCompletion() { - edt(() -> waitForPromise(myProjectsManager.waitForImportCompletion())); + edt(() -> waitForPromise(myProjectsManager.waitForImportCompletion(), 60_000)); } protected void readProjects(List files, String... profiles) { @@ -623,8 +662,13 @@ protected void readProjects(List files, List disabledProfil } protected void updateProjectsAndImport(VirtualFile... files) { - readProjects(files); - myProjectsManager.performScheduledImportInTests(); + if (isNewImportingProcess) { + importViaNewFlow(Arrays.asList(files), true, Collections.emptyList()); + } + else { + readProjects(files); + myProjectsManager.performScheduledImportInTests(); + } } protected void initProjectsManager(boolean enableEventHandling) { @@ -679,14 +723,15 @@ protected void resolveDependenciesAndImport() { } protected void resolveFoldersAndImport() { - if (isNewImportingProcess) { - importProject(); - return; - } myProjectsManager.scheduleFoldersResolveForAllProjects(); myProjectsManager.waitForFoldersResolvingCompletion(); - ApplicationManager.getApplication().invokeAndWait(() -> myProjectsManager.performScheduledImportInTests()); + if (isNewImportingProcess) { + importProject(); + } + else { + ApplicationManager.getApplication().invokeAndWait(() -> myProjectsManager.performScheduledImportInTests()); + } } protected void resolvePlugins() { diff --git a/intellij-community/plugins/maven/testFramework/src/com/intellij/maven/testFramework/MavenTestCase.java b/intellij-community/plugins/maven/testFramework/src/com/intellij/maven/testFramework/MavenTestCase.java index 198226292..b93d30171 100644 --- a/intellij-community/plugins/maven/testFramework/src/com/intellij/maven/testFramework/MavenTestCase.java +++ b/intellij-community/plugins/maven/testFramework/src/com/intellij/maven/testFramework/MavenTestCase.java @@ -1,8 +1,11 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.maven.testFramework; import com.intellij.execution.wsl.WSLDistribution; import com.intellij.execution.wsl.WslDistributionManager; +import com.intellij.ide.DataManager; +import com.intellij.openapi.actionSystem.CommonDataKeys; +import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.command.WriteCommandAction; @@ -35,6 +38,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.idea.maven.indices.MavenIndicesManager; import org.jetbrains.idea.maven.project.*; import org.jetbrains.idea.maven.server.MavenServerConnector; @@ -43,7 +47,6 @@ import org.jetbrains.idea.maven.server.RemotePathTransformerFactory; import org.jetbrains.idea.maven.utils.MavenProgressIndicator; import org.jetbrains.idea.maven.utils.MavenUtil; -import org.junit.Assume; import java.awt.*; import java.io.File; @@ -56,11 +59,13 @@ import java.util.concurrent.TimeUnit; public abstract class MavenTestCase extends UsefulTestCase { - protected static final String MAVEN_COMPILER_PROPERTIES = "\n" + - " UTF-8\n" + - " 1.7\n" + - " 1.7\n" + - "\n"; + protected static final String MAVEN_COMPILER_PROPERTIES = """ + + UTF-8 + 1.7 + 1.7 + + """; protected static final MavenConsole NULL_MAVEN_CONSOLE = new NullMavenConsole(); private MavenProgressIndicator myProgressIndicator; private MavenEmbeddersManager myEmbeddersManager; @@ -80,19 +85,10 @@ public abstract class MavenTestCase extends UsefulTestCase { protected VirtualFile myProjectPom; protected List myAllPoms = new ArrayList<>(); - private final Set FAILED_IN_MASTER = - ContainerUtil.set("MavenProjectsManagerTest.testUpdatingProjectsWhenMovingModuleFile", - "MavenProjectsManagerTest.testUpdatingProjectsWhenAbsentManagedProjectFileAppears", - "MavenProjectsManagerTest.testAddingManagedFileAndChangingAggregation", - "MavenProjectsManagerWatcherTest.testChangeConfigInOurProjectShouldCallUpdatePomFile", - "MavenProjectsManagerWatcherTest.testIncrementalAutoReload", - "InvalidEnvironmentImportingTest.testShouldShowLogsOfMavenServerIfNotStarted", - "MavenProjectReaderTest.testInvalidXmlWithWrongClosingTag"); @Override protected void setUp() throws Exception { super.setUp(); - Assume.assumeFalse(FAILED_IN_MASTER.contains(getClass().getSimpleName() + "." + getName())); setUpFixtures(); myProject = myTestFixture.getProject(); @@ -161,15 +157,11 @@ protected void waitForMavenUtilRunnablesComplete() { protected void runBare(@NotNull ThrowableRunnable testRunnable) throws Throwable { LoggedErrorProcessor.executeWith(new LoggedErrorProcessor() { @Override - public boolean processError(@NotNull String category, String message, Throwable t, String @NotNull [] details) { - if (StringUtil.notNullize(t.getMessage()).contains("The network name cannot be found") && - StringUtil.notNullize(message).contains("Couldn't read shelf information")) { - return false; - } - if ("JDK annotations not found".equals(t.getMessage()) && "#com.intellij.openapi.projectRoots.impl.JavaSdkImpl".equals(category)) { - return false; - } - return super.processError(category, message, t, details); + public @NotNull Set processError(@NotNull String category, @NotNull String message, String @NotNull [] details, @Nullable Throwable t) { + boolean intercept = t != null && ( + StringUtil.notNullize(t.getMessage()).contains("The network name cannot be found") && message.contains("Couldn't read shelf information") || + "JDK annotations not found".equals(t.getMessage()) && "#com.intellij.openapi.projectRoots.impl.JavaSdkImpl".equals(category)); + return intercept ? Action.NONE : Action.ALL; } }, () -> super.runBare(testRunnable)); } @@ -247,18 +239,25 @@ private void ensureTempDirCreated() throws IOException { protected void setUpFixtures() throws Exception { String wslMsId = System.getProperty("wsl.distribution.name"); + + boolean isDirectoryBasedProject = useDirectoryBasedProjectFormat(); if (wslMsId != null) { Path path = TemporaryDirectory .generateTemporaryPath(FileUtil.sanitizeFileName(getName(), false), Paths.get("\\\\wsl$\\" + wslMsId + "\\tmp")); - myTestFixture = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getName(), path, false).getFixture(); + myTestFixture = + IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getName(), path, isDirectoryBasedProject).getFixture(); } else { - myTestFixture = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getName()).getFixture(); + myTestFixture = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getName(), isDirectoryBasedProject).getFixture(); } myTestFixture.setUp(); } + protected boolean useDirectoryBasedProjectFormat() { + return false; + } + protected void setUpInWriteAction() throws Exception { File projectDir = new File(myDir, "project"); projectDir.mkdirs(); @@ -522,10 +521,15 @@ protected void deleteProfilesXml() throws IOException { } protected void createStdProjectFolders() { - createProjectSubDirs("src/main/java", - "src/main/resources", - "src/test/java", - "src/test/resources"); + createStdProjectFolders(""); + } + + protected void createStdProjectFolders(String subdir) { + if (!subdir.isEmpty()) subdir += "/"; + createProjectSubDirs(subdir + "src/main/java", + subdir + "src/main/resources", + subdir + "src/test/java", + subdir + "src/test/resources"); } protected void createProjectSubDirs(String... relativePaths) { @@ -676,6 +680,19 @@ private static String getTestMavenHome() { return System.getProperty("idea.maven.test.home"); } + protected DataContext createTestDataContext(VirtualFile pomFile) { + final DataContext defaultContext = DataManager.getInstance().getDataContext(); + return dataId -> { + if (CommonDataKeys.PROJECT.is(dataId)) { + return myProject; + } + if (CommonDataKeys.VIRTUAL_FILE_ARRAY.is(dataId)) { + return new VirtualFile[]{pomFile}; + } + return defaultContext.getData(dataId); + }; + } + private static class SetWithToString extends AbstractSet { private final Set myDelegate; diff --git a/pull_intellij_tests.sh b/pull_intellij_tests.sh index 07ecb09e5..fc70328bf 100755 --- a/pull_intellij_tests.sh +++ b/pull_intellij_tests.sh @@ -34,6 +34,4 @@ mkdir -p intellij-community/plugins/gradle/tooling-extension-impl/testSources/or cp -p intellij-community-tmp/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/annotation/TargetVersions.java intellij-community/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/annotation mkdir -p intellij-community/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/util/ cp -p intellij-community-tmp/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/util/VersionMatcher.java intellij-community/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/util -mkdir -p intellij-community/plugins/gradle/src/org/jetbrains/plugins/gradle/util -cp -p intellij-community-tmp/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleJvmSupportMatricies.kt intellij-community/plugins/gradle/src/org/jetbrains/plugins/gradle/util echo "Done!" \ No newline at end of file