jps model: don't fail if some iml file doesn't exist (IDEA-173842)

This commit is contained in:
nik
2017-06-02 15:24:58 +03:00
parent 3a62b6e434
commit cf497ca91a
3 changed files with 27 additions and 5 deletions

View File

@@ -303,17 +303,22 @@ public class JpsProjectLoader extends JpsLoaderBase {
try {
final List<String> classpathDirs = new ArrayList<>();
for (Future<Pair<Path, Element>> moduleFile : futureModuleFilesContents) {
final String classpathDir = moduleFile.get().getSecond().getAttributeValue(CLASSPATH_DIR_ATTRIBUTE);
if (classpathDir != null) {
classpathDirs.add(classpathDir);
Element rootElement = moduleFile.get().getSecond();
if (rootElement != null) {
final String classpathDir = rootElement.getAttributeValue(CLASSPATH_DIR_ATTRIBUTE);
if (classpathDir != null) {
classpathDirs.add(classpathDir);
}
}
}
List<Future<JpsModule>> futures = new ArrayList<>();
for (final Future<Pair<Path, Element>> futureModuleFile : futureModuleFilesContents) {
final Pair<Path, Element> moduleFile = futureModuleFile.get();
futures.add(ourThreadPool.submit(
() -> loadModule(moduleFile.getFirst(), moduleFile.getSecond(), classpathDirs, projectSdkType, pathVariables)));
if (moduleFile.getSecond() != null) {
futures.add(ourThreadPool.submit(
() -> loadModule(moduleFile.getFirst(), moduleFile.getSecond(), classpathDirs, projectSdkType, pathVariables)));
}
}
for (Future<JpsModule> future : futures) {
JpsModule module = future.get();

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/missingImlFile.iml" filepath="$PROJECT_DIR$/missingImlFile.iml" />
</modules>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.4" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@@ -236,6 +236,11 @@ public class JpsProjectSerializationTest extends JpsSerializationTestCase {
assertEquals("main", assertOneElement(myProject.getModules()).getName());
}
public void testMissingImlFile() {
loadProject("/jps/model-serialization/testData/missingImlFile/missingImlFile.ipr");
assertEmpty(myProject.getModules());
}
private void doTestSaveLibrary(@NotNull Path libFile, String libName, JpsLibrary library) {
Element actual = new Element("library");
JpsLibraryTableSerializer.saveLibrary(library, actual, libName);