org_scala_tools_maven_dependency.CheckScalaVersionVisitor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of maven-scala-plugin Show documentation
Show all versions of maven-scala-plugin Show documentation
The maven-scala-plugin is used for compiling/testing/running/documenting scala code in maven.
package org_scala_tools_maven_dependency;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.shared.dependency.tree.DependencyNode;
import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor;
import org_scala_tools_maven.VersionNumber;
import static org_scala_tools_maven_dependency.ScalaConstants.*;
/**
* Ensures that all scala versions match the given version.
* @author JSuereth
*
*/
public class CheckScalaVersionVisitor implements DependencyNodeVisitor {
private VersionNumber _version;
private boolean _failed = false;
private Log _log;
public boolean endVisit(DependencyNode node) {
return !_failed;
}
public CheckScalaVersionVisitor(String projectVerison, Log log) {
this._version = new VersionNumber(projectVerison);
this._log = log;
}
public boolean isScalaDistroArtifact(Artifact artifact) {
return SCALA_DISTRO_GROUP.equalsIgnoreCase(artifact.getGroupId()) &&
SCALA_DISTRO_ARTIFACTS.contains(artifact.getArtifactId());
}
public boolean visit(DependencyNode node) {
//TODO - Do we care about provided scope?
Artifact artifact = node.getArtifact();
_log.debug("checking ["+artifact+"] for scala version");
//TODO - Handle version ranges???? does that make sense given scala's binary incompatability!
if(isScalaDistroArtifact(artifact) && artifact.getVersion() != null) {
VersionNumber originalVersion = new VersionNumber(artifact.getVersion());
if(originalVersion.compareTo(_version) != 0) {
_failed = true;
}
} else {
//TODO - What now?
}
return !_failed;
}
public boolean isFailed() {
return _failed;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy