diff --git a/build/org.eclipse.cdt.make.core/plugin.xml b/build/org.eclipse.cdt.make.core/plugin.xml index 7455ac32a3e..14dddcd1ef2 100644 --- a/build/org.eclipse.cdt.make.core/plugin.xml +++ b/build/org.eclipse.cdt.make.core/plugin.xml @@ -15,7 +15,6 @@ - @@ -69,8 +68,8 @@ name="%makeproject.name" point="org.eclipse.cdt.core.CProject"> + class="org.eclipse.cdt.make.internal.core.MakeProject" + natureID="org.eclipse.cdt.make.core.makeNature"> 0) { + elem = doc.createElement(TARGET_ARGUMENTS); + elem.appendChild(doc.createTextNode(target.getBuildArguments())); + targetElem.appendChild(elem); + } - elem = doc.createElement(TARGET); - elem.appendChild(doc.createTextNode(target.getBuildTarget())); - targetElem.appendChild(elem); + if (target.getBuildTarget().length() > 0) { + elem = doc.createElement(TARGET); + elem.appendChild(doc.createTextNode(target.getBuildTarget())); + targetElem.appendChild(elem); + } elem = doc.createElement(TARGET_STOP_ON_ERROR); elem.appendChild(doc.createTextNode(new Boolean(target.isStopOnError()).toString())); @@ -211,19 +225,37 @@ public class ProjectTargets { } public void saveTargets() throws IOException { + Document doc = getAsXML(); + //Historical method would save the output to the stream specified + //translateDocumentToOutputStream(doc, output); try { - Document doc = getAsXML(); - //Historical method would save the output to the stream specified - //translateDocumentToOutputStream(doc, output); translateDocumentToCDTProject(doc); - } catch (CoreException ex) { - throw new IOException(ex.getMessage()); + } catch (Exception e) { + IPath targetFilePath = MakeCorePlugin.getDefault().getStateLocation().append(project.getName()).addFileExtension( + TARGETS_EXT); + File targetFile = targetFilePath.toFile(); + try { + saveTargets(doc, new FileOutputStream(targetFile)); + } catch (FileNotFoundException e1) { + } catch (IOException e1) { + } catch (TransformerException e1) { + } } } + protected void saveTargets(Document doc, OutputStream output) throws IOException, TransformerException { + TransformerFactory factory = TransformerFactory.newInstance(); + Transformer transformer; + transformer = factory.newTransformer(); + transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ + + DOMSource source = new DOMSource(doc); + StreamResult outputTarget = new StreamResult(output); + transformer.transform(source, outputTarget); + } /** - * This output method saves the information into the .cdtproject metadata - * file. + * This output method saves the information into the .cdtproject metadata file. * * @param doc * @throws IOException @@ -254,8 +286,7 @@ public class ProjectTargets { } /** - * This method parses the .cdtproject file for the XML document describing - * the build targets. + * This method parses the .cdtproject file for the XML document describing the build targets. * * @param input * @return @@ -269,26 +300,24 @@ public class ProjectTargets { descriptor = CCorePlugin.getDefault().getCProjectDescription(getProject()); rootElement = descriptor.getProjectData(MAKE_TARGET_KEY); - } catch ( ParserConfigurationException e) { + } catch (ParserConfigurationException e) { return document; - } catch ( CoreException e) { + } catch (CoreException e) { return document; } - Element element = rootElement.getOwnerDocument().getDocumentElement(); NodeList list = rootElement.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { - if ( list.item(i).getNodeType() == Node.ELEMENT_NODE) { + if (list.item(i).getNodeType() == Node.ELEMENT_NODE) { Node appendNode = document.importNode(list.item(i), true); document.appendChild(appendNode); - break; // show never have multiple + break; // should never have multiple } } return document; } /** - * This method parses the input stream for the XML document describing the - * build targets. + * This method parses the input stream for the XML document describing the build targets. * * @param input * @return @@ -304,8 +333,7 @@ public class ProjectTargets { } /** - * Extract the make target information which is contained in the XML - * Document + * Extract the make target information which is contained in the XML Document * * @param document */ @@ -344,6 +372,10 @@ public class ProjectTargets { if (option != null) { target.setBuildArguments(option); } + option = getString(node, BAD_TARGET); + if (option != null) { + target.setBuildTarget(option); + } option = getString(node, TARGET); if (option != null) { target.setBuildTarget(option);