List of usage examples for org.springframework.ide.eclipse.boot.core MavenId MavenId
public MavenId(String groupId, String artifactId)
From source file:org.springframework.ide.eclipse.boot.core.internal.MavenSpringBootProject.java
@Override public void setStarters(Collection<SpringBootStarter> _starters) throws CoreException { try {/*from ww w . j a va 2 s . c om*/ final Set<MavenId> starters = new HashSet<>(); for (SpringBootStarter s : _starters) { starters.add(s.getMavenId()); } IFile file = getPomFile(); performOnDOMDocument(new OperationTuple(file, new Operation() { public void process(Document pom) { Element depsEl = getChild(pom.getDocumentElement(), DEPENDENCIES); List<Element> children = findChilds(depsEl, DEPENDENCY); for (Element c : children) { //We only care about 'starter' dependencies. Leave everything else alone. // Also... don't touch nodes that are already there, unless they are to // be removed. This way we don't mess up versions, comments or other stuff // that a user may have inserted via manual edits. String aid = getTextValue(findChild(c, ARTIFACT_ID)); String gid = getTextValue(findChild(c, GROUP_ID)); if (aid != null && gid != null) { //ignore invalid entries that don't have gid or aid if (isKnownStarter(new MavenId(gid, aid))) { MavenId id = new MavenId(gid, aid); boolean keep = starters.remove(id); if (!keep) { depsEl.removeChild(c); } } } } //if 'starters' is not empty at this point, it contains remaining ids we have not seen // in the pom, so we need to add them. for (MavenId mid : starters) { SpringBootStarter starter = getStarter(mid); createDependency(depsEl, starter.getDependency(), starter.getScope()); createBomIfNeeded(pom, starter.getBom()); createRepoIfNeeded(pom, starter.getRepo()); } } })); } catch (Throwable e) { throw ExceptionUtil.coreException(e); } }