List of usage examples for org.springframework.ide.eclipse.boot.core IMavenCoordinates getGroupId
String getGroupId();
From source file:org.springframework.ide.eclipse.boot.core.internal.MavenSpringBootProject.java
/** * Determine the 'managed' version, if any, associate with a given dependency. * @return Version string or null./* ww w .j av a2 s .c o m*/ */ private String getManagedVersion(IMavenCoordinates dep) { try { MavenProject mp = getMavenProject(); if (mp != null) { DependencyManagement managedDeps = mp.getDependencyManagement(); if (managedDeps != null) { List<Dependency> deps = managedDeps.getDependencies(); if (deps != null && !deps.isEmpty()) { for (Dependency d : deps) { if ("jar".equals(d.getType())) { if (dep.getArtifactId().equals(d.getArtifactId()) && dep.getGroupId().equals(d.getGroupId())) { return d.getVersion(); } } } } } } } catch (Exception e) { BootActivator.log(e); } return null; }
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 ww w.j a v a2 s.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 .j a va2 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; }