IDEA-176281 - fix of maven modules imports in cases when pom.xml file located in folder named *.xml

This commit is contained in:
Ivan Bessonov
2017-07-20 17:22:03 +03:00
parent a872dc3410
commit e66381ad2e
2 changed files with 30 additions and 2 deletions
@@ -224,13 +224,13 @@ public class MavenProject {
private Map<String, String> collectModulePathsAndNames(MavenModel mavenModel, String baseDir) {
String basePath = baseDir + "/";
Map<String, String> result = new LinkedHashMap<>();
for (Map.Entry<String, String> each : collectModulesRelativePathsAndNames(mavenModel).entrySet()) {
for (Map.Entry<String, String> each : collectModulesRelativePathsAndNames(mavenModel, basePath).entrySet()) {
result.put(new Path(basePath + each.getKey()).getPath(), each.getValue());
}
return result;
}
private Map<String, String> collectModulesRelativePathsAndNames(MavenModel mavenModel) {
private Map<String, String> collectModulesRelativePathsAndNames(MavenModel mavenModel, String basePath) {
String extension = StringUtil.notNullize(myFile.getExtension());
LinkedHashMap<String, String> result = new LinkedHashMap<>();
for (String name : mavenModel.getModules()) {
@@ -246,6 +246,12 @@ public class MavenProject {
if (!name.endsWith("/")) name += "/";
name += MavenConstants.POM_EXTENSION + '.' + extension;
}
else {
String systemDependentName = FileUtil.toSystemDependentName(basePath + name);
if (new File(systemDependentName).isDirectory()) {
name += "/" + MavenConstants.POM_XML;
}
}
result.put(name, originalName);
}
@@ -42,6 +42,28 @@ public class CustomPomFileNameTest extends MavenDomTestCase {
assertModules("project", "m1");
}
public void testFolderNameWithXmlExtension() throws Exception {
createProjectSubFile("customName.xml/pom.xml", createPomXml(
"<artifactId>m1</artifactId>" +
"<version>1</version>" +
"<parent>" +
" <groupId>test</groupId>" +
" <artifactId>project</artifactId>" +
" <version>1</version>" +
"</parent>"));
importProject("<groupId>test</groupId>" +
"<artifactId>project</artifactId>" +
"<version>1</version>" +
"<modules>" +
" <module>customName.xml</module>" +
"</modules>");
assertModules("project", "m1");
}
public void testModuleCompletion() throws Exception {
createProjectSubFile("m1/customPom.xml", createPomXml(
"<artifactId>m1</artifactId>" +