Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 9b5301c3198d5c3c20f6b250bc6fda7440495792 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*******************************************************************************
 * Copyright (c) 2011 Sonatype, Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/

package org.eclipse.m2e.core.ui.internal.editing;

import org.apache.maven.model.Dependency;
import org.eclipse.m2e.core.embedder.ArtifactKey;
import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.*;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class AddExclusionOperation implements Operation {

  private Dependency dependency;

  private ArtifactKey exclusion;

  public AddExclusionOperation(Dependency dependency, ArtifactKey exclusion) {
    this.dependency = dependency;
    this.exclusion = exclusion;
  }

  /* (non-Javadoc)
   * @see org.eclipse.m2e.core.ui.internal.editing.PomEdits.Operation#process(org.w3c.dom.Document)
   */
  public void process(Document document) {
    Element depElement = PomHelper.findDependency(document, dependency);

    if(depElement != null) {
      Element exclusionsElement = getChild(depElement, EXCLUSIONS);

      Element exclusionElement = createElement(exclusionsElement, EXCLUSION);

      createElementWithText(exclusionElement, ARTIFACT_ID, exclusion.getArtifactId());
      createElementWithText(exclusionElement, GROUP_ID, exclusion.getGroupId());
      //TODO mkleint: are there really exclusion versions??
      createElementWithText(exclusionElement, VERSION, exclusion.getVersion());
    }
  }
}

Back to the top