aboutsummaryrefslogtreecommitdiffstats
path: root/enforcer-rule/src
diff options
context:
space:
mode:
authorJulien Eluard <[email protected]>2010-11-19 09:57:35 +0100
committerJulien Eluard <[email protected]>2010-11-19 09:57:35 +0100
commitae801320aa1ff89ebdec45559657db5f5841ba11 (patch)
tree8911755cb7269b6f705554910d00f7d3ab5a4f27 /enforcer-rule/src
parent95a44b57760f4a9e656a5bf68421a66095306e97 (diff)
API refactoring.
Diffstat (limited to 'enforcer-rule/src')
-rw-r--r--enforcer-rule/src/main/java/org/semver/enforcer/CheckVersionRule.java20
1 files changed, 11 insertions, 9 deletions
diff --git a/enforcer-rule/src/main/java/org/semver/enforcer/CheckVersionRule.java b/enforcer-rule/src/main/java/org/semver/enforcer/CheckVersionRule.java
index dd95e7d..4044c06 100644
--- a/enforcer-rule/src/main/java/org/semver/enforcer/CheckVersionRule.java
+++ b/enforcer-rule/src/main/java/org/semver/enforcer/CheckVersionRule.java
@@ -34,7 +34,9 @@ import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.StringUtils;
-import org.semver.Checker;
+import org.semver.Comparer;
+import org.semver.Delta;
+import org.semver.Dumper;
import org.semver.Version;
/**
@@ -68,11 +70,11 @@ public final class CheckVersionRule implements EnforcerRule {
private String[] excludes;
/**
- * Print changes details if current artifact is incompatible.
+ * Dump change details.
*
* @parameter
*/
- private boolean printDetails = false;
+ private boolean dumpDetails = false;
private Set<String> extractFilters(final String[] filtersAsStringArray) {
if (filtersAsStringArray == null) {
@@ -111,14 +113,14 @@ public final class CheckVersionRule implements EnforcerRule {
helper.getLog().info("Using <"+currentJar+"> as current JAR");
try {
- final Checker checker = new Checker();
- final Checker.CompatibilityType compatibilityType = checker.check(previousJar, currentJar, extractFilters(this.includes), extractFilters(this.excludes));
- final boolean compatible = Checker.isTypeCompatible(compatibilityType, previous.delta(current));
+ final Comparer comparer = new Comparer(previousJar, currentJar, extractFilters(this.includes), extractFilters(this.excludes));
+ final Delta delta = comparer.diff();
+ final boolean compatible = delta.validate(previous, current);
if (!compatible) {
- if (this.printDetails) {
- checker.dumpDiff(previousJar, currentJar, extractFilters(this.includes), extractFilters(this.excludes));
+ if (this.dumpDetails) {
+ Dumper.dump(delta);
}
- throw new EnforcerRuleException("Current codebase incompatible with version <"+current+">. Version should be at least <"+Checker.inferNextVersion(previous, compatibilityType)+">.");
+ throw new EnforcerRuleException("Current codebase incompatible with version <"+current+">. Version should be at least <"+delta.infer(previous)+">.");
}
} catch (IOException e) {
throw new EnforcerRuleException("Exception while checking compatibility: "+e.toString(), e);