Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilos Kleint2011-02-11 13:44:40 +0000
committerMilos Kleint2011-02-11 13:44:40 +0000
commit9aad8767c1414f9c32dbc9f90b03bc0f4ca11703 (patch)
tree11fd70861ad5daaeea31425863519e73adcc470f /org.eclipse.m2e.editor
parentd70c75a0557376093bbcd5e847e4b9b0898011ff (diff)
downloadm2e-core-9aad8767c1414f9c32dbc9f90b03bc0f4ca11703.tar.gz
m2e-core-9aad8767c1414f9c32dbc9f90b03bc0f4ca11703.tar.xz
m2e-core-9aad8767c1414f9c32dbc9f90b03bc0f4ca11703.zip
one more rewrite
Diffstat (limited to 'org.eclipse.m2e.editor')
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/OverviewPage.java42
1 files changed, 22 insertions, 20 deletions
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/OverviewPage.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/OverviewPage.java
index 8361f8f1..105dc6fe 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/OverviewPage.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/OverviewPage.java
@@ -1395,31 +1395,33 @@ public class OverviewPage extends MavenPomEditorPage {
IPath resultPath = container.getLocation();
String path = resultPath.makeRelativeTo(projectPath).toString();
-
if(!model.getModules().contains(path)) {
if(updateParentSection) {
final String relativePath = projectPath.makeRelativeTo(resultPath).toString();
- MavenPlugin.getDefault().getMavenModelManager().updateProject(pomFile, new ProjectUpdater() {
- public void update(Model model) {
- Parent parent = model.getParent();
- if(parent == null) {
- parent = PomFactory.eINSTANCE.createParent();
- model.setParent(parent);
- }
- parent.setGroupId(parentGroupId);
- parent.setArtifactId(parentArtifactId);
- parent.setVersion(parentVersion);
- parent.setRelativePath(relativePath);
-
- if(model.getGroupId() == null || model.getGroupId().equals(parentGroupId)) {
- model.setGroupId(null);
-
- if(model.getVersion() != null && model.getVersion().equals(parentVersion)) {
- model.setVersion(null);
+ try {
+ performOnDOMDocument(new OperationTuple(pomFile, new Operation() {
+ public void process(Document document) {
+ Element root = document.getDocumentElement();
+ Element parent = getChild(root, "parent");
+ setText(getChild(parent, "groupId"), parentGroupId);
+ setText(getChild(parent, "artifactId"), parentArtifactId);
+ setText(getChild(parent, "version"), parentVersion);
+ setText(getChild(parent, "relativePath"), relativePath);
+ Element grId = findChild(root, "groupId");
+ String grIdText = getTextValue(grId);
+ if (grIdText != null && grIdText.equals(parentGroupId)) {
+ removeChild(root, grId);
+ }
+ Element ver = findChild(root, "version");
+ String verText = getTextValue(ver);
+ if (verText != null && verText.equals(parentVersion)) {
+ removeChild(root, ver);
}
}
- }
- });
+ }));
+ } catch(Exception e) {
+ LOG.error("Error updating parent reference in file:" + pomFile, e);
+ }
}
createNewModule(path);

Back to the top