use of org.jdom.JDOMException in project intellij-community by JetBrains.
the class EclipseClasspathConverter method readClasspath.
@Override
public void readClasspath(@NotNull ModifiableRootModel model) throws IOException {
try {
CachedXmlDocumentSet fileSet = getFileSet();
String path = fileSet.getParent(EclipseXml.PROJECT_FILE);
Element classpath = null;
if (!fileSet.exists(EclipseXml.PROJECT_FILE)) {
classpath = fileSet.load(EclipseXml.CLASSPATH_FILE, false);
if (classpath == null) {
return;
}
path = fileSet.getParent(EclipseXml.CLASSPATH_FILE);
}
EclipseClasspathReader classpathReader = new EclipseClasspathReader(path, module.getProject(), null);
classpathReader.init(model);
if (classpath == null) {
classpath = fileSet.load(EclipseXml.CLASSPATH_FILE, false);
}
if (classpath == null) {
EclipseClasspathReader.setOutputUrl(model, path + "/bin");
} else {
classpathReader.readClasspath(model, classpath);
}
Element eml = fileSet.load(model.getModule().getName() + EclipseXml.IDEA_SETTINGS_POSTFIX, false);
if (eml == null) {
model.getModuleExtension(CompilerModuleExtension.class).setExcludeOutput(false);
} else {
new IdeaSpecificSettings().readIdeaSpecific(eml, model, null, null);
}
} catch (JDOMException e) {
throw new IOException(e);
}
}
use of org.jdom.JDOMException in project intellij-community by JetBrains.
the class EclipseProjectFinder method findProjectName.
@Nullable
public static String findProjectName(String rootPath) {
String name = null;
final File file = new File(rootPath, DOT_PROJECT_EXT);
if (file.isFile()) {
try {
name = JDOMUtil.load(file).getChildText(NAME_TAG);
if (StringUtil.isEmptyOrSpaces(name)) {
return null;
}
name = name.replace("\n", " ").trim();
} catch (JDOMException | IOException e) {
return null;
}
}
return name;
}
use of org.jdom.JDOMException in project android by JetBrains.
the class CompatibilityChecksMetadataUpdater method fetchMetadata.
@NotNull
private static ActionCallback fetchMetadata() {
ActionCallback callback = new ActionCallback();
ApplicationManager.getApplication().executeOnPooledThread(() -> {
String url = "https://dl.google.com/android/studio/metadata/android-component-compatibility.xml";
try {
Document metadata = HttpRequests.request(url).connect(request -> {
try {
return loadDocument(request.getInputStream());
} catch (JDOMException e) {
LOG.info("Failed to parse XML metadata", e);
return null;
} catch (Throwable e) {
LOG.info("Failed to parse XML metadata", e);
return null;
}
});
if (metadata != null) {
VersionCompatibilityChecker.getInstance().updateMetadata(metadata);
callback.setDone();
}
} catch (IOException e) {
LOG.info(String.format("Failed to connect to '%1$s'", url), e);
}
callback.setRejected();
});
return callback;
}
use of org.jdom.JDOMException in project intellij-plugins by JetBrains.
the class ConversionTestBaseEx method doTest.
@Override
protected boolean doTest(String testName, boolean conversionShouldHappen) throws IOException, JDOMException {
String path = getHomePath() + getBasePath() + testName;
final File globalBefore = new File(path, "global_before");
ApplicationManager.getApplication().runWriteAction(() -> {
try {
if (checkJdk()) {
Element d = JDOMUtil.load(new File(globalBefore, JDK_TABLE_XML));
ConversionHelper.expandPaths(d);
((ProjectJdkTableImpl) ProjectJdkTable.getInstance()).loadState(d);
}
{
Element d = JDOMUtil.load(new File(globalBefore, GLOBAL_LIBS_XML));
ConversionHelper.expandPaths(d);
ApplicationLibraryTable.getApplicationTable().loadState(d);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
});
if (!super.doTest(testName, conversionShouldHappen)) {
return false;
}
Path globalAfter = Paths.get(path, "global_after");
if (checkJdk()) {
Element sdkState = ((ProjectJdkTableImpl) ProjectJdkTable.getInstance()).getState();
ConversionHelper.collapsePaths(sdkState);
assertThat(sdkState).isEqualTo(globalAfter.resolve(JDK_TABLE_XML));
}
{
Element globalLibState = ApplicationLibraryTable.getApplicationTable().getState();
ConversionHelper.collapsePaths(globalLibState);
assertThat(globalLibState).isEqualTo(globalAfter.resolve(GLOBAL_LIBS_XML));
}
return true;
}
use of org.jdom.JDOMException in project intellij-plugins by JetBrains.
the class FlexBuilderUtils method copyAndFixCustomAirDescriptor.
private static void copyAndFixCustomAirDescriptor(final CompileContext context, final BuildOutputConsumer outputConsumer, final JpsFlexBuildConfiguration bc, final JpsAirPackagingOptions packagingOptions) {
final String customDescriptorPath = packagingOptions.getCustomDescriptorPath();
final File descriptorTemplateFile = new File(customDescriptorPath);
if (!descriptorTemplateFile.isFile()) {
context.processMessage(new CompilerMessage(getCompilerName(bc), BuildMessage.Kind.ERROR, FlexCommonBundle.message("air.descriptor.not.found", customDescriptorPath)));
return;
}
final String outputFilePath = bc.getActualOutputFilePath();
final String outputFolderPath = PathUtilRt.getParentPath(outputFilePath);
final File outputFolder = new File(outputFolderPath);
if (!outputFolder.isDirectory()) {
context.processMessage(new CompilerMessage(getCompilerName(bc), BuildMessage.Kind.ERROR, FlexCommonBundle.message("output.folder.does.not.exist", outputFolder.getPath())));
return;
}
final String content;
try {
content = fixInitialContent(descriptorTemplateFile, PathUtilRt.getFileName(outputFilePath));
} catch (IOException e) {
context.processMessage(new CompilerMessage(getCompilerName(bc), BuildMessage.Kind.ERROR, FlexCommonBundle.message("failed.to.open.air.descriptor", descriptorTemplateFile.getPath(), e.getMessage())));
return;
} catch (JDOMException e) {
context.processMessage(new CompilerMessage(getCompilerName(bc), BuildMessage.Kind.ERROR, FlexCommonBundle.message("incorrect.air.descriptor.content", descriptorTemplateFile.getPath(), e.getMessage())));
return;
}
try {
final String descriptorFileName = bc.isTempBCForCompilation() ? FlexCommonUtils.getGeneratedAirDescriptorName(bc, packagingOptions) : descriptorTemplateFile.getName();
final File outputFile = new File(outputFolder, descriptorFileName);
FileUtil.writeToFile(outputFile, content.getBytes("UTF-8"));
outputConsumer.registerOutputFile(outputFile, Collections.singletonList(descriptorTemplateFile.getPath()));
} catch (IOException e) {
context.processMessage(new CompilerMessage(getCompilerName(bc), BuildMessage.Kind.ERROR, FlexCommonBundle.message("failed.to.copy.air.descriptor", e.getMessage())));
}
}
Aggregations