List of usage examples for org.springframework.ide.eclipse.boot.core IMavenCoordinates getVersion
String getVersion();
From source file:org.springframework.ide.eclipse.boot.core.internal.MavenSpringBootProject.java
@Override public void addMavenDependency(final IMavenCoordinates dep, final boolean preferManagedVersion, final boolean optional) throws CoreException { try {//from w w w.ja v a2s. c o m IFile file = getPomFile(); performOnDOMDocument(new OperationTuple(file, new Operation() { public void process(Document document) { Element depsEl = getChild(document.getDocumentElement(), DEPENDENCIES); if (depsEl == null) { //TODO: handle this case } else { String version = dep.getVersion(); String managedVersion = getManagedVersion(dep); if (managedVersion != null) { //Decide whether we can/should inherit the managed version or override it. if (preferManagedVersion || managedVersion.equals(version)) { version = null; } } else { //No managed version. We have to include a version in xml added to the pom. } Element xmlDep = PomHelper.createDependency(depsEl, dep.getGroupId(), dep.getArtifactId(), version); if (optional) { createElementWithText(xmlDep, OPTIONAL, "true"); format(xmlDep); } } } })); } catch (Throwable e) { throw ExceptionUtil.coreException(e); } }
From source file:org.springframework.ide.eclipse.boot.core.internal.MavenSpringBootProject.java
/** * creates and adds new dependency to the parent. formats the result. *///from w w w .ja v a 2 s . c o m private Element createDependency(Element parentList, IMavenCoordinates info, String scope) { Element dep = createElement(parentList, DEPENDENCY); String groupId = info.getGroupId(); String artifactId = info.getArtifactId(); String version = info.getVersion(); String classifier = info.getClassifier(); if (groupId != null) { createElementWithText(dep, GROUP_ID, groupId); } createElementWithText(dep, ARTIFACT_ID, artifactId); if (version != null) { createElementWithText(dep, VERSION, version); } if (classifier != null) { createElementWithText(dep, CLASSIFIER, classifier); } if (scope != null && !scope.equals("compile")) { createElementWithText(dep, SCOPE, scope); } format(dep); return dep; }