aboutsummaryrefslogtreecommitdiffstats
path: root/enforcer-rule
diff options
context:
space:
mode:
authorJulien Eluard <[email protected]>2011-09-13 00:10:21 -0700
committerJulien Eluard <[email protected]>2011-09-13 00:10:21 -0700
commit37a8a5cbc5d9d941b5e96665ef0409b0999c5ee0 (patch)
tree74d7629461cebfd69ba4772ceff066956cdd1566 /enforcer-rule
parente4e8186f31410d9147d80d30c0bcdc1314a85382 (diff)
Added support for Maven/OSGI version scheme.
Diffstat (limited to 'enforcer-rule')
-rwxr-xr-xenforcer-rule/pom.xml9
-rwxr-xr-xenforcer-rule/src/main/java/org/semver/enforcer/AbstractEnforcerRule.java28
2 files changed, 10 insertions, 27 deletions
diff --git a/enforcer-rule/pom.xml b/enforcer-rule/pom.xml
index 37dad2d..469987f 100755
--- a/enforcer-rule/pom.xml
+++ b/enforcer-rule/pom.xml
@@ -3,7 +3,6 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>enforcer-rule</artifactId>
- <packaging>jar</packaging>
<name>Enforcer Rule</name>
@@ -15,15 +14,15 @@
</parent>
<properties>
- <api.version>1.0-beta-1</api.version>
- <maven.version>2.0.9</maven.version>
+ <api.version>1.0.1</api.version>
+ <maven.version>2.2.1</maven.version>
</properties>
<dependencies>
<dependency>
<groupId>org.semver</groupId>
<artifactId>api</artifactId>
- <version>0.9.9-SNAPSHOT</version>
+ <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.enforcer</groupId>
@@ -53,7 +52,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.8.2</version>
+ <version>4.9</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/enforcer-rule/src/main/java/org/semver/enforcer/AbstractEnforcerRule.java b/enforcer-rule/src/main/java/org/semver/enforcer/AbstractEnforcerRule.java
index d276b7f..4f5a6f6 100755
--- a/enforcer-rule/src/main/java/org/semver/enforcer/AbstractEnforcerRule.java
+++ b/enforcer-rule/src/main/java/org/semver/enforcer/AbstractEnforcerRule.java
@@ -52,7 +52,6 @@ import org.semver.Version;
*/
public abstract class AbstractEnforcerRule implements EnforcerRule {
- private static final String SNAPSHOT_VERSION_SUFFIX = "-SNAPSHOT";
private static final String JAR_ARTIFACT_TYPE = "jar";
/**
@@ -99,8 +98,8 @@ public abstract class AbstractEnforcerRule implements EnforcerRule {
throw new EnforcerRuleException("Failed to access ${project} variable", e);
}
final String type = project.getArtifact().getType();
- if (!JAR_ARTIFACT_TYPE.equals(type)) {
- helper.getLog().debug("Skipping non "+JAR_ARTIFACT_TYPE+" artifact.");
+ if (!AbstractEnforcerRule.JAR_ARTIFACT_TYPE.equals(type)) {
+ helper.getLog().debug("Skipping non "+AbstractEnforcerRule.JAR_ARTIFACT_TYPE+" artifact.");
return;
}
@@ -139,9 +138,9 @@ public abstract class AbstractEnforcerRule implements EnforcerRule {
throw new EnforcerRuleException("Exception while accessing artifacts", e);
}
- final Version previous = Version.parse(getVersion(previousArtifact));
+ final Version previous = Version.parse(previousArtifact.getVersion());
final File previousJar = previousArtifact.getFile();
- final Version current = Version.parse(getVersion(currentArtifact));
+ final Version current = Version.parse(currentArtifact.getVersion());
final File currentJar = currentArtifact.getFile();
helper.getLog().info("Using <"+previousJar+"> as previous JAR");
@@ -166,22 +165,6 @@ public abstract class AbstractEnforcerRule implements EnforcerRule {
throw new EnforcerRuleException(message);
}
- protected final String getVersion(final Artifact artifact) {
- final String version = artifact.getVersion();
- if (version.contains(AbstractEnforcerRule.SNAPSHOT_VERSION_SUFFIX)) {
- return version.substring(0, version.indexOf(AbstractEnforcerRule.SNAPSHOT_VERSION_SUFFIX));
- }
- return version;
- }
-
- /**
- * @param artifactVersion
- * @return true if specified version is a snapshot version
- */
- protected final boolean isSnapshotVersion(final ArtifactVersion artifactVersion) {
- return artifactVersion.toString().endsWith(AbstractEnforcerRule.SNAPSHOT_VERSION_SUFFIX);
- }
-
/**
* @param artifactMetadataSource
* @param project
@@ -194,10 +177,11 @@ public abstract class AbstractEnforcerRule implements EnforcerRule {
availableVersions.remove(new DefaultArtifactVersion(project.getArtifact().getVersion()));
for (final Iterator<ArtifactVersion> iterator = availableVersions.iterator(); iterator.hasNext();) {
final ArtifactVersion artifactVersion = iterator.next();
- if (isSnapshotVersion(artifactVersion)) {
+ if (Version.parse(artifactVersion.toString()).isSnapshot()) {
iterator.remove();
}
}
+ //TODO proper sorting based on Version
Collections.sort(availableVersions);
Collections.reverse(availableVersions);
return availableVersions;