[maven][test][eel][IDEA-361665] use nio.Path instead of io.File in MavenCustomRepositoryHelper

GitOrigin-RevId: d9d6906336b70e697e04aff26fbc0243b20ed799
This commit is contained in:
Alexander.Glukhov
2025-02-19 23:23:41 +00:00
committed by intellij-monorepo-bot
parent 1513d320c5
commit 4de7797cee
30 changed files with 326 additions and 347 deletions
@@ -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<>() {
@@ -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"))
}
@@ -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("""
@@ -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()
</dependencies>
""".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("""<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -420,7 +424,7 @@ $relativePathUnixSeparator<caret></relativePath>
</parent>"""
)
val f = LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath)
val f = LocalFileSystem.getInstance().refreshAndFindFileByNioFile(filePath)
assertResolved(projectPom, findPsiFile(f))
}
@@ -448,16 +452,16 @@ $relativePathUnixSeparator<caret></relativePath>
""".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("""
<groupId>test</groupId>
@@ -486,8 +490,8 @@ $relativePathUnixSeparator<caret></relativePath>
</dependencies>
""".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<caret></relativePath>
</dependencies>
""".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<caret></relativePath>
@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("""<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -568,7 +572,7 @@ $libPath</systemPath>
</dependencies>
""")
assertResolved(projectPom, findPsiFile(LocalFileSystem.getInstance().refreshAndFindFileByPath(libPath)))
assertResolved(projectPom, findPsiFile(LocalFileSystem.getInstance().refreshAndFindFileByNioFile(libPath)))
checkHighlighting()
}
@@ -593,7 +597,7 @@ $libPath</systemPath>
@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("""<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -614,7 +618,7 @@ $libPath</systemPath>
@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("""<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -634,20 +638,20 @@ $libPath</depPath>
</dependencies>
""")
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("""<groupId>test</groupId>
<artifactId>project</artifactId>
<version>1</version>
<properties>
<depDir>
${File(libPath).getParent()}</depDir>
${libPath.parent}</depDir>
</properties>
<dependencies>
<dependency>
@@ -665,7 +669,7 @@ ${File(libPath).getParent()}</depDir>
@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("""<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -682,7 +686,7 @@ $libPath<caret></systemPath>
</dependencies>
""")
assertResolved(projectPom, findPsiFile(LocalFileSystem.getInstance().refreshAndFindFileByPath(libPath)))
assertResolved(projectPom, findPsiFile(LocalFileSystem.getInstance().refreshAndFindFileByNioFile(libPath)))
checkHighlighting()
}
@@ -705,8 +709,8 @@ $libPath<caret></systemPath>
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) }
@@ -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))
}
@@ -117,8 +117,8 @@ class MavenParentCompletionAndResolutionTest : MavenDomWithIndicesTestCase() {
</parent>
""".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))
}
@@ -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))
}
@@ -687,7 +687,7 @@ class MavenPropertyCompletionAndResolutionTest : MavenDomTestCase() {
fun testResolvingSettingsModelProperties() = runBlocking {
val profiles = updateSettingsXml("""
<localRepository>
${repositoryPath}</localRepository>
${repositoryFile}</localRepository>
""".trimIndent())
updateProjectPom("""
@@ -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("""<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -44,7 +44,7 @@ $relativePathUnixSeparator<caret></relativePath>
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<caret></relativePath>
@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("""<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -77,7 +79,7 @@ $relativePathUnixSeparator<caret></relativePath>
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)
@@ -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<OrderEntry> = 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</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</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</scope>
f.parent.createDirectories()
createEmptyJar(f.parent.toString(), f.fileName.toString())
repositoryPath = createProjectSubDir("repo").path
repositoryFile = createProjectSubDir("repo").toNioPath()
}
private fun createOutputDirectories() {
@@ -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() {
</dependencies>
""".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() {
</dependencies>
""".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() {
</dependencies>
""".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() {
</dependencies>
""".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)!!)}</url>
</dependencies>
""".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)!!)}</url>
</build>
""".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)!!)}</url>
@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("""
@@ -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) {
@@ -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!/")
}
}
@@ -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() {
<version>4.0</version>
<scope>system</scope>
<systemPath>
${repositoryPath}/junit/junit/4.0/junit-4.0.jar</systemPath>
${repositoryFile}/junit/junit/4.0/junit-4.0.jar</systemPath>
</dependency>
</dependencies>
""".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("""<settings>
@@ -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("""
<groupId>test</groupId>
@@ -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("""
<groupId>test</groupId>
@@ -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("""
<groupId>test</groupId>
@@ -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
@@ -24,10 +24,10 @@ class DependenciesManagementTest : MavenMultiVersionImportingTestCase() {
fun testImportingDependencies() = runBlocking {
if (!hasMavenInstallation()) return@runBlocking
repositoryPath = dir.resolve("repo").toString()
repositoryFile = dir.resolve("repo")
updateSettingsXml("""
<localRepository>
${repositoryPath}</localRepository>
${repositoryFile}</localRepository>
""".trimIndent())
createModulePom("__temp",
@@ -77,10 +77,10 @@ class DependenciesManagementTest : MavenMultiVersionImportingTestCase() {
@Test
fun testImportingNotInstalledDependencies() = runBlocking {
repositoryPath = dir.resolve("repo").toString()
repositoryFile = dir.resolve("repo")
updateSettingsXml("""
<localRepository>
${repositoryPath}</localRepository>
${repositoryFile}</localRepository>
""".trimIndent())
val bom = createModulePom("bom",
@@ -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("""
<groupId>test</groupId>
@@ -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("""
<groupId>test</groupId><artifactId>project</artifactId><version>1</version><dependencies>
@@ -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("""
<groupId>test</groupId><artifactId>project</artifactId><version>1</version><build>
@@ -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
@@ -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("""
<groupId>test</groupId>
@@ -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 = """
<settings>
<localRepository>$localRepoPath</localRepository>
@@ -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")
@@ -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",
"""
@@ -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
@@ -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())
}
/**
@@ -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("""
<groupId>test</groupId>
<artifactId>project</artifactId>
@@ -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("""
<groupId>test</groupId>
@@ -162,13 +162,13 @@ ${repositoriesSection()}<dependencies>
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()}<dependencies>
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()}<dependencies>
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 = "") {
@@ -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))
@@ -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")
@@ -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<File?> = ConcurrentHashMap.newKeySet<File?>()
@@ -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)
@@ -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);
}
@@ -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("""
@@ -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()!!