From 4de7797ceef5349098cdc2be5ecf613dbe9b06b0 Mon Sep 17 00:00:00 2001 From: "Alexander.Glukhov" Date: Tue, 18 Feb 2025 16:04:31 +0100 Subject: [PATCH] [maven][test][eel][IDEA-361665] use `nio.Path` instead of `io.File` in `MavenCustomRepositoryHelper` GitOrigin-RevId: d9d6906336b70e697e04aff26fbc0243b20ed799 --- .../maven/MavenCustomRepositoryHelper.java | 48 ++-------- .../idea/maven/MavenPluginInfoReaderTest.kt | 2 +- .../MavenCompatibilityProjectImportingTest.kt | 6 +- ...enDependencyCompletionAndResolutionTest.kt | 54 ++++++----- ...venExtensionCompletionAndResolutionTest.kt | 4 +- .../MavenParentCompletionAndResolutionTest.kt | 4 +- .../MavenPluginCompletionAndResolutionTest.kt | 8 +- ...avenPropertyCompletionAndResolutionTest.kt | 2 +- .../dom/MavenRelativePathResolutionTest.kt | 20 ++-- .../MavenClasspathsAndSearchScopesTest.kt | 84 ++++++++--------- .../importing/ArtifactsDownloadingTest.kt | 42 ++++----- .../importing/ArtifactsDownloadingTestCase.kt | 2 +- ...ependenciesImportingExternalChangesTest.kt | 28 +++--- .../importing/DependenciesImportingTest.kt | 80 ++++++++-------- .../importing/DependenciesManagementTest.kt | 8 +- .../maven/importing/FoldersImportingTest.kt | 6 +- .../maven/importing/GroovyImporterTest.kt | 42 +++++---- .../importing/InvalidProjectImportingTest.kt | 4 +- .../MavenRepositoriesDownloadingTest.kt | 93 ++++++++++--------- .../MavenSnapshotDependenciesTest.kt | 8 +- .../maven/importing/MavenStaticSyncTest.kt | 36 +++---- .../MavenWrapperConfigurationTest.kt | 13 +-- .../idea/maven/importing/MiscImportingTest.kt | 6 +- .../SnapshotDependenciesImportingTest.kt | 24 ++--- .../maven/importing/StructureImportingTest.kt | 2 +- .../idea/maven/indices/MavenGavIndicesTest.kt | 4 +- .../maven/indices/MavenIndicesManagerTest.kt | 18 ++-- .../indices/MavenIndicesTestFixture.java | 5 +- .../maven/project/MavenProjectReaderTest.kt | 4 +- .../maven/testFramework/MavenTestCase.kt | 16 ++-- 30 files changed, 326 insertions(+), 347 deletions(-) diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenCustomRepositoryHelper.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenCustomRepositoryHelper.java index 711b33d89f7b..946502c62b5f 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenCustomRepositoryHelper.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenCustomRepositoryHelper.java @@ -20,41 +20,19 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.LocalFileSystem; import org.jetbrains.idea.maven.utils.MavenLog; -import java.io.File; import java.io.IOException; import java.nio.file.*; import java.nio.file.attribute.BasicFileAttributes; import java.util.Collections; public class MavenCustomRepositoryHelper { - private final Path myTempDir; + private final Path myWorkingData; - private final String[] mySubFolders; public MavenCustomRepositoryHelper(Path tempDir, String... subFolders) throws IOException { - myTempDir = tempDir; - mySubFolders = subFolders; - - myWorkingData = myTempDir.resolve("testData"); + myWorkingData = tempDir.resolve("testData"); Files.createDirectories(myWorkingData); - - for (String each : mySubFolders) { - addTestData(each); - } - } - - /** - * @deprecated use NIO - */ - @Deprecated(forRemoval = true) - public MavenCustomRepositoryHelper(File tempDir, String... subFolders) throws IOException { - myTempDir = tempDir.toPath(); - mySubFolders = subFolders; - - myWorkingData = myTempDir.resolve("testData"); - Files.createDirectories(myWorkingData); - - for (String each : mySubFolders) { + for (String each : subFolders) { addTestData(each); } } @@ -76,8 +54,8 @@ public class MavenCustomRepositoryHelper { return FileVisitResult.CONTINUE; } }); - LocalFileSystem.getInstance().refreshIoFiles(Collections.singleton(to.toFile())); - LocalFileSystem.getInstance().refreshIoFiles(Collections.singleton(to.toFile())); + LocalFileSystem.getInstance().refreshNioFiles(Collections.singleton(to)); + LocalFileSystem.getInstance().refreshNioFiles(Collections.singleton(to)); } public static String getOriginalTestDataPath() { @@ -85,23 +63,13 @@ public class MavenCustomRepositoryHelper { return FileUtil.toSystemIndependentName(sourcesDir + "/src/test/data"); } - public String getTestDataPath(String relativePath) { - String path = getTestDataLegacy(relativePath).getPath(); - return FileUtil.toSystemIndependentName(path); - } - public Path getTestData(String relativePath) { return myWorkingData.resolve(relativePath); } - @Deprecated - public File getTestDataLegacy(String relativePath) { - return getTestData(relativePath).toFile(); - } - public void delete(String relativePath) { try { - Path path = Paths.get(getTestDataPath(relativePath)); + Path path = getTestData(relativePath); MavenLog.LOG.warn("Deleting " + path); if (Files.isDirectory(path)) { // delete directory content recursively @@ -129,8 +97,8 @@ public class MavenCustomRepositoryHelper { } public void copy(String fromRelativePath, String toRelativePath) throws IOException { - Path from = Paths.get(getTestDataPath(fromRelativePath)); - Path to = Paths.get(getTestDataPath(toRelativePath)); + Path from = getTestData(fromRelativePath); + Path to = getTestData(toRelativePath); if (Files.isDirectory(from)) { Files.walkFileTree(from, new SimpleFileVisitor<>() { diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenPluginInfoReaderTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenPluginInfoReaderTest.kt index d44fe727edd9..1d01c9b6872a 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenPluginInfoReaderTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenPluginInfoReaderTest.kt @@ -27,7 +27,7 @@ class MavenPluginInfoReaderTest : MavenTestCase() { override fun setUp() { super.setUp() - repositoryPath = MavenCustomRepositoryHelper(dir, "plugins").getTestDataPath("plugins") + repositoryFile = MavenCustomRepositoryHelper(dir, "plugins").getTestData("plugins") p = MavenArtifactUtil.readPluginInfo(Path.of(repositoryFile.toAbsolutePath().toString(), "org/apache/maven/plugins", "maven-compiler-plugin", "2.0.2", "maven-compiler-plugin-2.0.2.jar")) } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compatibility/MavenCompatibilityProjectImportingTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compatibility/MavenCompatibilityProjectImportingTest.kt index 9ab682041909..6949cdb3168c 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compatibility/MavenCompatibilityProjectImportingTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compatibility/MavenCompatibilityProjectImportingTest.kt @@ -92,8 +92,8 @@ class MavenCompatibilityProjectImportingTest : MavenImportingTestCase() { val helper = MavenCustomRepositoryHelper(dir, "local1") - val repoPath = helper.getTestDataPath("local1") - repositoryPath = repoPath + val repoPath = helper.getTestData("local1") + repositoryFile = repoPath } @After @@ -106,7 +106,7 @@ class MavenCompatibilityProjectImportingTest : MavenImportingTestCase() { fun testExceptionsFromMavenExtensionsAreReportedAsProblems() = runBlocking { assumeVersionAtLeast("3.1.0") val helper = MavenCustomRepositoryHelper(dir, "plugins") - repositoryPath = helper.getTestDataPath("plugins") + repositoryFile = helper.getTestData("plugins") mavenGeneralSettings.isWorkOffline = true createProjectPom(""" diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.kt index 729b7907656f..de7f2c533dad 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.kt @@ -7,6 +7,7 @@ import com.intellij.openapi.application.WriteAction import com.intellij.openapi.application.readAction import com.intellij.openapi.application.writeIntentReadAction import com.intellij.openapi.util.io.FileUtil +import com.intellij.openapi.util.io.toCanonicalPath import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.psi.codeStyle.CodeStyleSettingsManager import com.intellij.psi.codeStyle.CommonCodeStyleSettings @@ -396,17 +397,20 @@ class MavenDependencyCompletionAndResolutionTest : MavenDomWithIndicesTestCase() """.trimIndent()) - val filePath = myIndicesFixture!!.repositoryHelper.getTestDataPath("local1/junit/junit/4.0/junit-4.0.pom") - val f = LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath) + val filePath = myIndicesFixture!!.repositoryHelper.getTestData("local1/junit/junit/4.0/junit-4.0.pom") + val f = LocalFileSystem.getInstance().refreshAndFindFileByNioFile(filePath) assertResolved(projectPom, findPsiFile(f)) } @Test fun testResolutionParentPathOutsideTheProject() = runBlocking { - val filePath = myIndicesFixture!!.repositoryHelper.getTestDataPath("local1/org/example/example/1.0/example-1.0.pom") + val filePath = myIndicesFixture!!.repositoryHelper.getTestData("local1/org/example/example/1.0/example-1.0.pom") - val relativePathUnixSeparator = - FileUtil.getRelativePath(File(projectRoot.getPath()), File(filePath))!!.replace("\\\\".toRegex(), "/") + val relativePathUnixSeparator = FileUtil.getRelativePath( + projectRoot.getPath(), + filePath.toCanonicalPath(), + File.separatorChar + )!!.replace("\\\\".toRegex(), "/") updateProjectPom("""test project @@ -420,7 +424,7 @@ $relativePathUnixSeparator """ ) - val f = LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath) + val f = LocalFileSystem.getInstance().refreshAndFindFileByNioFile(filePath) assertResolved(projectPom, findPsiFile(f)) } @@ -448,16 +452,16 @@ $relativePathUnixSeparator """.trimIndent()) importProjectAsync() - val filePath = myIndicesFixture!!.repositoryHelper.getTestDataPath("local1/junit/junit/4.0/junit-4.0.pom") - val f = LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath) + val filePath = myIndicesFixture!!.repositoryHelper.getTestData("local1/junit/junit/4.0/junit-4.0.pom") + val f = LocalFileSystem.getInstance().refreshAndFindFileByNioFile(filePath) assertResolved(projectPom, findPsiFile(f)) } @Test fun testResolveLATESTDependency() = runBlocking { val helper = MavenCustomRepositoryHelper(dir, "local1") - val repoPath = helper.getTestDataPath("local1") - repositoryPath = repoPath + val repoPath = helper.getTestData("local1") + repositoryFile = repoPath updateProjectPom(""" test @@ -486,8 +490,8 @@ $relativePathUnixSeparator """.trimIndent()) - val filePath = myIndicesFixture!!.repositoryHelper.getTestDataPath("local1/junit/junit/4.0/junit-4.0.pom") - val f = LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath) + val filePath = myIndicesFixture!!.repositoryHelper.getTestData("local1/junit/junit/4.0/junit-4.0.pom") + val f = LocalFileSystem.getInstance().refreshAndFindFileByNioFile(filePath) assertResolved(projectPom, findPsiFile(f)) } @@ -508,8 +512,8 @@ $relativePathUnixSeparator """.trimIndent()) - val filePath = myIndicesFixture!!.repositoryHelper.getTestDataPath("local1/junit/junit/4.0/junit-4.0.pom") - val f = LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath) + val filePath = myIndicesFixture!!.repositoryHelper.getTestData("local1/junit/junit/4.0/junit-4.0.pom") + val f = LocalFileSystem.getInstance().refreshAndFindFileByNioFile(filePath) assertResolved(projectPom, findPsiFile(f)) } @@ -551,7 +555,7 @@ $relativePathUnixSeparator @Test fun testResolvingSystemScopeDependencies() = runBlocking { - val libPath = myIndicesFixture!!.repositoryHelper.getTestDataPath("local1/junit/junit/4.0/junit-4.0.jar") + val libPath = myIndicesFixture!!.repositoryHelper.getTestData("local1/junit/junit/4.0/junit-4.0.jar") updateProjectPom("""test project @@ -568,7 +572,7 @@ $libPath """) - assertResolved(projectPom, findPsiFile(LocalFileSystem.getInstance().refreshAndFindFileByPath(libPath))) + assertResolved(projectPom, findPsiFile(LocalFileSystem.getInstance().refreshAndFindFileByNioFile(libPath))) checkHighlighting() } @@ -593,7 +597,7 @@ $libPath @Test fun testDoNotHighlightValidSystemScopeDependencies() = runBlocking { - val libPath = myIndicesFixture!!.repositoryHelper.getTestDataPath("local1/junit/junit/4.0/junit-4.0.jar") + val libPath = myIndicesFixture!!.repositoryHelper.getTestData("local1/junit/junit/4.0/junit-4.0.jar") updateProjectPom("""test project @@ -614,7 +618,7 @@ $libPath @Test fun testResolvingSystemScopeDependenciesWithProperties() = runBlocking { - val libPath = myIndicesFixture!!.repositoryHelper.getTestDataPath("local1/junit/junit/4.0/junit-4.0.jar") + val libPath = myIndicesFixture!!.repositoryHelper.getTestData("local1/junit/junit/4.0/junit-4.0.jar") updateProjectPom("""test project @@ -634,20 +638,20 @@ $libPath """) - assertResolved(projectPom, findPsiFile(LocalFileSystem.getInstance().refreshAndFindFileByPath(libPath))) + assertResolved(projectPom, findPsiFile(LocalFileSystem.getInstance().refreshAndFindFileByNioFile(libPath))) checkHighlighting() } @Test fun testCompletionSystemScopeDependenciesWithProperties() = runBlocking { - val libPath = myIndicesFixture!!.repositoryHelper.getTestDataPath("local1/junit/junit/4.0/junit-4.0.jar") + val libPath = myIndicesFixture!!.repositoryHelper.getTestData("local1/junit/junit/4.0/junit-4.0.jar") updateProjectPom("""test project 1 -${File(libPath).getParent()} +${libPath.parent} @@ -665,7 +669,7 @@ ${File(libPath).getParent()} @Test fun testResolvingSystemScopeDependenciesFromSystemPath() = runBlocking { - val libPath = myIndicesFixture!!.repositoryHelper.getTestDataPath("local1/junit/junit/4.0/junit-4.0.jar") + val libPath = myIndicesFixture!!.repositoryHelper.getTestData("local1/junit/junit/4.0/junit-4.0.jar") updateProjectPom("""test project @@ -682,7 +686,7 @@ $libPath """) - assertResolved(projectPom, findPsiFile(LocalFileSystem.getInstance().refreshAndFindFileByPath(libPath))) + assertResolved(projectPom, findPsiFile(LocalFileSystem.getInstance().refreshAndFindFileByNioFile(libPath))) checkHighlighting() } @@ -705,8 +709,8 @@ $libPath val action = getIntentionAtCaret("Choose File") assertNotNull(action) - val libPath = myIndicesFixture!!.repositoryHelper.getTestDataPath("local1/junit/junit/4.0/junit-4.0.jar") - val libFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(libPath) + val libPath = myIndicesFixture!!.repositoryHelper.getTestData("local1/junit/junit/4.0/junit-4.0.jar") + val libFile = LocalFileSystem.getInstance().refreshAndFindFileByNioFile(libPath) val intentionAction = IntentionActionDelegate.unwrap(action!!) (intentionAction as ChooseFileIntentionAction).setFileChooser { arrayOf(libFile) } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenExtensionCompletionAndResolutionTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenExtensionCompletionAndResolutionTest.kt index 73ae725eaba8..594a025ccc83 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenExtensionCompletionAndResolutionTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenExtensionCompletionAndResolutionTest.kt @@ -134,8 +134,8 @@ class MavenExtensionCompletionAndResolutionTest : MavenDomWithIndicesTestCase() val pluginVersion = getDefaultPluginVersion("org.apache.maven:maven-compiler-plugin") val pluginPath = "plugins/org/apache/maven/plugins/maven-compiler-plugin/$pluginVersion/maven-compiler-plugin-$pluginVersion.pom" - val filePath = myIndicesFixture!!.repositoryHelper.getTestDataPath(pluginPath) - val f = LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath) + val filePath = myIndicesFixture!!.repositoryHelper.getTestData(pluginPath) + val f = LocalFileSystem.getInstance().refreshAndFindFileByNioFile(filePath) assertNotNull("file: $filePath not exists!", f) assertResolved(projectPom, findPsiFile(f)) } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenParentCompletionAndResolutionTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenParentCompletionAndResolutionTest.kt index f099164ae4bf..5bfeaafb01bc 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenParentCompletionAndResolutionTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenParentCompletionAndResolutionTest.kt @@ -117,8 +117,8 @@ class MavenParentCompletionAndResolutionTest : MavenDomWithIndicesTestCase() { """.trimIndent()) - val filePath = myIndicesFixture!!.repositoryHelper.getTestDataPath("local1/junit/junit/4.0/junit-4.0.pom") - val f = LocalFileSystem.getInstance().findFileByPath(filePath) + val filePath = myIndicesFixture!!.repositoryHelper.getTestData("local1/junit/junit/4.0/junit-4.0.pom") + val f = LocalFileSystem.getInstance().findFileByNioFile(filePath) assertResolved(projectPom, findPsiFile(f)) } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPluginCompletionAndResolutionTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPluginCompletionAndResolutionTest.kt index bb3e5dda56fc..b9efbfeafe18 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPluginCompletionAndResolutionTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPluginCompletionAndResolutionTest.kt @@ -112,8 +112,8 @@ class MavenPluginCompletionAndResolutionTest : MavenDomWithIndicesTestCase() { val pluginPath = "plugins/org/apache/maven/plugins/maven-surefire-plugin/2.12.4/maven-surefire-plugin-2.12.4.pom" - val filePath = myIndicesFixture!!.repositoryHelper.getTestDataPath(pluginPath) - val f = LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath) + val filePath = myIndicesFixture!!.repositoryHelper.getTestData(pluginPath) + val f = LocalFileSystem.getInstance().refreshAndFindFileByNioFile(filePath) assertNotNull("file: $filePath not exists!", f) assertResolved(projectPom, findPsiFile(f)) } @@ -226,8 +226,8 @@ class MavenPluginCompletionAndResolutionTest : MavenDomWithIndicesTestCase() { val pluginPath = "plugins/org/apache/maven/plugins/maven-compiler-plugin/$pluginVersion/maven-compiler-plugin-$pluginVersion.pom" - val filePath = myIndicesFixture!!.repositoryHelper.getTestDataPath(pluginPath) - val f = LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath) + val filePath = myIndicesFixture!!.repositoryHelper.getTestData(pluginPath) + val f = LocalFileSystem.getInstance().refreshAndFindFileByNioFile(filePath) assertNotNull("file: $filePath not exists!", f) assertResolved(projectPom, findPsiFile(f)) } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyCompletionAndResolutionTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyCompletionAndResolutionTest.kt index 0c1302978b19..8d6070ef071c 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyCompletionAndResolutionTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyCompletionAndResolutionTest.kt @@ -687,7 +687,7 @@ class MavenPropertyCompletionAndResolutionTest : MavenDomTestCase() { fun testResolvingSettingsModelProperties() = runBlocking { val profiles = updateSettingsXml(""" - ${repositoryPath} + ${repositoryFile} """.trimIndent()) updateProjectPom(""" diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenRelativePathResolutionTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenRelativePathResolutionTest.kt index ccad572f6157..991296c61183 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenRelativePathResolutionTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenRelativePathResolutionTest.kt @@ -21,11 +21,11 @@ class MavenRelativePathResolutionTest : MavenDomWithIndicesTestCase() { @Test fun testParentRelativePathOutsideProjectRoot() = runBlocking { - val file = myIndicesFixture!!.repositoryHelper.getTestDataLegacy("local1/org/example/example/1.0/example-1.0.pom") + val file = myIndicesFixture!!.repositoryHelper.getTestData("local1/org/example/example/1.0/example-1.0.pom") val relativePathUnixSeparator = - FileUtil.getRelativePath(File(projectRoot.getPath()), file)!!.replace("\\\\".toRegex(), "/") + FileUtil.getRelativePath(projectRoot.getPath(), file.toString(), File.separatorChar)!!.replace("\\\\".toRegex(), "/") val pom = createProjectPom("""test project @@ -44,7 +44,7 @@ $relativePathUnixSeparator val resolved = readAction { fixture.getElementAtCaret() } assertTrue(resolved is XmlFileImpl) - val f = LocalFileSystem.getInstance().refreshAndFindFileByPath(file.path) + val f = LocalFileSystem.getInstance().refreshAndFindFileByNioFile(file) val parentPsi = findPsiFile(f) assertResolved(projectPom, parentPsi) assertSame(parentPsi, resolved) @@ -53,13 +53,15 @@ $relativePathUnixSeparator @Test fun testParentRelativePathOutsideProjectRootWithDir() = runBlocking { - val file = myIndicesFixture!!.repositoryHelper.getTestDataLegacy("local1/org/example/example/1.0/pom.xml") + val file = myIndicesFixture!!.repositoryHelper.getTestData("local1/org/example/example/1.0/pom.xml") - val parentFile = file.getParentFile() + val parentFile = file.parent - - val relativePathUnixSeparator = - FileUtil.getRelativePath(File(projectRoot.getPath()), parentFile)!!.replace("\\\\".toRegex(), "/") + val relativePathUnixSeparator = FileUtil.getRelativePath( + projectRoot.getPath(), + parentFile.toString(), + File.separatorChar + )!!.replace("\\\\".toRegex(), "/") val pom = createProjectPom("""test project @@ -77,7 +79,7 @@ $relativePathUnixSeparator val resolved = readAction { fixture.getElementAtCaret() } assertTrue(resolved is XmlFileImpl) - val f = LocalFileSystem.getInstance().refreshAndFindFileByPath(file.path) + val f = LocalFileSystem.getInstance().refreshAndFindFileByNioFile(file) val parentPsi = findPsiFile(f) assertResolved(projectPom, parentPsi) assertSame(parentPsi, resolved) diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenClasspathsAndSearchScopesTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenClasspathsAndSearchScopesTest.kt index eef134885049..4e536ae97788 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenClasspathsAndSearchScopesTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenClasspathsAndSearchScopesTest.kt @@ -543,42 +543,42 @@ class MavenClasspathsAndSearchScopesTest : MavenMultiVersionImportingTestCase() assertAllProductionSearchScope("m1", "$projectPath/m1/src/main/java", "$projectPath/m2/src/main/java", - "$repositoryPath/jmock/jmock/1.0/jmock-1.0.jar") + "$repositoryFile/jmock/jmock/1.0/jmock-1.0.jar") assertAllTestsSearchScope("m1", "$projectPath/m1/src/main/java", "$projectPath/m1/src/test/java", "$projectPath/m2/src/main/java", - "$repositoryPath/jmock/jmock/1.0/jmock-1.0.jar") + "$repositoryFile/jmock/jmock/1.0/jmock-1.0.jar") assertAllProductionClasspath("m1", "$projectPath/m1/target/classes", "$projectPath/m2/target/classes", - "$repositoryPath/jmock/jmock/1.0/jmock-1.0.jar") + "$repositoryFile/jmock/jmock/1.0/jmock-1.0.jar") assertAllTestsClasspath("m1", "$projectPath/m1/target/test-classes", "$projectPath/m1/target/classes", "$projectPath/m2/target/classes", - "$repositoryPath/jmock/jmock/1.0/jmock-1.0.jar") + "$repositoryFile/jmock/jmock/1.0/jmock-1.0.jar") assertAllProductionSearchScope("m2", "$projectPath/m2/src/main/java", - "$repositoryPath/jmock/jmock/1.0/jmock-1.0.jar", - "$repositoryPath/junit/junit/4.0/junit-4.0.jar") + "$repositoryFile/jmock/jmock/1.0/jmock-1.0.jar", + "$repositoryFile/junit/junit/4.0/junit-4.0.jar") assertAllTestsSearchScope("m2", "$projectPath/m2/src/main/java", "$projectPath/m2/src/test/java", - "$repositoryPath/jmock/jmock/1.0/jmock-1.0.jar", - "$repositoryPath/junit/junit/4.0/junit-4.0.jar") + "$repositoryFile/jmock/jmock/1.0/jmock-1.0.jar", + "$repositoryFile/junit/junit/4.0/junit-4.0.jar") assertAllProductionClasspath("m2", "$projectPath/m2/target/classes", - "$repositoryPath/jmock/jmock/1.0/jmock-1.0.jar", - "$repositoryPath/junit/junit/4.0/junit-4.0.jar") + "$repositoryFile/jmock/jmock/1.0/jmock-1.0.jar", + "$repositoryFile/junit/junit/4.0/junit-4.0.jar") assertAllTestsClasspath("m2", "$projectPath/m2/target/test-classes", "$projectPath/m2/target/classes", - "$repositoryPath/jmock/jmock/1.0/jmock-1.0.jar", - "$repositoryPath/junit/junit/4.0/junit-4.0.jar") + "$repositoryFile/jmock/jmock/1.0/jmock-1.0.jar", + "$repositoryFile/junit/junit/4.0/junit-4.0.jar") } @Test @@ -641,32 +641,32 @@ class MavenClasspathsAndSearchScopesTest : MavenMultiVersionImportingTestCase() assertCompileProductionSearchScope("m1", "$projectPath/m1/src/main/java", "$projectPath/m2/src/main/java", - "$repositoryPath/junit/junit/4.0/junit-4.0.jar") + "$repositoryFile/junit/junit/4.0/junit-4.0.jar") assertRuntimeProductionSearchScope("m1", "$projectPath/m1/src/main/java", "$projectPath/m2/src/main/java", - "$repositoryPath/junit/junit/4.0/junit-4.0.jar") + "$repositoryFile/junit/junit/4.0/junit-4.0.jar") assertAllTestsSearchScope("m1", "$projectPath/m1/src/main/java", "$projectPath/m1/src/test/java", "$projectPath/m2/src/main/java", - "$repositoryPath/junit/junit/4.0/junit-4.0.jar", + "$repositoryFile/junit/junit/4.0/junit-4.0.jar", "$projectPath/m3/src/main/java", - "$repositoryPath/jmock/jmock/4.0/jmock-4.0.jar") + "$repositoryFile/jmock/jmock/4.0/jmock-4.0.jar") assertCompileProductionClasspath("m1", "$projectPath/m1/target/classes", "$projectPath/m2/target/classes", - "$repositoryPath/junit/junit/4.0/junit-4.0.jar") + "$repositoryFile/junit/junit/4.0/junit-4.0.jar") assertRuntimeProductionClasspath("m1", "$projectPath/m1/target/classes") assertAllTestsClasspath("m1", "$projectPath/m1/target/test-classes", "$projectPath/m1/target/classes", "$projectPath/m2/target/classes", - "$repositoryPath/junit/junit/4.0/junit-4.0.jar", + "$repositoryFile/junit/junit/4.0/junit-4.0.jar", "$projectPath/m3/target/classes", - "$repositoryPath/jmock/jmock/4.0/jmock-4.0.jar") + "$repositoryFile/jmock/jmock/4.0/jmock-4.0.jar") } @Test @@ -712,12 +712,12 @@ class MavenClasspathsAndSearchScopesTest : MavenMultiVersionImportingTestCase() assertRuntimeProductionSearchScope("m1", "$projectPath/m1/src/main/java", "$projectPath/m2/src/main/java", - "$repositoryPath/junit/junit/4.0/junit-4.0.jar") + "$repositoryFile/junit/junit/4.0/junit-4.0.jar") assertAllTestsSearchScope("m1", "$projectPath/m1/src/main/java", "$projectPath/m1/src/test/java", "$projectPath/m2/src/main/java", - "$repositoryPath/junit/junit/4.0/junit-4.0.jar") + "$repositoryFile/junit/junit/4.0/junit-4.0.jar") assertCompileProductionClasspath("m1", "$projectPath/m1/target/classes") @@ -725,13 +725,13 @@ class MavenClasspathsAndSearchScopesTest : MavenMultiVersionImportingTestCase() assertRuntimeProductionClasspath("m1", "$projectPath/m1/target/classes", "$projectPath/m2/target/classes", - "$repositoryPath/junit/junit/4.0/junit-4.0.jar") + "$repositoryFile/junit/junit/4.0/junit-4.0.jar") assertAllTestsClasspath("m1", "$projectPath/m1/target/test-classes", "$projectPath/m1/target/classes", "$projectPath/m2/target/classes", - "$repositoryPath/junit/junit/4.0/junit-4.0.jar") + "$repositoryFile/junit/junit/4.0/junit-4.0.jar") } @Test @@ -802,26 +802,26 @@ class MavenClasspathsAndSearchScopesTest : MavenMultiVersionImportingTestCase() assertCompileProductionSearchScope("m2", "$projectPath/m2/src/main/java", - "$repositoryPath/jmock/jmock/1.0/jmock-1.0.jar") + "$repositoryFile/jmock/jmock/1.0/jmock-1.0.jar") assertRuntimeProductionSearchScope("m2", "$projectPath/m2/src/main/java", - "$repositoryPath/jmock/jmock/1.0/jmock-1.0.jar") + "$repositoryFile/jmock/jmock/1.0/jmock-1.0.jar") assertAllTestsSearchScope("m2", "$projectPath/m2/src/main/java", "$projectPath/m2/src/test/java", - "$repositoryPath/jmock/jmock/1.0/jmock-1.0.jar", - "$repositoryPath/junit/junit/4.0/junit-4.0.jar") + "$repositoryFile/jmock/jmock/1.0/jmock-1.0.jar", + "$repositoryFile/junit/junit/4.0/junit-4.0.jar") assertCompileProductionClasspath("m2", "$projectPath/m2/target/classes", - "$repositoryPath/jmock/jmock/1.0/jmock-1.0.jar") + "$repositoryFile/jmock/jmock/1.0/jmock-1.0.jar") assertRuntimeProductionClasspath("m2", "$projectPath/m2/target/classes") assertAllTestsClasspath("m2", "$projectPath/m2/target/test-classes", "$projectPath/m2/target/classes", - "$repositoryPath/jmock/jmock/1.0/jmock-1.0.jar", - "$repositoryPath/junit/junit/4.0/junit-4.0.jar") + "$repositoryFile/jmock/jmock/1.0/jmock-1.0.jar", + "$repositoryFile/junit/junit/4.0/junit-4.0.jar") } @Test @@ -869,8 +869,8 @@ class MavenClasspathsAndSearchScopesTest : MavenMultiVersionImportingTestCase() "$projectPath/m2/src/test/java" ) - val libraryPath = "$repositoryPath/junit/junit/4.0/junit-4.0.jar" - val librarySrcPath = "$repositoryPath/junit/junit/4.0/junit-4.0-sources.jar" + val libraryPath = "$repositoryFile/junit/junit/4.0/junit-4.0.jar" + val librarySrcPath = "$repositoryFile/junit/junit/4.0/junit-4.0-sources.jar" val m2m = getInstance(project).findModuleByName("m2") val modules2: List = ArrayList() ModuleRootManager.getInstance(m2m!!).orderEntries().withoutSdk().withoutModuleSourceEntries().forEach( @@ -948,14 +948,14 @@ class MavenClasspathsAndSearchScopesTest : MavenMultiVersionImportingTestCase() "$projectPath/m1/src/main/java", "$projectPath/m1/src/test/java", "$projectPath/m2/src/main/java", - "$repositoryPath/junit/junit/4.0/junit-4.0.jar", + "$repositoryFile/junit/junit/4.0/junit-4.0.jar", "$projectPath/m3/src/main/java") assertAllTestsClasspath("m1", "$projectPath/m1/target/test-classes", "$projectPath/m1/target/classes", "$projectPath/m2/target/classes", - "$repositoryPath/junit/junit/4.0/junit-4.0.jar", + "$repositoryFile/junit/junit/4.0/junit-4.0.jar", "$projectPath/m3/target/classes") } @@ -1019,7 +1019,7 @@ class MavenClasspathsAndSearchScopesTest : MavenMultiVersionImportingTestCase() assertCompileProductionClasspath("user", "$projectPath/user/output", "$projectPath/m1/target/classes", - "$repositoryPath/junit/junit/4.0/junit-4.0.jar") + "$repositoryFile/junit/junit/4.0/junit-4.0.jar") assertRuntimeProductionClasspath("user", "$projectPath/user/output", @@ -1031,7 +1031,7 @@ class MavenClasspathsAndSearchScopesTest : MavenMultiVersionImportingTestCase() "$projectPath/user/output", "$projectPath/m1/target/test-classes", "$projectPath/m1/target/classes", - "$repositoryPath/junit/junit/4.0/junit-4.0.jar") + "$repositoryFile/junit/junit/4.0/junit-4.0.jar") assertRuntimeTestsClasspath("user", "$projectPath/user/test-output", @@ -1040,11 +1040,11 @@ class MavenClasspathsAndSearchScopesTest : MavenMultiVersionImportingTestCase() "$projectPath/m1/target/classes", "$projectPath/m2/target/test-classes", "$projectPath/m2/target/classes", - "$repositoryPath/junit/junit/4.0/junit-4.0.jar") + "$repositoryFile/junit/junit/4.0/junit-4.0.jar") assertCompileProductionClasspath("m1", "$projectPath/m1/target/classes", - "$repositoryPath/junit/junit/4.0/junit-4.0.jar") + "$repositoryFile/junit/junit/4.0/junit-4.0.jar") assertRuntimeProductionClasspath("m1", "$projectPath/m1/target/classes", "$projectPath/m2/target/classes") @@ -1052,7 +1052,7 @@ class MavenClasspathsAndSearchScopesTest : MavenMultiVersionImportingTestCase() "$projectPath/m1/target/test-classes", "$projectPath/m1/target/classes", "$projectPath/m2/target/classes", - "$repositoryPath/junit/junit/4.0/junit-4.0.jar") + "$repositoryFile/junit/junit/4.0/junit-4.0.jar") } @Test @@ -1215,7 +1215,7 @@ $scope val m6E3 = m6OrderEntries[3] UsefulTestCase.assertInstanceOf(m6E3, ModuleSourceOrderEntry::class.java) - val jmockDir = VfsUtil.findFileByIoFile(File(repositoryPath, "jmock/jmock/1.0/jmock-1.0.jar"), true) + val jmockDir = VfsUtil.findFile(repositoryFile.resolve("jmock/jmock/1.0/jmock-1.0.jar"), true) assertNotNull(jmockDir) val jmockJar = JarFileSystem.getInstance().getJarRootForLocalFile(jmockDir!!) assertNotNull(jmockJar) @@ -1264,7 +1264,7 @@ $scope val m6E2 = m6OrderEntries[2] UsefulTestCase.assertInstanceOf(m6E2, ModuleSourceOrderEntry::class.java) - val jmockDir = VfsUtil.findFileByIoFile(File(repositoryPath, "jmock/jmock/1.0/jmock-1.0.jar"), true) + val jmockDir = VfsUtil.findFile(repositoryFile.resolve("jmock/jmock/1.0/jmock-1.0.jar"), true) assertNotNull(jmockDir) val jmockJar = JarFileSystem.getInstance().getJarRootForLocalFile(jmockDir!!) assertNotNull(jmockJar) @@ -1476,7 +1476,7 @@ $scope f.parent.createDirectories() createEmptyJar(f.parent.toString(), f.fileName.toString()) - repositoryPath = createProjectSubDir("repo").path + repositoryFile = createProjectSubDir("repo").toNioPath() } private fun createOutputDirectories() { diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/ArtifactsDownloadingTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/ArtifactsDownloadingTest.kt index 8edf53acaddc..991ba7027a0f 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/ArtifactsDownloadingTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/ArtifactsDownloadingTest.kt @@ -21,7 +21,7 @@ import kotlinx.coroutines.runBlocking import org.jetbrains.idea.maven.model.MavenId import org.jetbrains.idea.maven.server.MavenServerManager import org.junit.Test -import java.io.File +import kotlin.io.path.exists class ArtifactsDownloadingTest : ArtifactsDownloadingTestCase() { @@ -40,8 +40,8 @@ class ArtifactsDownloadingTest : ArtifactsDownloadingTestCase() { """.trimIndent()) - val sources = File(repositoryPath, "/junit/junit/4.0/junit-4.0-sources.jar") - val javadoc = File(repositoryPath, "/junit/junit/4.0/junit-4.0-javadoc.jar") + val sources = repositoryFile.resolve("junit/junit/4.0/junit-4.0-sources.jar") + val javadoc = repositoryFile.resolve("junit/junit/4.0/junit-4.0-javadoc.jar") assertFalse(sources.exists()) assertFalse(javadoc.exists()) @@ -67,8 +67,8 @@ class ArtifactsDownloadingTest : ArtifactsDownloadingTestCase() { """.trimIndent()) - val sources = File(repositoryPath, "/junit/junit/4.0/junit-4.0-sources.jar") - val javadoc = File(repositoryPath, "/junit/junit/4.0/junit-4.0-javadoc.jar") + val sources = repositoryFile.resolve("junit/junit/4.0/junit-4.0-sources.jar") + val javadoc = repositoryFile.resolve("junit/junit/4.0/junit-4.0-javadoc.jar") assertFalse(sources.exists()) assertFalse(javadoc.exists()) @@ -112,8 +112,8 @@ class ArtifactsDownloadingTest : ArtifactsDownloadingTestCase() { """.trimIndent()) - val sources = File(repositoryPath, "/jmock/jmock/1.2.0/jmock-1.2.0-sources.jar") - val javadoc = File(repositoryPath, "/jmock/jmock/1.2.0/jmock-1.2.0-javadoc.jar") + val sources = repositoryFile.resolve("jmock/jmock/1.2.0/jmock-1.2.0-sources.jar") + val javadoc = repositoryFile.resolve("jmock/jmock/1.2.0/jmock-1.2.0-javadoc.jar") assertFalse(sources.exists()) assertFalse(javadoc.exists()) @@ -123,8 +123,8 @@ class ArtifactsDownloadingTest : ArtifactsDownloadingTestCase() { assertTrue(sources.exists()) assertTrue(javadoc.exists()) - assertFalse(File(repositoryPath, "/junit/junit/4.0/junit-4.0-sources.jar").exists()) - assertFalse(File(repositoryPath, "/junit/junit/4.0/junit-4.0-javadoc.jar").exists()) + assertFalse(repositoryFile.resolve("junit/junit/4.0/junit-4.0-sources.jar").exists()) + assertFalse(repositoryFile.resolve("junit/junit/4.0/junit-4.0-javadoc.jar").exists()) } @Test @@ -171,8 +171,8 @@ class ArtifactsDownloadingTest : ArtifactsDownloadingTestCase() { """.trimIndent()) - val sources = File(repositoryPath, "/junit/junit/4.0/junit-4.0-sources.jar") - val javadoc = File(repositoryPath, "/junit/junit/4.0/junit-4.0-javadoc.jar") + val sources = repositoryFile.resolve("junit/junit/4.0/junit-4.0-sources.jar") + val javadoc = repositoryFile.resolve("junit/junit/4.0/junit-4.0-javadoc.jar") assertFalse(sources.exists()) assertFalse(javadoc.exists()) @@ -238,15 +238,15 @@ ${VfsUtilCore.pathToUrl(pathTransformer.toRemotePath(remoteRepo)!!)} """.trimIndent()) - val files1 = listOf(File(repositoryPath, "/xxx/xxx/1/xxx-1-sources.jar"), - File(repositoryPath, "/xxx/xxx/1/xxx-1-javadoc.jar"), - File(repositoryPath, "/xxx/yyy/1/yyy-1-test-sources.jar"), - File(repositoryPath, "/xxx/yyy/1/yyy-1-test-javadoc.jar")) + val files1 = listOf(repositoryFile.resolve("xxx/xxx/1/xxx-1-sources.jar"), + repositoryFile.resolve("xxx/xxx/1/xxx-1-javadoc.jar"), + repositoryFile.resolve("xxx/yyy/1/yyy-1-test-sources.jar"), + repositoryFile.resolve("xxx/yyy/1/yyy-1-test-javadoc.jar")) - val files2 = listOf(File(repositoryPath, "/xxx/xxx/1/xxx-1-foo-sources.jar"), - File(repositoryPath, "/xxx/xxx/1/xxx-1-foo-javadoc.jar"), - File(repositoryPath, "/xxx/zzz/1/zzz-1-test-foo-sources.jar"), - File(repositoryPath, "/xxx/zzz/1/zzz-1-test-foo-javadoc.jar")) + val files2 = listOf(repositoryFile.resolve("xxx/xxx/1/xxx-1-foo-sources.jar"), + repositoryFile.resolve("xxx/xxx/1/xxx-1-foo-javadoc.jar"), + repositoryFile.resolve("xxx/zzz/1/zzz-1-test-foo-sources.jar"), + repositoryFile.resolve("xxx/zzz/1/zzz-1-test-foo-javadoc.jar")) for (each in files1) { assertFalse(each.toString(), each.exists()) @@ -282,7 +282,7 @@ ${VfsUtilCore.pathToUrl(pathTransformer.toRemotePath(remoteRepo)!!)} """.trimIndent()) - val f = File(repositoryPath, "/org/apache/maven/plugins/maven-surefire-plugin/2.4.2/maven-surefire-plugin-2.4.2.jar") + val f = repositoryFile.resolve("org/apache/maven/plugins/maven-surefire-plugin/2.4.2/maven-surefire-plugin-2.4.2.jar") assertTrue(f.exists()) } @@ -294,7 +294,7 @@ ${VfsUtilCore.pathToUrl(pathTransformer.toRemotePath(remoteRepo)!!)} @Test fun DownloadBuildExtensionsOnResolve() = runBlocking { - val f = File(repositoryPath, "/org/apache/maven/wagon/wagon-ftp/2.10/wagon-ftp-2.10.pom") + val f = repositoryFile.resolve("org/apache/maven/wagon/wagon-ftp/2.10/wagon-ftp-2.10.pom") assertFalse(f.exists()) importProjectAsync(""" diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/ArtifactsDownloadingTestCase.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/ArtifactsDownloadingTestCase.kt index 9267b7545ab2..9adaddf7e5c8 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/ArtifactsDownloadingTestCase.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/ArtifactsDownloadingTestCase.kt @@ -16,7 +16,7 @@ abstract class ArtifactsDownloadingTestCase : MavenMultiVersionImportingTestCase super.setUp() val helper = MavenCustomRepositoryHelper(dir, "plugins", "local1") helper.copy("plugins", "local1") - repositoryPath = helper.getTestDataPath("local1") + repositoryFile = helper.getTestData("local1") } protected fun createDummyArtifact(remoteRepo: String, name: String) { diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesImportingExternalChangesTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesImportingExternalChangesTest.kt index d65af96397cb..273366f8a97c 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesImportingExternalChangesTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesImportingExternalChangesTest.kt @@ -31,21 +31,21 @@ class DependenciesImportingExternalChangesTest : MavenMultiVersionImportingTestC assertModuleLibDeps("project", "Maven: junit:junit:4.0") assertModuleLibDep("project", "Maven: junit:junit:4.0", - "jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0.jar!/", - "jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0-sources.jar!/", - "jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0-javadoc.jar!/") + "jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0.jar!/", + "jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0-sources.jar!/", + "jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0-javadoc.jar!/") waitForImportWithinTimeout { - repositoryPath = dir.resolve("__repo").toString() + repositoryFile = dir.resolve("__repo") } projectsManager.embeddersManager.reset() // to recognize repository change updateAllProjects() assertModuleLibDep("project", "Maven: junit:junit:4.0", - "jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0.jar!/", - "jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0-sources.jar!/", - "jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0-javadoc.jar!/") + "jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0.jar!/", + "jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0-sources.jar!/", + "jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0-javadoc.jar!/") } @Test @@ -66,20 +66,20 @@ class DependenciesImportingExternalChangesTest : MavenMultiVersionImportingTestC assertModuleLibDeps("project", "Maven: org.testng:testng:jdk15:5.8", "Maven: junit:junit:3.8.1") assertModuleLibDep("project", "Maven: org.testng:testng:jdk15:5.8", - "jar://" + repositoryPath + "/org/testng/testng/5.8/testng-5.8-jdk15.jar!/", - "jar://" + repositoryPath + "/org/testng/testng/5.8/testng-5.8-sources.jar!/", - "jar://" + repositoryPath + "/org/testng/testng/5.8/testng-5.8-javadoc.jar!/") + "jar://" + repositoryFile + "/org/testng/testng/5.8/testng-5.8-jdk15.jar!/", + "jar://" + repositoryFile + "/org/testng/testng/5.8/testng-5.8-sources.jar!/", + "jar://" + repositoryFile + "/org/testng/testng/5.8/testng-5.8-javadoc.jar!/") waitForImportWithinTimeout { - repositoryPath = dir.resolve("__repo").toString() + repositoryFile = dir.resolve("__repo") } projectsManager.embeddersManager.reset() // to recognize repository change updateAllProjects() assertModuleLibDep("project", "Maven: org.testng:testng:jdk15:5.8", - "jar://" + repositoryPath + "/org/testng/testng/5.8/testng-5.8-jdk15.jar!/", - "jar://" + repositoryPath + "/org/testng/testng/5.8/testng-5.8-sources.jar!/", - "jar://" + repositoryPath + "/org/testng/testng/5.8/testng-5.8-javadoc.jar!/") + "jar://" + repositoryFile + "/org/testng/testng/5.8/testng-5.8-jdk15.jar!/", + "jar://" + repositoryFile + "/org/testng/testng/5.8/testng-5.8-sources.jar!/", + "jar://" + repositoryFile + "/org/testng/testng/5.8/testng-5.8-javadoc.jar!/") } } \ No newline at end of file diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesImportingTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesImportingTest.kt index 6725f4b6bd93..781904ebcb8d 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesImportingTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesImportingTest.kt @@ -50,9 +50,9 @@ class DependenciesImportingTest : MavenMultiVersionImportingTestCase() { assertModules("project") assertModuleLibDep("project", "Maven: junit:junit:4.0", - "jar://$repositoryPath/junit/junit/4.0/junit-4.0.jar!/", - "jar://$repositoryPath/junit/junit/4.0/junit-4.0-sources.jar!/", - "jar://$repositoryPath/junit/junit/4.0/junit-4.0-javadoc.jar!/") + "jar://$repositoryFile/junit/junit/4.0/junit-4.0.jar!/", + "jar://$repositoryFile/junit/junit/4.0/junit-4.0-sources.jar!/", + "jar://$repositoryFile/junit/junit/4.0/junit-4.0-javadoc.jar!/") assertProjectLibraryCoordinates("Maven: junit:junit:4.0", "junit", "junit", "4.0") } @@ -69,14 +69,14 @@ class DependenciesImportingTest : MavenMultiVersionImportingTestCase() { 4.0 system - ${repositoryPath}/junit/junit/4.0/junit-4.0.jar + ${repositoryFile}/junit/junit/4.0/junit-4.0.jar """.trimIndent()) assertModules("project") assertModuleLibDep("project", "Maven: junit:junit:4.0", - listOf("jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0.jar!/"), + listOf("jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0.jar!/"), emptyList(), emptyList()) } @@ -98,9 +98,9 @@ class DependenciesImportingTest : MavenMultiVersionImportingTestCase() { assertModules("project") assertModuleLibDep("project", "Maven: junit:junit:test-jar:tests:4.0", - "jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0-tests.jar!/", - "jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0-test-sources.jar!/", - "jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0-test-javadoc.jar!/") + "jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0-tests.jar!/", + "jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0-test-sources.jar!/", + "jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0-test-javadoc.jar!/") assertProjectLibraryCoordinates("Maven: junit:junit:test-jar:tests:4.0", "junit", "junit", "tests", "jar", "4.0") } @@ -121,9 +121,9 @@ class DependenciesImportingTest : MavenMultiVersionImportingTestCase() { """.trimIndent()) assertModules("project") assertModuleLibDep("project", "Maven: junit:junit:bar:4.0", - "jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0-bar.jar!/", - "jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0-sources.jar!/", - "jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0-javadoc.jar!/") + "jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0-bar.jar!/", + "jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0-sources.jar!/", + "jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0-javadoc.jar!/") assertProjectLibraryCoordinates("Maven: junit:junit:bar:4.0", "junit", "junit", "bar", "jar", "4.0") } @@ -299,9 +299,9 @@ class DependenciesImportingTest : MavenMultiVersionImportingTestCase() { assertModuleModuleDeps("m1", "m2") assertModuleLibDep("m1", "Maven: test:m2:client:1", - "jar://" + repositoryPath + "/test/m2/1/m2-1-client.jar!/", - "jar://" + repositoryPath + "/test/m2/1/m2-1-sources.jar!/", - "jar://" + repositoryPath + "/test/m2/1/m2-1-javadoc.jar!/") + "jar://" + repositoryFile + "/test/m2/1/m2-1-client.jar!/", + "jar://" + repositoryFile + "/test/m2/1/m2-1-sources.jar!/", + "jar://" + repositoryFile + "/test/m2/1/m2-1-javadoc.jar!/") } @Test @@ -1433,7 +1433,7 @@ class DependenciesImportingTest : MavenMultiVersionImportingTestCase() { @Test fun testResolvingFromRepositoriesIfSeveral() = runBlocking { val fixture = MavenCustomNioRepositoryHelper(dir, "local1") - repositoryPath = fixture.getTestData("local1").toCanonicalPath() + repositoryFile = fixture.getTestData("local1") removeFromLocalRepository("junit") val file = fixture.getTestData("local1/junit/junit/4.0/junit-4.0.pom") @@ -1463,7 +1463,7 @@ class DependenciesImportingTest : MavenMultiVersionImportingTestCase() { @Test fun testUsingMirrors() = runBlocking { - repositoryPath = dir.resolve("repo").toCanonicalPath() + repositoryFile = dir.resolve("repo") val mirrorPath = pathTransformer.toRemotePath(dir.resolve("mirror").toCanonicalPath()) updateSettingsXmlFully(""" @@ -1703,18 +1703,18 @@ class DependenciesImportingTest : MavenMultiVersionImportingTestCase() { """.trimIndent()) assertModuleLibDep("project", "Maven: junit:junit:4.0", - Arrays.asList("jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0.jar!/"), - Arrays.asList("jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0-sources.jar!/"), - Arrays.asList("jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0-javadoc.jar!/")) + Arrays.asList("jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0.jar!/"), + Arrays.asList("jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0-sources.jar!/"), + Arrays.asList("jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0-javadoc.jar!/")) // update twice updateAllProjects() updateAllProjects() assertModuleLibDep("project", "Maven: junit:junit:4.0", - Arrays.asList("jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0.jar!/"), - Arrays.asList("jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0-sources.jar!/"), - Arrays.asList("jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0-javadoc.jar!/")) + Arrays.asList("jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0.jar!/"), + Arrays.asList("jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0-sources.jar!/"), + Arrays.asList("jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0-javadoc.jar!/")) } @Test @@ -1943,7 +1943,7 @@ class DependenciesImportingTest : MavenMultiVersionImportingTestCase() { createAndAddProjectLibrary("project", "lib") assertProjectLibraries("lib") - addLibraryRoot("lib", OrderRootType.CLASSES, "file://" + repositoryPath + "/foo/bar.jar!/") + addLibraryRoot("lib", OrderRootType.CLASSES, "file://" + repositoryFile + "/foo/bar.jar!/") updateProjectPom(""" test @@ -1966,7 +1966,7 @@ class DependenciesImportingTest : MavenMultiVersionImportingTestCase() { """.trimIndent()) createProjectLibrary("lib") - addLibraryRoot("lib", OrderRootType.CLASSES, "file://" + repositoryPath + "/foo/bar.jar!/") + addLibraryRoot("lib", OrderRootType.CLASSES, "file://" + repositoryFile + "/foo/bar.jar!/") assertProjectLibraries("lib") @@ -2158,8 +2158,8 @@ class DependenciesImportingTest : MavenMultiVersionImportingTestCase() { fun testDoNotFailToConfigureUnresolvedVersionRangeDependencies() = runBlocking { // should not throw NPE when accessing CustomArtifact.getPath(); val helper = MavenCustomNioRepositoryHelper(dir, "local1") - val repoPath = helper.getTestData("local1").toCanonicalPath() - repositoryPath = repoPath + val repoPath = helper.getTestData("local1") + repositoryFile = repoPath importProjectAsync(""" test @@ -2194,8 +2194,8 @@ class DependenciesImportingTest : MavenMultiVersionImportingTestCase() { @Test fun testVersionRangeInDependencyManagementDoesntBreakIndirectDependency() = runBlocking { val helper = MavenCustomNioRepositoryHelper(dir, "local1") - val repoPath = helper.getTestData("local1").toCanonicalPath() - repositoryPath = repoPath + val repoPath = helper.getTestData("local1") + repositoryFile = repoPath createProjectPom(""" test @@ -2289,9 +2289,9 @@ class DependenciesImportingTest : MavenMultiVersionImportingTestCase() { assertModuleLibDeps("m1", "Maven: test:m2:2") assertModuleLibDep("m1", "Maven: test:m2:2", - "jar://" + repositoryPath + "/test/m2/2/m2-2.jar!/", - "jar://" + repositoryPath + "/test/m2/2/m2-2-sources.jar!/", - "jar://" + repositoryPath + "/test/m2/2/m2-2-javadoc.jar!/") + "jar://" + repositoryFile + "/test/m2/2/m2-2.jar!/", + "jar://" + repositoryFile + "/test/m2/2/m2-2-sources.jar!/", + "jar://" + repositoryFile + "/test/m2/2/m2-2-javadoc.jar!/") } @Test @@ -2416,9 +2416,9 @@ class DependenciesImportingTest : MavenMultiVersionImportingTestCase() { assertProjectLibraries("Maven: com.google.guava:guava:15.0") assertModuleLibDep("project", "Maven: com.google.guava:guava:15.0", - "jar://" + repositoryPath + "/com/google/guava/guava/15.0/guava-15.0.jar!/", - "jar://" + repositoryPath + "/com/google/guava/guava/15.0/guava-15.0-sources.jar!/", - "jar://" + repositoryPath + "/com/google/guava/guava/15.0/guava-15.0-javadoc.jar!/") + "jar://" + repositoryFile + "/com/google/guava/guava/15.0/guava-15.0.jar!/", + "jar://" + repositoryFile + "/com/google/guava/guava/15.0/guava-15.0-sources.jar!/", + "jar://" + repositoryFile + "/com/google/guava/guava/15.0/guava-15.0-javadoc.jar!/") } @Test @@ -2469,14 +2469,14 @@ class DependenciesImportingTest : MavenMultiVersionImportingTestCase() { updateAllProjects() assertModuleLibDep("project", "Maven: junit:junit:4.0", - "jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0.jar!/", - "jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0-sources.jar!/", - "jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0-javadoc.jar!/") + "jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0.jar!/", + "jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0-sources.jar!/", + "jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0-javadoc.jar!/") assertModuleLibDep(mn("project", "m1"), "Maven: junit:junit:4.0", - "jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0.jar!/", - "jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0-sources.jar!/", - "jar://" + repositoryPath + "/junit/junit/4.0/junit-4.0-javadoc.jar!/") + "jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0.jar!/", + "jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0-sources.jar!/", + "jar://" + repositoryFile + "/junit/junit/4.0/junit-4.0-javadoc.jar!/") } @Test diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesManagementTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesManagementTest.kt index 9baa5b1e2791..f89d6bff6d9e 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesManagementTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesManagementTest.kt @@ -24,10 +24,10 @@ class DependenciesManagementTest : MavenMultiVersionImportingTestCase() { fun testImportingDependencies() = runBlocking { if (!hasMavenInstallation()) return@runBlocking - repositoryPath = dir.resolve("repo").toString() + repositoryFile = dir.resolve("repo") updateSettingsXml(""" - ${repositoryPath} + ${repositoryFile} """.trimIndent()) createModulePom("__temp", @@ -77,10 +77,10 @@ class DependenciesManagementTest : MavenMultiVersionImportingTestCase() { @Test fun testImportingNotInstalledDependencies() = runBlocking { - repositoryPath = dir.resolve("repo").toString() + repositoryFile = dir.resolve("repo") updateSettingsXml(""" - ${repositoryPath} + ${repositoryFile} """.trimIndent()) val bom = createModulePom("bom", diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/FoldersImportingTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/FoldersImportingTest.kt index cbd2a5ca8886..1c225c609813 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/FoldersImportingTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/FoldersImportingTest.kt @@ -35,6 +35,7 @@ import org.junit.Test import java.io.File import java.io.IOException import java.util.function.Consumer +import kotlin.io.path.exists class FoldersImportingTest : MavenMultiVersionImportingTestCase() { @@ -760,9 +761,8 @@ class FoldersImportingTest : MavenMultiVersionImportingTestCase() { fun testDownloadingNecessaryPlugins() = runBlocking { try { val helper = MavenCustomRepositoryHelper(dir, "local1") - repositoryPath = helper.getTestDataPath("local1") - val pluginFile = File(repositoryPath, - "org/codehaus/mojo/build-helper-maven-plugin/1.2/build-helper-maven-plugin-1.2.jar") + repositoryFile = helper.getTestData("local1") + val pluginFile = repositoryFile.resolve("org/codehaus/mojo/build-helper-maven-plugin/1.2/build-helper-maven-plugin-1.2.jar") assertFalse(pluginFile.exists()) importProjectAsync(""" test diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/GroovyImporterTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/GroovyImporterTest.kt index 3646aaaece2c..b82d18ae4b5b 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/GroovyImporterTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/GroovyImporterTest.kt @@ -6,23 +6,21 @@ import com.intellij.openapi.application.edtWriteAction import com.intellij.openapi.externalSystem.service.project.ProjectDataManager import com.intellij.openapi.roots.OrderRootType import com.intellij.openapi.vfs.LocalFileSystem +import com.intellij.testFramework.utils.io.createFile +import com.intellij.util.io.createDirectories import kotlinx.coroutines.runBlocking import org.jetbrains.idea.maven.project.MavenFolderResolver import org.jetbrains.idea.maven.server.MavenServerManager import org.jetbrains.plugins.groovy.compiler.GreclipseIdeaCompilerSettings import org.jetbrains.plugins.groovy.config.GroovyConfigUtils import org.junit.Test -import java.io.File -import java.nio.file.Paths +import java.nio.file.Path class GroovyImporterTest : MavenMultiVersionImportingTestCase() { - private var repoPath: String? = null - override fun setUp() { super.setUp() - repoPath = Paths.get(dir.toString(), "repo").toString() - repositoryPath = repoPath + repositoryFile = dir.resolve("repo") } @Test @@ -76,7 +74,7 @@ class GroovyImporterTest : MavenMultiVersionImportingTestCase() { val library = libraries[0] assertUnorderedPathsAreEqual( listOf(*library.getUrls(OrderRootType.CLASSES)), - listOf("jar://$repositoryPath/org/codehaus/groovy/groovy-all-minimal/1.5.6/groovy-all-minimal-1.5.6.jar!/")) + listOf("jar://$repositoryFile/org/codehaus/groovy/groovy-all-minimal/1.5.6/groovy-all-minimal-1.5.6.jar!/")) } @Test @@ -165,10 +163,10 @@ class GroovyImporterTest : MavenMultiVersionImportingTestCase() { @Test fun testGroovyEclipsePlugin() = runBlocking { - val batchDir = File(repoPath, "org/codehaus/groovy/groovy-eclipse-batch/2.1.3-01/") - batchDir.mkdirs() - val batchJar = File(batchDir, "groovy-eclipse-batch-2.1.3-01.jar") - batchJar.createNewFile() + val batchDir = repositoryFile.resolve("org/codehaus/groovy/groovy-eclipse-batch/2.1.3-01/") + batchDir.createDirectories() + val batchJar = batchDir.resolve("groovy-eclipse-batch-2.1.3-01.jar") + batchJar.createFile() importProjectAsync(""" testproject1 @@ -225,16 +223,18 @@ class GroovyImporterTest : MavenMultiVersionImportingTestCase() { val compilerSettings = project.getService( GreclipseIdeaCompilerSettings::class.java) - assertEquals(LocalFileSystem.getInstance().findFileByIoFile(batchJar)!!.getPath(), compilerSettings.state!!.greclipsePath) + assertEquals( + LocalFileSystem.getInstance().findFileByNioFile(batchJar)!!.toNioPath(), + Path.of(compilerSettings.state!!.greclipsePath) + ) } @Test fun testGroovyEclipsePluginWhenOnlyCompilerDependency() = runBlocking { - val batchDir = File(repoPath, "org/codehaus/groovy/groovy-eclipse-batch/2.1.3-01/") - batchDir.mkdirs() - val batchJar = File(batchDir, "groovy-eclipse-batch-2.1.3-01.jar") - batchJar.createNewFile() - + val batchDir = repositoryFile.resolve("org/codehaus/groovy/groovy-eclipse-batch/2.1.3-01/") + batchDir.createDirectories() + val batchJar = batchDir.resolve("groovy-eclipse-batch-2.1.3-01.jar") + batchJar.createFile() importProjectAsync(""" testproject1 @@ -283,9 +283,11 @@ class GroovyImporterTest : MavenMultiVersionImportingTestCase() { "src/test/java") assertDefaultTestResources("project") - val compilerSettings = project.getService( - GreclipseIdeaCompilerSettings::class.java) - assertEquals(LocalFileSystem.getInstance().findFileByIoFile(batchJar)!!.getPath(), compilerSettings.state!!.greclipsePath) + val compilerSettings = project.getService(GreclipseIdeaCompilerSettings::class.java) + assertEquals( + LocalFileSystem.getInstance().findFileByNioFile(batchJar)!!.toNioPath(), + Path.of(compilerSettings.state!!.greclipsePath) + ) } @Test diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/InvalidProjectImportingTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/InvalidProjectImportingTest.kt index 0a01213c9e78..f91d0ed5d13f 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/InvalidProjectImportingTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/InvalidProjectImportingTest.kt @@ -832,9 +832,9 @@ class InvalidProjectImportingTest : MavenMultiVersionImportingTestCase() { @Test fun testDoNotReportResolvedPlugins() = runBlocking { - val helper = MavenCustomRepositoryHelper(dir.toFile(), "plugins") + val helper = MavenCustomRepositoryHelper(dir, "plugins") - repositoryPath = helper.getTestDataPath("plugins") + repositoryFile = helper.getTestData("plugins") importProjectAsync(""" test diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenRepositoriesDownloadingTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenRepositoriesDownloadingTest.kt index d44aa6fd4b74..70e18878a901 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenRepositoriesDownloadingTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenRepositoriesDownloadingTest.kt @@ -4,6 +4,7 @@ package org.jetbrains.idea.maven.importing import com.intellij.maven.testFramework.MavenMultiVersionImportingTestCase import com.intellij.maven.testFramework.utils.MavenHttpRepositoryServerFixture import com.intellij.openapi.util.registry.Registry +import com.intellij.util.io.createDirectories import junit.framework.TestCase import kotlinx.coroutines.runBlocking import org.intellij.lang.annotations.Language @@ -19,6 +20,8 @@ import java.io.InputStreamReader import java.net.HttpURLConnection import java.net.URL import java.util.stream.Collectors +import kotlin.io.path.isRegularFile +import kotlin.io.path.writeText class MavenRepositoriesDownloadingTest : MavenMultiVersionImportingTestCase() { @@ -71,10 +74,10 @@ class MavenRepositoriesDownloadingTest : MavenMultiVersionImportingTestCase() { @Test fun testDownloadedFromRepository() = runBlocking { val helper = MavenCustomRepositoryHelper(dir, "local1", "remote") - val remoteRepoPath = helper.getTestDataPath("remote") - val localRepoPath = helper.getTestDataPath("local1") - httpServerFixture.startRepositoryFor(remoteRepoPath) - repositoryPath = localRepoPath + val remoteRepoPath = helper.getTestData("remote") + val localRepoPath = helper.getTestData("local1") + httpServerFixture.startRepositoryFor(remoteRepoPath.toString()) + repositoryFile = localRepoPath val settingsXml = createProjectSubFile( "settings.xml", """ @@ -84,20 +87,20 @@ class MavenRepositoriesDownloadingTest : MavenMultiVersionImportingTestCase() { """.trimIndent()) mavenGeneralSettings.setUserSettingsFile(settingsXml.canonicalPath) removeFromLocalRepository("org/mytest/myartifact/") - assertFalse(helper.getTestDataLegacy("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isFile) + assertFalse(helper.getTestData("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isRegularFile()) importProjectAsync(pom()) - assertTrue(helper.getTestDataLegacy("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isFile) - assertFalse(helper.getTestDataLegacy("local1/org/mytest/myartifact/1.0/myartifact-1.0-sources.jar").isFile) + assertTrue(helper.getTestData("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isRegularFile()) + assertFalse(helper.getTestData("local1/org/mytest/myartifact/1.0/myartifact-1.0-sources.jar").isRegularFile()) } @Test fun testDownloadSourcesFromRepository() = runBlocking { val helper = MavenCustomRepositoryHelper(dir, "local1", "remote") - val remoteRepoPath = helper.getTestDataPath("remote") - val localRepoPath = helper.getTestDataPath("local1") - httpServerFixture.startRepositoryFor(remoteRepoPath) - repositoryPath = localRepoPath + val remoteRepoPath = helper.getTestData("remote") + val localRepoPath = helper.getTestData("local1") + httpServerFixture.startRepositoryFor(remoteRepoPath.toString()) + repositoryFile = localRepoPath val settingsXml = createProjectSubFile( "settings.xml", """ @@ -108,19 +111,19 @@ class MavenRepositoriesDownloadingTest : MavenMultiVersionImportingTestCase() { mavenGeneralSettings.setUserSettingsFile(settingsXml.canonicalPath) mavenImporterSettings.isDownloadSourcesAutomatically = true removeFromLocalRepository("org/mytest/myartifact/") - assertFalse(helper.getTestDataLegacy("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isFile) + assertFalse(helper.getTestData("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isRegularFile()) importProjectAsync(pom()) - assertTrue(helper.getTestDataLegacy("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isFile) - assertTrue(helper.getTestDataLegacy("local1/org/mytest/myartifact/1.0/myartifact-1.0-sources.jar").isFile) + assertTrue(helper.getTestData("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isRegularFile()) + assertTrue(helper.getTestData("local1/org/mytest/myartifact/1.0/myartifact-1.0-sources.jar").isRegularFile()) } @Test fun testPluginDownloadedFromRepository() = runBlocking { val helper = MavenCustomRepositoryHelper(dir, "local1", "remote") - val remoteRepoPath = helper.getTestDataPath("remote") - val localRepoPath = helper.getTestDataPath("local1") - httpServerFixture.startRepositoryFor(remoteRepoPath) - repositoryPath = localRepoPath + val remoteRepoPath = helper.getTestData("remote") + val localRepoPath = helper.getTestData("local1") + httpServerFixture.startRepositoryFor(remoteRepoPath.toString()) + repositoryFile = localRepoPath val settingsXml = createProjectSubFile( "settings.xml", """ @@ -130,19 +133,19 @@ class MavenRepositoriesDownloadingTest : MavenMultiVersionImportingTestCase() { """.trimIndent()) mavenGeneralSettings.setUserSettingsFile(settingsXml.canonicalPath) removeFromLocalRepository("org/mytest/myartifact/") - assertFalse(helper.getTestDataLegacy("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isFile) + assertFalse(helper.getTestData("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isRegularFile()) importProjectAsync(pomPlugins()) - assertTrue(helper.getTestDataLegacy("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isFile) + assertTrue(helper.getTestData("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isRegularFile()) } @Test fun testDownloadedFromRepositoryWithAuthentification() = runBlocking { val helper = MavenCustomRepositoryHelper(dir, "local1", "remote") - val remoteRepoPath = helper.getTestDataPath("remote") - val localRepoPath = helper.getTestDataPath("local1") - httpServerFixture.startRepositoryFor(File(remoteRepoPath), USERNAME, PASSWORD) - repositoryPath = localRepoPath + val remoteRepoPath = helper.getTestData("remote") + val localRepoPath = helper.getTestData("local1") + httpServerFixture.startRepositoryFor(remoteRepoPath.toFile(), USERNAME, PASSWORD) + repositoryFile = localRepoPath val settingsXml = createProjectSubFile( "settings.xml", """ @@ -161,18 +164,18 @@ class MavenRepositoriesDownloadingTest : MavenMultiVersionImportingTestCase() { mavenGeneralSettings.setUserSettingsFile(settingsXml.canonicalPath) removeFromLocalRepository("org/mytest/myartifact/") - assertFalse(helper.getTestDataLegacy("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isFile) + assertFalse(helper.getTestData("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isRegularFile()) importProjectAsync(pom()) - assertTrue(helper.getTestDataLegacy("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isFile) + assertTrue(helper.getTestData("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isRegularFile()) } @Test fun testDownloadedFromRepositoryWithWrongAuthentificationLeadsToError() = runBlocking { val helper = MavenCustomRepositoryHelper(dir, "local1", "remote") - val remoteRepoPath = helper.getTestDataPath("remote") - val localRepoPath = helper.getTestDataPath("local1") - httpServerFixture.startRepositoryFor(File(remoteRepoPath), USERNAME, PASSWORD) - repositoryPath = localRepoPath + val remoteRepoPath = helper.getTestData("remote") + val localRepoPath = helper.getTestData("local1") + httpServerFixture.startRepositoryFor(remoteRepoPath.toFile(), USERNAME, PASSWORD) + repositoryFile = localRepoPath val settingsXml = createProjectSubFile( "settings.xml", """ @@ -191,7 +194,7 @@ class MavenRepositoriesDownloadingTest : MavenMultiVersionImportingTestCase() { mavenGeneralSettings.setUserSettingsFile(settingsXml.canonicalPath) removeFromLocalRepository("org/mytest/myartifact/") - assertFalse(helper.getTestDataLegacy("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isFile) + assertFalse(helper.getTestData("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isRegularFile()) createProjectPom(pom()) doImportProjectsAsync(listOf(projectPom), false) TestCase.assertEquals(1, projectsManager.rootProjects.size) @@ -208,10 +211,10 @@ class MavenRepositoriesDownloadingTest : MavenMultiVersionImportingTestCase() { @Test fun `settings xml respected at the very start of the container`() = runBlocking { val helper = MavenCustomRepositoryHelper(dir, "local1", "remote") - val remoteRepoPath = helper.getTestDataPath("remote") - val localRepoPath = helper.getTestDataPath("local1") - httpServerFixture.startRepositoryFor(File(remoteRepoPath), USERNAME, PASSWORD) - repositoryPath = localRepoPath + val remoteRepoPath = helper.getTestData("remote") + val localRepoPath = helper.getTestData("local1") + httpServerFixture.startRepositoryFor(remoteRepoPath.toFile(), USERNAME, PASSWORD) + repositoryFile = localRepoPath @Language(value = "XML") val settingsXmlText = """ $localRepoPath @@ -268,7 +271,7 @@ class MavenRepositoriesDownloadingTest : MavenMultiVersionImportingTestCase() { Registry.get("maven.server.debug").setValue(false) removeFromLocalRepository("org/mytest/myartifact/") - assertFalse(helper.getTestDataLegacy("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isFile) + assertFalse(helper.getTestData("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isRegularFile()) val embedderWrapper = MavenServerManager.getInstance().createEmbedder(project, true, projectRoot.toNioPath().toString()) val embedder = embedderWrapper.getEmbedder() assertTrue("Embedder should be remote object: got class ${embedder.javaClass.name}", embedder.javaClass.name.contains("\$Proxy")) @@ -311,15 +314,15 @@ class MavenRepositoriesDownloadingTest : MavenMultiVersionImportingTestCase() { } val helper = MavenCustomRepositoryHelper(dir, "local1", "remote") removeFromLocalRepository("org/mytest/myartifact/") - assertFalse(helper.getTestDataLegacy("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isFile) + assertFalse(helper.getTestData("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isRegularFile()) } private fun doLastUpdatedTest(updateSnapshots: Boolean, pomContent: String, checks: () -> Unit) = runBlocking { val helper = MavenCustomRepositoryHelper(dir, "local1", "remote") - val remoteRepoPath = helper.getTestDataPath("remote") - val localRepoPath = helper.getTestDataPath("local1") - httpServerFixture.startRepositoryFor(remoteRepoPath) - repositoryPath = localRepoPath + val remoteRepoPath = helper.getTestData("remote") + val localRepoPath = helper.getTestData("local1") + httpServerFixture.startRepositoryFor(remoteRepoPath.toString()) + repositoryFile = localRepoPath val settingsXml = createProjectSubFile( "settings.xml", """ @@ -336,11 +339,11 @@ class MavenRepositoriesDownloadingTest : MavenMultiVersionImportingTestCase() { "#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice\n" + "${myUrl.replace(":", "\\:")}/.error=\n" + "${myUrl.replace(":", "\\:")}/.lastUpdated=${System.currentTimeMillis()}\n" - val dir = helper.getTestDataLegacy("local1/org/mytest/myartifact/1.0") - dir.mkdirs() + val dir = helper.getTestData("local1/org/mytest/myartifact/1.0") + dir.createDirectories() - File(dir, "myartifact-1.0.jar.lastUpdated").writeText(lastUpdatedText) - File(dir, "myartifact-1.0.pom.lastUpdated").writeText(lastUpdatedText) + dir.resolve("myartifact-1.0.jar.lastUpdated").writeText(lastUpdatedText) + dir.resolve("myartifact-1.0.pom.lastUpdated").writeText(lastUpdatedText) sendGetRequest("$myUrl/org/mytest/myartifact/1.0/myartifact-1.0.pom") sendGetRequest("$myUrl/org/mytest/myartifact/1.0/myartifact-1.0.pom.sha1") diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenSnapshotDependenciesTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenSnapshotDependenciesTest.kt index 5e8aeaa579cf..e49f980ea311 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenSnapshotDependenciesTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenSnapshotDependenciesTest.kt @@ -34,10 +34,10 @@ class MavenSnapshotDependenciesTest : MavenMultiVersionImportingTestCase() { fun `test incremental sync update snapshot dependency`() = runBlocking { val helper = MavenCustomRepositoryHelper(dir, "local1") helper.addTestData("remote_snapshot/1", "remote") - val remoteRepoPath = helper.getTestDataPath("remote") - val localRepoPath = helper.getTestDataPath("local1") - httpServerFixture.startRepositoryFor(remoteRepoPath) - repositoryPath = localRepoPath + val remoteRepoPath = helper.getTestData("remote") + val localRepoPath = helper.getTestData("local1") + httpServerFixture.startRepositoryFor(remoteRepoPath.toString()) + repositoryFile = localRepoPath val settingsXml = createProjectSubFile( "settings.xml", """ diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenStaticSyncTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenStaticSyncTest.kt index 2982b4c3defc..0d24473f93ff 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenStaticSyncTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenStaticSyncTest.kt @@ -29,9 +29,9 @@ class MavenStaticSyncTest : AbstractMavenStaticSyncTest() { assertModules("project") assertModuleLibDep("project", "Maven: somedep:somedep:4.0", - "jar://" + repositoryPath + "/somedep/somedep/4.0/somedep-4.0.jar!/", - "jar://" + repositoryPath + "/somedep/somedep/4.0/somedep-4.0-sources.jar!/", - "jar://" + repositoryPath + "/somedep/somedep/4.0/somedep-4.0-javadoc.jar!/") + "jar://" + repositoryFile + "/somedep/somedep/4.0/somedep-4.0.jar!/", + "jar://" + repositoryFile + "/somedep/somedep/4.0/somedep-4.0-sources.jar!/", + "jar://" + repositoryFile + "/somedep/somedep/4.0/somedep-4.0-javadoc.jar!/") assertProjectLibraryCoordinates("Maven: somedep:somedep:4.0", "somedep", "somedep", "4.0") } @@ -55,9 +55,9 @@ class MavenStaticSyncTest : AbstractMavenStaticSyncTest() { assertModules("project") assertModuleLibDep("project", "Maven: somedep:somedep:4.0", - "jar://" + repositoryPath + "/somedep/somedep/4.0/somedep-4.0.jar!/", - "jar://" + repositoryPath + "/somedep/somedep/4.0/somedep-4.0-sources.jar!/", - "jar://" + repositoryPath + "/somedep/somedep/4.0/somedep-4.0-javadoc.jar!/") + "jar://" + repositoryFile + "/somedep/somedep/4.0/somedep-4.0.jar!/", + "jar://" + repositoryFile + "/somedep/somedep/4.0/somedep-4.0-sources.jar!/", + "jar://" + repositoryFile + "/somedep/somedep/4.0/somedep-4.0-javadoc.jar!/") assertProjectLibraryCoordinates("Maven: somedep:somedep:4.0", "somedep", "somedep", "4.0") } @@ -82,9 +82,9 @@ class MavenStaticSyncTest : AbstractMavenStaticSyncTest() { assertModules("project") assertModuleLibDep("project", "Maven: somedep:somedep:4.0", - "jar://" + repositoryPath + "/somedep/somedep/4.0/somedep-4.0.jar!/", - "jar://" + repositoryPath + "/somedep/somedep/4.0/somedep-4.0-sources.jar!/", - "jar://" + repositoryPath + "/somedep/somedep/4.0/somedep-4.0-javadoc.jar!/") + "jar://" + repositoryFile + "/somedep/somedep/4.0/somedep-4.0.jar!/", + "jar://" + repositoryFile + "/somedep/somedep/4.0/somedep-4.0-sources.jar!/", + "jar://" + repositoryFile + "/somedep/somedep/4.0/somedep-4.0-javadoc.jar!/") assertProjectLibraryCoordinates("Maven: somedep:somedep:4.0", "somedep", "somedep", "4.0") } @@ -123,9 +123,9 @@ class MavenStaticSyncTest : AbstractMavenStaticSyncTest() { assertModules("project", "m1") assertModuleLibDep("m1", "Maven: somedep:somedep:4.0", - "jar://" + repositoryPath + "/somedep/somedep/4.0/somedep-4.0.jar!/", - "jar://" + repositoryPath + "/somedep/somedep/4.0/somedep-4.0-sources.jar!/", - "jar://" + repositoryPath + "/somedep/somedep/4.0/somedep-4.0-javadoc.jar!/") + "jar://" + repositoryFile + "/somedep/somedep/4.0/somedep-4.0.jar!/", + "jar://" + repositoryFile + "/somedep/somedep/4.0/somedep-4.0-sources.jar!/", + "jar://" + repositoryFile + "/somedep/somedep/4.0/somedep-4.0-javadoc.jar!/") assertProjectLibraryCoordinates("Maven: somedep:somedep:4.0", "somedep", "somedep", "4.0") } @@ -730,9 +730,9 @@ class MavenStaticSyncTest : AbstractMavenStaticSyncTest() { assertModules("project") assertModuleLibDep("project", "Maven: somedep:somedep:4.0", - "jar://" + repositoryPath + "/somedep/somedep/4.0/somedep-4.0.jar!/", - "jar://" + repositoryPath + "/somedep/somedep/4.0/somedep-4.0-sources.jar!/", - "jar://" + repositoryPath + "/somedep/somedep/4.0/somedep-4.0-javadoc.jar!/") + "jar://" + repositoryFile + "/somedep/somedep/4.0/somedep-4.0.jar!/", + "jar://" + repositoryFile + "/somedep/somedep/4.0/somedep-4.0-sources.jar!/", + "jar://" + repositoryFile + "/somedep/somedep/4.0/somedep-4.0-javadoc.jar!/") assertModuleLibDepScope("project", "Maven: somedep:somedep:4.0", DependencyScope.TEST) @@ -770,9 +770,9 @@ class MavenStaticSyncTest : AbstractMavenStaticSyncTest() { assertModules("project", "m1") assertModuleLibDep("m1", "Maven: somedep:somedep:4.0", - "jar://" + repositoryPath + "/somedep/somedep/4.0/somedep-4.0.jar!/", - "jar://" + repositoryPath + "/somedep/somedep/4.0/somedep-4.0-sources.jar!/", - "jar://" + repositoryPath + "/somedep/somedep/4.0/somedep-4.0-javadoc.jar!/") + "jar://" + repositoryFile + "/somedep/somedep/4.0/somedep-4.0.jar!/", + "jar://" + repositoryFile + "/somedep/somedep/4.0/somedep-4.0-sources.jar!/", + "jar://" + repositoryFile + "/somedep/somedep/4.0/somedep-4.0-javadoc.jar!/") } @Test diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenWrapperConfigurationTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenWrapperConfigurationTest.kt index 9605dd3222ea..71ea1c275adc 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenWrapperConfigurationTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenWrapperConfigurationTest.kt @@ -14,6 +14,7 @@ import org.jetbrains.idea.maven.server.MavenDistributionsCache import org.junit.Test import java.io.File import java.util.zip.ZipOutputStream +import kotlin.io.path.isRegularFile class MavenWrapperConfigurationTest : MavenImportingTestCase() { @@ -99,10 +100,10 @@ class MavenWrapperConfigurationTest : MavenImportingTestCase() { @Test fun testShouldDownloadAndUseWrapperMavenSettings() = runBlocking { val helper = MavenCustomRepositoryHelper(dir, "local1", "remote") - val remoteRepoPath = helper.getTestDataPath("remote") - val localRepoPath = helper.getTestDataPath("local1") + val remoteRepoPath = helper.getTestData("remote") + val localRepoPath = helper.getTestData("local1") - httpServerFixture.startRepositoryFor(remoteRepoPath) + httpServerFixture.startRepositoryFor(remoteRepoPath.toString()) val newName = "custom-maven.zip" val repack = repackCurrentMaven(newName) { FileUtil.writeToFile(it.resolve("conf/settings.xml"), """ @@ -128,7 +129,7 @@ class MavenWrapperConfigurationTest : MavenImportingTestCase() { } httpServerFixtureForWrapper.startRepositoryFor(repack.parent) - repositoryPath = localRepoPath + repositoryFile = localRepoPath val settingsXml = createProjectSubFile( "settings.xml", """ @@ -157,9 +158,9 @@ class MavenWrapperConfigurationTest : MavenImportingTestCase() { MavenWorkspaceSettingsComponent.getInstance(project).settings.generalSettings.setMavenHomeNoFire(MavenWrapper) removeFromLocalRepository("org/mytest/myartifact/") - assertFalse(helper.getTestDataLegacy("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isFile) + assertFalse(helper.getTestData("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isRegularFile()) importProjectAsync() - assertTrue(helper.getTestDataLegacy("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isFile) + assertTrue(helper.getTestData("local1/org/mytest/myartifact/1.0/myartifact-1.0.jar").isRegularFile()) } /** diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MiscImportingTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MiscImportingTest.kt index 18259aaf6f83..54e58e547dd8 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MiscImportingTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MiscImportingTest.kt @@ -292,8 +292,8 @@ class MiscImportingTest : MavenMultiVersionImportingTestCase() { @Test fun testTakingProxySettingsIntoAccount() = runBlocking { val helper = MavenCustomRepositoryHelper(dir, "local1") - repositoryPath = helper.getTestDataPath("local1") - mavenGeneralSettings.setLocalRepository(repositoryPath) + repositoryFile = helper.getTestData("local1") + mavenGeneralSettings.setLocalRepository(repositoryFile.toString()) importProjectAsync(""" test project @@ -347,7 +347,7 @@ class MiscImportingTest : MavenMultiVersionImportingTestCase() { fun testMavenExtensionsAreLoadedAndAfterProjectsReadIsCalled() = runBlocking { try { val helper = MavenCustomRepositoryHelper(dir, "plugins") - repositoryPath = helper.getTestDataPath("plugins") + repositoryFile = helper.getTestData("plugins") mavenGeneralSettings.isWorkOffline = true importProjectAsync(""" test diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/SnapshotDependenciesImportingTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/SnapshotDependenciesImportingTest.kt index 56635fce4f2f..ea72d57e0b33 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/SnapshotDependenciesImportingTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/SnapshotDependenciesImportingTest.kt @@ -162,13 +162,13 @@ ${repositoriesSection()} assertModuleLibDep("project", "Maven: test:foo:1-SNAPSHOT", - "jar://" + repositoryPath + "/test/foo/1-SNAPSHOT/foo-1-SNAPSHOT.jar!/", - "jar://" + repositoryPath + "/test/foo/1-SNAPSHOT/foo-1-SNAPSHOT-sources.jar!/", - "jar://" + repositoryPath + "/test/foo/1-SNAPSHOT/foo-1-SNAPSHOT-javadoc.jar!/") + "jar://" + repositoryFile + "/test/foo/1-SNAPSHOT/foo-1-SNAPSHOT.jar!/", + "jar://" + repositoryFile + "/test/foo/1-SNAPSHOT/foo-1-SNAPSHOT-sources.jar!/", + "jar://" + repositoryFile + "/test/foo/1-SNAPSHOT/foo-1-SNAPSHOT-javadoc.jar!/") - assertTrue(repositoryFile.resolve("/test/foo/1-SNAPSHOT/foo-1-SNAPSHOT.jar").exists()) - assertTrue(repositoryFile.resolve("/test/foo/1-SNAPSHOT/foo-1-SNAPSHOT-sources.jar").exists()) - assertTrue(repositoryFile.resolve("/test/foo/1-SNAPSHOT/foo-1-SNAPSHOT-javadoc.jar").exists()) + assertTrue(repositoryFile.resolve("test/foo/1-SNAPSHOT/foo-1-SNAPSHOT.jar").exists()) + assertTrue(repositoryFile.resolve("test/foo/1-SNAPSHOT/foo-1-SNAPSHOT-sources.jar").exists()) + assertTrue(repositoryFile.resolve("test/foo/1-SNAPSHOT/foo-1-SNAPSHOT-javadoc.jar").exists()) } @Test @@ -221,9 +221,9 @@ ${repositoriesSection()} assertModuleLibDep("project", "Maven: test:foo:1-SNAPSHOT", - "jar://" + repositoryPath + "/test/foo/1-SNAPSHOT/foo-1-SNAPSHOT.jar!/", - "jar://" + repositoryPath + "/test/foo/1-SNAPSHOT/foo-1-SNAPSHOT-sources.jar!/", - "jar://" + repositoryPath + "/test/foo/1-SNAPSHOT/foo-1-SNAPSHOT-javadoc.jar!/") + "jar://" + repositoryFile + "/test/foo/1-SNAPSHOT/foo-1-SNAPSHOT.jar!/", + "jar://" + repositoryFile + "/test/foo/1-SNAPSHOT/foo-1-SNAPSHOT-sources.jar!/", + "jar://" + repositoryFile + "/test/foo/1-SNAPSHOT/foo-1-SNAPSHOT-javadoc.jar!/") deployArtifact("test", "foo", "1-SNAPSHOT", @@ -257,9 +257,9 @@ ${repositoriesSection()} assertModuleLibDep("project", "Maven: test:foo:1-SNAPSHOT", - "jar://" + repositoryPath + "/test/foo/1-SNAPSHOT/foo-1-SNAPSHOT.jar!/", - "jar://" + repositoryPath + "/test/foo/1-SNAPSHOT/foo-1-SNAPSHOT-sources.jar!/", - "jar://" + repositoryPath + "/test/foo/1-SNAPSHOT/foo-1-SNAPSHOT-javadoc.jar!/") + "jar://" + repositoryFile + "/test/foo/1-SNAPSHOT/foo-1-SNAPSHOT.jar!/", + "jar://" + repositoryFile + "/test/foo/1-SNAPSHOT/foo-1-SNAPSHOT-sources.jar!/", + "jar://" + repositoryFile + "/test/foo/1-SNAPSHOT/foo-1-SNAPSHOT-javadoc.jar!/") } private fun deployArtifact(groupId: String, artifactId: String, version: String, tail: String = "") { diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/StructureImportingTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/StructureImportingTest.kt index 558bfecbea82..8ee85002c9e2 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/StructureImportingTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/StructureImportingTest.kt @@ -639,7 +639,7 @@ class StructureImportingTest : MavenMultiVersionImportingTestCase() { @Test fun testParentInRemoteRepository() = runBlocking { val pathToJUnit = "asm/asm-parent/3.0" - val parentDir = Paths.get(repositoryPath, pathToJUnit) + val parentDir = repositoryFile.resolve(pathToJUnit) removeFromLocalRepository(pathToJUnit) assertFalse(Files.exists(parentDir)) diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenGavIndicesTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenGavIndicesTest.kt index 1062c29d25bc..8953dfc96194 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenGavIndicesTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenGavIndicesTest.kt @@ -11,9 +11,9 @@ class MavenGavIndicesTest : MavenTestCase() { fun testUpdateGavIndex() = runBlocking { val helper = MavenCustomRepositoryHelper(dir, "local1") - val path = helper.getTestDataPath("local1") + val path = helper.getTestData("local1") - val gavIndex = MavenLocalGavIndexImpl(MavenRepositoryInfo("local", path, RepositoryKind.LOCAL)) + val gavIndex = MavenLocalGavIndexImpl(MavenRepositoryInfo("local", path.toString(), RepositoryKind.LOCAL)) gavIndex.update(mavenProgressIndicator!!, false) assertSameElements(gavIndex.groupIds, "asm", "commons-io", "junit", "org.deptest", "org.example", "org.intellijgroup", "org.ow2.asm") assertSameElements(gavIndex.getArtifactIds("asm"), "asm", "asm-attrs") diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesManagerTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesManagerTest.kt index 30fd5167022d..cb0a47557755 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesManagerTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesManagerTest.kt @@ -2,7 +2,6 @@ package org.jetbrains.idea.maven.indices import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.util.io.FileUtil import org.jetbrains.idea.maven.indices.MavenIndicesManager.Companion.addArchetype import org.jetbrains.idea.maven.indices.MavenIndicesManager.Companion.getInstance import org.jetbrains.idea.maven.indices.MavenIndicesManager.MavenIndexerListener @@ -12,10 +11,13 @@ import org.jetbrains.idea.maven.model.MavenRepositoryInfo import org.jetbrains.idea.maven.project.MavenProjectsManager import org.junit.Test import java.io.File +import java.nio.file.Files import java.nio.file.Path import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.CountDownLatch import java.util.concurrent.TimeUnit +import kotlin.io.path.ExperimentalPathApi +import kotlin.io.path.copyToRecursively class MavenIndicesManagerTest : MavenIndicesTestCase() { public override fun runInDispatchThread(): Boolean { @@ -68,20 +70,21 @@ class MavenIndicesManagerTest : MavenIndicesTestCase() { } @Test + @OptIn(ExperimentalPathApi::class) fun testAddingFilesToIndex() { - val localRepo = myIndicesFixture!!.repositoryHelper.getTestDataLegacy("local2") + val localRepo = myIndicesFixture!!.repositoryHelper.getTestData("local2") - MavenProjectsManager.getInstance(project).getGeneralSettings().setLocalRepository(localRepo.path) + MavenProjectsManager.getInstance(project).getGeneralSettings().setLocalRepository(localRepo.toString()) myIndicesFixture!!.indicesManager.scheduleUpdateIndicesListAndWait() myIndicesFixture!!.indicesManager.waitForGavUpdateCompleted() val localIndex = myIndicesFixture!!.indicesManager.getCommonGavIndex() assertTrue(localIndex.getArtifactIds("junit").isEmpty()) //copy junit to repository - val artifactDir = myIndicesFixture!!.repositoryHelper.getTestDataLegacy("local1/junit") - FileUtil.copyDir(artifactDir, localRepo) + val artifactDir = myIndicesFixture!!.repositoryHelper.getTestData("local1/junit") + artifactDir.copyToRecursively(localRepo, followLinks = false, overwrite = false) - val artifactFile = myIndicesFixture!!.repositoryHelper.getTestDataLegacy("local2/junit/junit/4.0/junit-4.0.pom") + val artifactFile = myIndicesFixture!!.repositoryHelper.getTestData("local2/junit/junit/4.0/junit-4.0.pom") val latch = CountDownLatch(1) val addedFiles: MutableSet = ConcurrentHashMap.newKeySet() @@ -95,8 +98,7 @@ class MavenIndicesManagerTest : MavenIndicesTestCase() { } }) - val indexingScheduled = - getInstance(project).scheduleArtifactIndexing(null, artifactFile.toPath(), localRepo.absolutePath) + val indexingScheduled = getInstance(project).scheduleArtifactIndexing(null, artifactFile, localRepo.toString()) assertTrue("Failed to schedule indexing", indexingScheduled) latch.await(1, TimeUnit.MINUTES) diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesTestFixture.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesTestFixture.java index 65a0222c1cbc..8924e1472922 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesTestFixture.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesTestFixture.java @@ -51,14 +51,13 @@ public class MavenIndicesTestFixture { } public void setUpBeforeImport() throws Exception { - myRepositoryHelper = new MavenCustomRepositoryHelper(myDir.toFile(), ArrayUtil.append(myExtraRepoDirs, myLocalRepoDir)); + myRepositoryHelper = new MavenCustomRepositoryHelper(myDir, ArrayUtil.append(myExtraRepoDirs, myLocalRepoDir)); for (String each : myExtraRepoDirs) { addToRepository(each); } - MavenProjectsManager.getInstance(myProject).getGeneralSettings().setLocalRepository( - myRepositoryHelper.getTestDataPath(myLocalRepoDir)); + MavenProjectsManager.getInstance(myProject).getGeneralSettings().setLocalRepository(myRepositoryHelper.getTestData(myLocalRepoDir).toString()); Registry.get("maven.skip.gav.update.in.unit.test.mode").setValue(false, myTestRootDisposable); } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectReaderTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectReaderTest.kt index 6e232fe5dace..b1b2e4d9c668 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectReaderTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectReaderTest.kt @@ -612,7 +612,7 @@ class MavenProjectReaderTest : MavenProjectReaderTestCase() { fun testHandlingRecursionProprielyAndDoNotForgetCoClearRecursionGuard() = runBlocking { val repoPath = dir.resolve("repository") - repositoryPath = repoPath.toString() + repositoryFile = repoPath val parentFile = repoPath.resolve("test/parent/1/parent-1.pom") createFile(parentFile, createPomXml(""" @@ -907,7 +907,7 @@ class MavenProjectReaderTest : MavenProjectReaderTestCase() { fun testExpandingPropertiesFromParentInRepository() = runBlocking { val repoPath = dir.resolve("repository") - repositoryPath = repoPath.toString() + repositoryFile = repoPath val parentFile = repoPath.resolve("org/test/parent/1/parent-1.pom") createFile(parentFile, createPomXml(""" diff --git a/plugins/maven/testFramework/src/com/intellij/maven/testFramework/MavenTestCase.kt b/plugins/maven/testFramework/src/com/intellij/maven/testFramework/MavenTestCase.kt index 660fba33f19f..c8b34d2b75e4 100644 --- a/plugins/maven/testFramework/src/com/intellij/maven/testFramework/MavenTestCase.kt +++ b/plugins/maven/testFramework/src/com/intellij/maven/testFramework/MavenTestCase.kt @@ -379,17 +379,15 @@ abstract class MavenTestCase : UsefulTestCase() { protected val mavenImporterSettings: MavenImportingSettings get() = MavenProjectsManager.getInstance(myProject!!).importingSettings - protected var repositoryPath: String? - get() { - val path = repositoryFile.toString() - return FileUtil.toSystemIndependentName(path) - } - protected set(path) { - mavenGeneralSettings.setLocalRepository(path) + protected var repositoryFile: Path + get() = mavenGeneralSettings.effectiveRepositoryPath + set(path) { + mavenGeneralSettings.setLocalRepository(path.toCanonicalPath()) } - protected val repositoryFile: Path - get() = mavenGeneralSettings.effectiveRepositoryPath + protected fun resetRepositoryFile() { + mavenGeneralSettings.setLocalRepository(null) + } protected val projectPath: Path get() = myProjectRoot!!.path.toNioPathOrNull()!!