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 86d0156a1..564d82d4c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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.6 channel=nightly quarkusVersion=3.1.2.Final lsp4mpVersion=0.10.0 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f2d658759..417602110 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,10 +3,10 @@ annotations = "24.0.1" # plugins -testlogger = "3.2.0" +testlogger = "4.0.0" kotlin = "1.9.10" changelog = "2.2.0" -gradleIntelliJPlugin = "1.16.1" +gradleIntelliJPlugin = "1.17.2" [libraries] diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7f93135c4..d64cd4917 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3fa8f862f..a80b22ce5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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.6-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew.bat b/gradlew.bat index 93e3f59f1..6689b85be 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,92 +1,92 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega 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..63b6931f3 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() { @@ -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); } 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..b3ceee7d2 100755 --- a/pull_intellij_tests.sh +++ b/pull_intellij_tests.sh @@ -1,5 +1,5 @@ # Check version to clone from https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html#intellij-platform-based-products-of-recent-ide-versions -IDEA_VERSION=$(grep '^pluginSinceBuild' gradle.properties | cut -d '=' -f 2 | tr -d ' ') # 222 = 2022.2 +IDEA_VERSION=$(grep '^pluginSinceBuild' gradle.properties | cut -d '=' -f 2 | tr -d ' ') # 223 = 2022.3 rm -rf intellij-community-tmp 2>/dev/null git clone --single-branch --depth 1 --branch $IDEA_VERSION https://github.com/JetBrains/intellij-community intellij-community-tmp rm -rf intellij-community 2>/dev/null @@ -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 diff --git a/src/main/java/com/redhat/devtools/intellij/quarkus/lsp/AbstractQuarkusDocumentMatcher.java b/src/main/java/com/redhat/devtools/intellij/quarkus/lsp/AbstractQuarkusDocumentMatcher.java index 68c9cb25b..99abeb7ab 100644 --- a/src/main/java/com/redhat/devtools/intellij/quarkus/lsp/AbstractQuarkusDocumentMatcher.java +++ b/src/main/java/com/redhat/devtools/intellij/quarkus/lsp/AbstractQuarkusDocumentMatcher.java @@ -16,6 +16,7 @@ import com.redhat.devtools.lsp4ij.AbstractDocumentMatcher; import com.redhat.devtools.lsp4ij.LSPIJUtils; import com.redhat.devtools.intellij.quarkus.QuarkusModuleUtil; +import org.jetbrains.annotations.NotNull; /** * Base class for Quarkus document matcher which checks that the file belongs to a Quarkus project. @@ -23,7 +24,7 @@ public class AbstractQuarkusDocumentMatcher extends AbstractDocumentMatcher { @Override - public boolean match(VirtualFile file, Project fileProject) { + public boolean match(@NotNull VirtualFile file, @NotNull Project fileProject) { Module module = LSPIJUtils.getModule(file, fileProject); return module != null && QuarkusModuleUtil.isQuarkusModule(module); } diff --git a/src/main/java/com/redhat/devtools/intellij/quarkus/lsp/QuarkusDocumentMatcherForPropertiesFile.java b/src/main/java/com/redhat/devtools/intellij/quarkus/lsp/QuarkusDocumentMatcherForPropertiesFile.java index baf011c24..a9c2b43fb 100644 --- a/src/main/java/com/redhat/devtools/intellij/quarkus/lsp/QuarkusDocumentMatcherForPropertiesFile.java +++ b/src/main/java/com/redhat/devtools/intellij/quarkus/lsp/QuarkusDocumentMatcherForPropertiesFile.java @@ -13,6 +13,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.redhat.devtools.intellij.quarkus.QuarkusModuleUtil; +import org.jetbrains.annotations.NotNull; /** * Quarkus document matcher for application.properties, microprofile-config.properties @@ -21,7 +22,7 @@ public class QuarkusDocumentMatcherForPropertiesFile extends AbstractQuarkusDocumentMatcher { @Override - public boolean match(VirtualFile file, Project fileProject) { + public boolean match(@NotNull VirtualFile file, @NotNull Project fileProject) { if (!matchFile(file, fileProject)) { return false; } diff --git a/src/main/java/com/redhat/devtools/intellij/quarkus/run/QuarkusDevActionGroup.java b/src/main/java/com/redhat/devtools/intellij/quarkus/run/QuarkusDevActionGroup.java index 88bfaca8c..0bb47647a 100644 --- a/src/main/java/com/redhat/devtools/intellij/quarkus/run/QuarkusDevActionGroup.java +++ b/src/main/java/com/redhat/devtools/intellij/quarkus/run/QuarkusDevActionGroup.java @@ -11,6 +11,7 @@ package com.redhat.devtools.intellij.quarkus.run; import com.intellij.openapi.actionSystem.ActionGroup; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.util.IconLoader; @@ -37,4 +38,10 @@ public void update(@NotNull AnActionEvent e) { public AnAction[] getChildren(@Nullable AnActionEvent e) { return new AnAction[] { OPEN_DEV_UI_ACTION, OPEN_APP_ACTION}; } + + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.BGT; + } + } diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index e66c12605..7ef80b512 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -316,7 +316,7 @@ - + diff --git a/src/test/java/com/redhat/devtools/intellij/GradleTestCase.java b/src/test/java/com/redhat/devtools/intellij/GradleTestCase.java index 6299e9c41..c765f7b33 100644 --- a/src/test/java/com/redhat/devtools/intellij/GradleTestCase.java +++ b/src/test/java/com/redhat/devtools/intellij/GradleTestCase.java @@ -12,6 +12,7 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtilCore; +import com.intellij.openapi.util.Couple; import com.redhat.devtools.intellij.quarkus.buildtool.gradle.AbstractGradleToolDelegate; import org.gradle.tooling.GradleConnector; import org.gradle.tooling.ProjectConnection; @@ -70,10 +71,15 @@ protected File getMavenRepository() { @Parameterized.Parameters(name = "{index}: with Gradle-{0}") public static Collection data() { - return Arrays.asList(new Object[][]{{"8.4"}}); + return Arrays.asList(new Object[][]{{"8.6"}}); } protected String getJavaFileUri(String path, Module module) { return new File(ModuleUtilCore.getModuleDirPath(module), path).toURI().toString(); } + + @Override + protected void handleDeprecationError(Couple errorInfo) { + //Don't fail the test -yet- if Gradle is complaining about deprecated features + } } diff --git a/src/test/java/com/redhat/devtools/intellij/lsp4mp4ij/psi/core/GradlePropertiesManagerTest.java b/src/test/java/com/redhat/devtools/intellij/lsp4mp4ij/psi/core/GradlePropertiesManagerTest.java index 28f02f225..fbc7f44a8 100644 --- a/src/test/java/com/redhat/devtools/intellij/lsp4mp4ij/psi/core/GradlePropertiesManagerTest.java +++ b/src/test/java/com/redhat/devtools/intellij/lsp4mp4ij/psi/core/GradlePropertiesManagerTest.java @@ -18,6 +18,7 @@ import org.eclipse.lsp4mp.commons.DocumentFormat; import org.eclipse.lsp4mp.commons.MicroProfileProjectInfo; import org.eclipse.lsp4mp.commons.MicroProfilePropertiesScope; +import org.intellij.lang.annotations.Language; import org.junit.Test; import java.io.File; @@ -31,27 +32,26 @@ * @see https://github.com/redhat-developer/quarkus-ls/blob/master/microprofile.jdt/com.redhat.microprofile.jdt.test/src/main/java/com/redhat/microprofile/jdt/core/PropertiesManagerTest.java */ public class GradlePropertiesManagerTest extends GradleTestCase { + @Language("Groovy") private static final String CONFIG = - "plugins {\n" + - " id 'java'\n" + - "}\n" + - - "repositories {\n" + - " mavenLocal()\n" + - " mavenCentral()\n" + - "}\n" + - - "dependencies {\n" + - " implementation 'io.quarkus:quarkus-core-deployment:1.0.1.Final'\n" + - "}\n" + - - "group 'org.acme'\n" + - "version '1.0.0-SNAPSHOT'\n" + - - "java {\n" + - " sourceCompatibility = JavaVersion.VERSION_1_8\n" + - " targetCompatibility = JavaVersion.VERSION_1_8\n" + - "}"; + """ + plugins { + id 'java' + } + repositories { + mavenLocal() + mavenCentral() + } + dependencies { + implementation 'io.quarkus:quarkus-core-deployment:1.0.1.Final' + } + group 'org.acme' + version '1.0.0-SNAPSHOT' + java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + """; @Test public void testQuarkusCoreDeploymentProperties() throws IOException { diff --git a/src/test/java/com/redhat/devtools/intellij/lsp4mp4ij/psi/core/MicroProfileAssert.java b/src/test/java/com/redhat/devtools/intellij/lsp4mp4ij/psi/core/MicroProfileAssert.java index e7ec5146b..4ef1865a2 100644 --- a/src/test/java/com/redhat/devtools/intellij/lsp4mp4ij/psi/core/MicroProfileAssert.java +++ b/src/test/java/com/redhat/devtools/intellij/lsp4mp4ij/psi/core/MicroProfileAssert.java @@ -11,17 +11,20 @@ import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.compiler.CompilerPaths; import com.intellij.openapi.module.Module; import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.PsiDocumentManager; import org.eclipse.lsp4j.Hover; import org.eclipse.lsp4j.MarkupContent; import org.eclipse.lsp4j.Position; import org.eclipse.lsp4j.Range; import org.eclipse.lsp4j.jsonrpc.messages.Either; import org.eclipse.lsp4mp.commons.MicroProfileProjectInfo; +import org.eclipse.lsp4mp.commons.metadata.ItemBase; import org.eclipse.lsp4mp.commons.metadata.ItemHint; import org.eclipse.lsp4mp.commons.metadata.ItemMetadata; import org.eclipse.lsp4mp.commons.metadata.ValueHint; @@ -79,7 +82,7 @@ public static void assertProperties(MicroProfileProjectInfo info, Integer expect private static void assertProperty(MicroProfileProjectInfo info, ItemMetadata expected) { List matches = info.getProperties().stream().filter(completion -> { return expected.getName().equals(completion.getName()); - }).collect(Collectors.toList()); + }).toList(); assertEquals( "'" + expected.getName() + "'" + " should exist exactly once: Actual: " @@ -146,7 +149,7 @@ public static void assertPropertiesDuplicate(MicroProfileProjectInfo info) { Map propertiesCount = info.getProperties().stream() .collect(Collectors.groupingBy(ItemMetadata::getName, Collectors.counting())); List> result = propertiesCount.entrySet().stream().filter(entry -> entry.getValue() > 1) - .collect(Collectors.toList()); + .toList(); assertEquals( result.stream().map(entry -> entry.getKey() + "=" + entry.getValue()).collect(Collectors.joining(",")), 0, result.size()); @@ -189,11 +192,11 @@ public static void assertHints(MicroProfileProjectInfo info, Integer expectedCou private static void assertHint(MicroProfileProjectInfo info, ItemHint expected) { List matches = info.getHints().stream().filter(completion -> { return expected.getName().equals(completion.getName()); - }).collect(Collectors.toList()); + }).toList(); assertEquals( expected.getName() + " should only exist once: Actual: " - + info.getHints().stream().map(c -> c.getName()).collect(Collectors.joining(",")), + + info.getHints().stream().map(ItemBase::getName).collect(Collectors.joining(",")), 1, matches.size()); ItemHint actual = matches.get(0); @@ -251,7 +254,7 @@ public static void assertHintsDuplicate(MicroProfileProjectInfo info) { Map hintsCount = info.getHints().stream() .collect(Collectors.groupingBy(ItemHint::getName, Collectors.counting())); List> result = hintsCount.entrySet().stream().filter(entry -> entry.getValue() > 1) - .collect(Collectors.toList()); + .toList(); assertEquals( result.stream().map(entry -> entry.getKey() + "=" + entry.getValue()).collect(Collectors.joining(",")), 0, result.size()); @@ -271,8 +274,7 @@ public static void saveFile(String name, String content, Module javaProject, boo } catch (InterruptedException e) { Thread.currentThread().interrupt(); } - Application application = ApplicationManager.getApplication(); - application.invokeAndWait(() -> application.runWriteAction(() -> { + WriteAction.runAndWait(() -> { try { VirtualFile folder = null; if (!inSource) { @@ -292,6 +294,7 @@ public static void saveFile(String name, String content, Module javaProject, boo folder = ModuleRootManager.getInstance(javaProject).getSourceRoots()[0]; } } + assert folder != null; VirtualFile file = folder.findFileByRelativePath(name); if (file == null) { String[] comps = name.split("/"); @@ -301,9 +304,11 @@ public static void saveFile(String name, String content, Module javaProject, boo file = folder.findOrCreateChildData(MicroProfileAssert.class, comps[comps.length - 1]); } file.setBinaryContent(content.getBytes(file.getCharset())); - } catch (IOException e) { + + PsiDocumentManager.getInstance(javaProject.getProject()).commitAllDocuments(); + } catch (IOException ignored) { } - })); + }); } public static void deleteFile(String name, Module javaProject) throws IOException { diff --git a/src/test/java/com/redhat/devtools/intellij/lsp4mp4ij/psi/core/jaxrs/java/JaxRsApplicationPathCodeLensTest.java b/src/test/java/com/redhat/devtools/intellij/lsp4mp4ij/psi/core/jaxrs/java/JaxRsApplicationPathCodeLensTest.java index 1adf95b57..f573d696d 100644 --- a/src/test/java/com/redhat/devtools/intellij/lsp4mp4ij/psi/core/jaxrs/java/JaxRsApplicationPathCodeLensTest.java +++ b/src/test/java/com/redhat/devtools/intellij/lsp4mp4ij/psi/core/jaxrs/java/JaxRsApplicationPathCodeLensTest.java @@ -41,11 +41,13 @@ public void testUrlCodeLensApplicationPath() throws Exception { params.setUri(javaFileUri); params.setUrlCodeLensEnabled(true); - saveFile("org/acme/MyApplication.java", "package org.acme;\r\n" + // - "import javax.ws.rs.ApplicationPath;\r\n" + // - "import javax.ws.rs.core.Application;\r\n" + // - "@ApplicationPath(\"/api\")\r\n" + // - "public class MyApplication extends Application {}\r\n", javaProject, true); + saveFile("org/acme/MyApplication.java", """ + package org.acme; + import javax.ws.rs.ApplicationPath; + import javax.ws.rs.core.Application; + @ApplicationPath("/api") + public class MyApplication extends Application {} + """, javaProject, true); // Default port assertCodeLenses(8080, params, utils, "/api/path", r(12, 4, 4)); @@ -62,11 +64,13 @@ public void testUrlCodeLensApplicationPathNoSlash() throws Exception { params.setUri(javaFileUri); params.setUrlCodeLensEnabled(true); - saveFile("org/acme/MyApplication.java", "package org.acme;\r\n" + // - "import javax.ws.rs.ApplicationPath;\r\n" + // - "import javax.ws.rs.core.Application;\r\n" + // - "@ApplicationPath(\"api\")\r\n" + // - "public class MyApplication extends Application {}\r\n", javaProject, true); + saveFile("org/acme/MyApplication.java", """ + package org.acme; + import javax.ws.rs.ApplicationPath; + import javax.ws.rs.core.Application; + @ApplicationPath("api") + public class MyApplication extends Application {} + """, javaProject, true); // Default port assertCodeLenses(8080, params, utils, "/api/path", r(12, 4, 4)); @@ -83,20 +87,24 @@ public void testUrlCodeLensApplicationPathChange() throws Exception { params.setUri(javaFileUri); params.setUrlCodeLensEnabled(true); - saveFile("org/acme/MyApplication.java", "package org.acme;\r\n" + // - "import javax.ws.rs.ApplicationPath;\r\n" + // - "import javax.ws.rs.core.Application;\r\n" + // - "@ApplicationPath(\"/api\")\r\n" + // - "public class MyApplication extends Application {}\r\n", javaProject, true); + saveFile("org/acme/MyApplication.java", """ + package org.acme; + import javax.ws.rs.ApplicationPath; + import javax.ws.rs.core.Application; + @ApplicationPath("/api") + public class MyApplication extends Application {} + """, javaProject, true); // Default port assertCodeLenses(8080, params, utils, "/api/path", r(12, 4, 4)); - saveFile("org/acme/MyApplication.java", "package org.acme;\r\n" + // - "import javax.ws.rs.ApplicationPath;\r\n" + // - "import javax.ws.rs.core.Application;\r\n" + // - "@ApplicationPath(\"/ipa\")\r\n" + // - "public class MyApplication extends Application {}\r\n", javaProject, true); + saveFile("org/acme/MyApplication.java", """ + package org.acme; + import javax.ws.rs.ApplicationPath; + import javax.ws.rs.core.Application; + @ApplicationPath("/ipa") + public class MyApplication extends Application {} + """, javaProject, true); assertCodeLenses(8080, params, utils, "/ipa/path", r(12, 4, 4)); }