aboutsummaryrefslogtreecommitdiffstats
path: root/enforcer-rule
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
parent95a44b57760f4a9e656a5bf68421a66095306e97 (diff)
API refactoring.
Diffstat (limited to 'enforcer-rule')
-rw-r--r--enforcer-rule/pom.xml18
-rw-r--r--enforcer-rule/src/main/java/org/semver/enforcer/CheckVersionRule.java20
2 files changed, 13 insertions, 25 deletions
diff --git a/enforcer-rule/pom.xml b/enforcer-rule/pom.xml
index 55bf8fc..3d8227b 100644
--- a/enforcer-rule/pom.xml
+++ b/enforcer-rule/pom.xml
@@ -10,7 +10,7 @@
<parent>
<groupId>org.semver</groupId>
<artifactId>parent</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>0.9.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@@ -23,7 +23,7 @@
<dependency>
<groupId>org.semver</groupId>
<artifactId>api</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>0.9.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven.enforcer</groupId>
@@ -58,18 +58,4 @@
</dependency>
</dependencies>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
</project>
-
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);