use of org.jetbrains.idea.eclipse.config.EclipseClasspathStorageProvider in project intellij-community by JetBrains.
the class EclipseClasspathTest method setUpModule.
static Module setUpModule(final String path, @NotNull final Project project) throws Exception {
final File classpathFile = new File(path, EclipseXml.DOT_CLASSPATH_EXT);
String fileText = FileUtil.loadFile(classpathFile).replaceAll("\\$ROOT\\$", project.getBaseDir().getPath());
if (!SystemInfo.isWindows) {
fileText = fileText.replaceAll(EclipseXml.FILE_PROTOCOL + "/", EclipseXml.FILE_PROTOCOL);
}
final Element classpathElement = JDOMUtil.load(fileText);
final Module module = WriteCommandAction.runWriteCommandAction(null, (Computable<Module>) () -> {
String imlPath = path + "/" + EclipseProjectFinder.findProjectName(path) + ModuleManagerImpl.IML_EXTENSION;
return ModuleManager.getInstance(project).newModule(imlPath, StdModuleTypes.JAVA.getId());
});
ModuleRootModificationUtil.updateModel(module, model -> {
try {
EclipseClasspathReader classpathReader = new EclipseClasspathReader(path, project, null);
classpathReader.init(model);
classpathReader.readClasspath(model, classpathElement);
new EclipseClasspathStorageProvider().assertCompatible(model);
} catch (Exception e) {
throw new RuntimeException(e);
}
});
return module;
}
Aggregations