List of usage examples for org.apache.maven.artifact.versioning VersionRange getSelectedVersion
public ArtifactVersion getSelectedVersion(Artifact artifact) throws OverConstrainedVersionException
From source file:org.automagic.deps.doctor.spy.PomSpyImpl.java
License:Apache License
@SuppressWarnings("unchecked") private boolean isLowerThanCurrent(TransitiveDependency newDependency, Optional<Node> currentVersionNode) throws InvalidVersionSpecificationException, OverConstrainedVersionException { String version = currentVersionNode.get().getTextContent().trim(); Optional<String> propertyName = getVersionPropertyName(version); if (propertyName.isPresent()) { Optional<Node> propertyNode = Utils.getNode("/project/properties/" + propertyName.get(), document); if (!propertyNode.isPresent()) { return false; }// w w w. j ava2 s . c o m version = propertyNode.get().getTextContent().trim(); } VersionRange versionRange = VersionRange.createFromVersionSpec(version); ArtifactVersion currentVersion = versionRange.getSelectedVersion(newDependency.getArtifact()); int result = newDependency.getVersion().compareTo(currentVersion); return result < 0; }