aboutsummaryrefslogtreecommitdiffstats
path: root/enforcer-rule
diff options
context:
space:
mode:
authorJulien Eluard <[email protected]>2010-11-16 21:54:30 +0100
committerJulien Eluard <[email protected]>2010-11-16 21:54:30 +0100
commitfa6259440847e721ef6ee21b79f57c7e8bd36c3f (patch)
tree02eb9fabe78f9fa1c8159062b2dd503608402ff6 /enforcer-rule
parentd88dfa22db5fe11c69b2749b0bcc02930ae67e3f (diff)
Added printDetails option.
Diffstat (limited to 'enforcer-rule')
-rw-r--r--enforcer-rule/src/main/java/org/semver/enforcer/CheckVersionRule.java26
1 files changed, 19 insertions, 7 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 d1c1283..dd95e7d 100644
--- a/enforcer-rule/src/main/java/org/semver/enforcer/CheckVersionRule.java
+++ b/enforcer-rule/src/main/java/org/semver/enforcer/CheckVersionRule.java
@@ -67,6 +67,13 @@ public final class CheckVersionRule implements EnforcerRule {
*/
private String[] excludes;
+ /**
+ * Print changes details if current artifact is incompatible.
+ *
+ * @parameter
+ */
+ private boolean printDetails = false;
+
private Set<String> extractFilters(final String[] filtersAsStringArray) {
if (filtersAsStringArray == null) {
return Collections.emptySet();
@@ -100,17 +107,22 @@ public final class CheckVersionRule implements EnforcerRule {
final File previousJar = previousArtifact.getFile();
final Version current = Version.parse(currentArtifact.getVersion());
final File currentJar = currentArtifact.getFile();
- final Checker.CompatibilityType compatibilityType;
+ helper.getLog().info("Using <"+previousJar+"> as previous JAR");
+ helper.getLog().info("Using <"+currentJar+"> as current JAR");
+
try {
- compatibilityType = new Checker().check(previousJar, currentJar, extractFilters(this.includes), extractFilters(this.excludes));
+ 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));
+ if (!compatible) {
+ if (this.printDetails) {
+ checker.dumpDiff(previousJar, currentJar, extractFilters(this.includes), extractFilters(this.excludes));
+ }
+ throw new EnforcerRuleException("Current codebase incompatible with version <"+current+">. Version should be at least <"+Checker.inferNextVersion(previous, compatibilityType)+">.");
+ }
} catch (IOException e) {
throw new EnforcerRuleException("Exception while checking compatibility: "+e.toString(), e);
}
- final boolean compatible = Checker.isTypeCompatible(compatibilityType, previous.delta(current));
- if (!compatible) {
- throw new EnforcerRuleException("Current codebase incompatible with version <"+current+">. Version should be at least <"+Checker.inferNextVersion(previous, compatibilityType)+">.");
- }
-
}
/**