summaryrefslogtreecommitdiffstats
path: root/maven-plugins/trunk/maven-bundle-plugin/src/main
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-03-26 18:13:31 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-03-26 18:13:31 +0000
commite62a5ee21ef5124d3a50893fa8ee7dce7eefea57 (patch)
treee83cdd9dd6a3f0b7b35bec117ea6b33ac56c6deb /maven-plugins/trunk/maven-bundle-plugin/src/main
parent6fcc7fb8f40fc01cc37cb99b637c1f7e39d3af07 (diff)
Minor fix to tolerate - in the maven version id
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@758783 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'maven-plugins/trunk/maven-bundle-plugin/src/main')
-rw-r--r--maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/OSGIArtifactVersion.java405
1 files changed, 196 insertions, 209 deletions
diff --git a/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/OSGIArtifactVersion.java b/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/OSGIArtifactVersion.java
index 7c6e72e049..9d562381c1 100644
--- a/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/OSGIArtifactVersion.java
+++ b/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/OSGIArtifactVersion.java
@@ -1,6 +1,5 @@
-package org.apache.tuscany.maven.bundle.plugin;
-
/*
+ * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
@@ -8,7 +7,7 @@ package org.apache.tuscany.maven.bundle.plugin;
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
@@ -17,216 +16,204 @@ package org.apache.tuscany.maven.bundle.plugin;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.tuscany.maven.bundle.plugin;
import java.util.StringTokenizer;
import org.apache.maven.artifact.versioning.ArtifactVersion;
public class OSGIArtifactVersion implements ArtifactVersion {
- private Integer buildNumber;
-
- private Integer incrementalVersion;
-
- private Integer majorVersion;
-
- private Integer minorVersion;
-
- private String qualifier;
-
- private String unparsed;
-
- public OSGIArtifactVersion(String version) {
- parseVersion(version);
- }
-
- public int compareTo(Object o) {
- ArtifactVersion otherVersion = (ArtifactVersion) o;
-
- int result = getMajorVersion() - otherVersion.getMajorVersion();
- if (result == 0) {
- result = getMinorVersion() - otherVersion.getMinorVersion();
- }
- if (result == 0) {
- result = getIncrementalVersion() - otherVersion.getIncrementalVersion();
- }
- if (result == 0) {
- if (this.qualifier != null) {
- String otherQualifier = otherVersion.getQualifier();
-
- if (otherQualifier != null) {
- if ((this.qualifier.length() > otherQualifier.length())
- && this.qualifier.startsWith(otherQualifier)) {
- // here, the longer one that otherwise match is
- // considered older
- result = -1;
- }
- else if ((this.qualifier.length() < otherQualifier.length())
- && otherQualifier.startsWith(this.qualifier)) {
- // here, the longer one that otherwise match is
- // considered older
- result = 1;
- }
- else {
- result = this.qualifier.compareTo(otherQualifier);
- }
- }
- else {
- // otherVersion has no qualifier but we do - that's newer
- result = -1;
- }
- }
- else if (otherVersion.getQualifier() != null) {
- // otherVersion has a qualifier but we don't, we're newer
- result = 1;
- }
- else {
- result = getBuildNumber() - otherVersion.getBuildNumber();
- }
- }
- return result;
- }
-
- @Override
- public boolean equals(Object other) {
- if (this == other) {
- return true;
- }
-
- if (false == (other instanceof ArtifactVersion)) {
- return false;
- }
-
- return 0 == compareTo(other);
- }
-
- public int getBuildNumber() {
- return this.buildNumber != null ? this.buildNumber.intValue() : 0;
- }
-
- public int getIncrementalVersion() {
- return this.incrementalVersion != null ? this.incrementalVersion.intValue() : 0;
- }
-
- public int getMajorVersion() {
- return this.majorVersion != null ? this.majorVersion.intValue() : 0;
- }
-
- public int getMinorVersion() {
- return this.minorVersion != null ? this.minorVersion.intValue() : 0;
- }
-
- public String getQualifier() {
- return this.qualifier;
- }
-
- @Override
- public int hashCode() {
- int result = 1229;
-
- result = 1223 * result + getMajorVersion();
- result = 1223 * result + getMinorVersion();
- result = 1223 * result + getIncrementalVersion();
- result = 1223 * result + getBuildNumber();
-
- if (null != getQualifier()) {
- result = 1223 * result + getQualifier().hashCode();
- }
-
- return result;
- }
-
- public final void parseVersion(String version) {
- this.unparsed = version;
-
- int index = version.indexOf("-");
-
- String part1;
- String part2 = null;
-
- if (index < 0) {
- part1 = version;
- }
- else {
- part1 = version.substring(0, index);
- part2 = version.substring(index + 1);
- }
-
- if (part2 != null) {
- try {
- if ((part2.length() == 1) || !part2.startsWith("0")) {
- this.buildNumber = Integer.valueOf(part2);
- }
- else {
- this.qualifier = part2;
- }
- }
- catch (NumberFormatException e) {
- this.qualifier = part2;
- }
- }
-
- if ((part1.indexOf(".") < 0) && !part1.startsWith("0")) {
- try {
- this.majorVersion = Integer.valueOf(part1);
- }
- catch (NumberFormatException e) {
- // qualifier is the whole version, including "-"
- this.qualifier = version;
- this.buildNumber = null;
- }
- }
- else {
- StringTokenizer tok = new StringTokenizer(part1, ".");
-
- String s;
-
- if (tok.hasMoreTokens()) {
- s = tok.nextToken();
- try {
- this.majorVersion = Integer.valueOf(s);
-
- if (tok.hasMoreTokens()) {
- s = tok.nextToken();
- try {
- this.minorVersion = Integer.valueOf(s);
- if (tok.hasMoreTokens()) {
-
- s = tok.nextToken();
- try {
- this.incrementalVersion = Integer.valueOf(s);
-
- }
- catch (NumberFormatException e) {
- this.qualifier = s;
- }
- }
- }
- catch (NumberFormatException e) {
- this.qualifier = s;
- }
- }
- }
- catch (NumberFormatException e) {
- this.qualifier = s;
- }
- }
-
- if (tok.hasMoreTokens()) {
- StringBuffer qualifier = new StringBuffer(this.qualifier != null ? this.qualifier : "");
- qualifier.append(tok.nextToken());
- while (tok.hasMoreTokens()) {
- qualifier.append("_");
- qualifier.append(tok.nextToken());
- }
-
- this.qualifier = qualifier.toString();
- }
-
- }
- }
-
- @Override
- public String toString() {
- return this.unparsed;
- }
+ private Integer buildNumber;
+
+ private Integer incrementalVersion;
+
+ private Integer majorVersion;
+
+ private Integer minorVersion;
+
+ private String qualifier;
+
+ private String unparsed;
+
+ public OSGIArtifactVersion(String version) {
+ parseVersion(version);
+ }
+
+ public int compareTo(Object o) {
+ ArtifactVersion otherVersion = (ArtifactVersion)o;
+
+ int result = getMajorVersion() - otherVersion.getMajorVersion();
+ if (result == 0) {
+ result = getMinorVersion() - otherVersion.getMinorVersion();
+ }
+ if (result == 0) {
+ result = getIncrementalVersion() - otherVersion.getIncrementalVersion();
+ }
+ if (result == 0) {
+ if (this.qualifier != null) {
+ String otherQualifier = otherVersion.getQualifier();
+
+ if (otherQualifier != null) {
+ if ((this.qualifier.length() > otherQualifier.length()) && this.qualifier
+ .startsWith(otherQualifier)) {
+ // here, the longer one that otherwise match is
+ // considered older
+ result = -1;
+ } else if ((this.qualifier.length() < otherQualifier.length()) && otherQualifier
+ .startsWith(this.qualifier)) {
+ // here, the longer one that otherwise match is
+ // considered older
+ result = 1;
+ } else {
+ result = this.qualifier.compareTo(otherQualifier);
+ }
+ } else {
+ // otherVersion has no qualifier but we do - that's newer
+ result = -1;
+ }
+ } else if (otherVersion.getQualifier() != null) {
+ // otherVersion has a qualifier but we don't, we're newer
+ result = 1;
+ } else {
+ result = getBuildNumber() - otherVersion.getBuildNumber();
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+
+ if (false == (other instanceof ArtifactVersion)) {
+ return false;
+ }
+
+ return 0 == compareTo(other);
+ }
+
+ public int getBuildNumber() {
+ return this.buildNumber != null ? this.buildNumber.intValue() : 0;
+ }
+
+ public int getIncrementalVersion() {
+ return this.incrementalVersion != null ? this.incrementalVersion.intValue() : 0;
+ }
+
+ public int getMajorVersion() {
+ return this.majorVersion != null ? this.majorVersion.intValue() : 0;
+ }
+
+ public int getMinorVersion() {
+ return this.minorVersion != null ? this.minorVersion.intValue() : 0;
+ }
+
+ public String getQualifier() {
+ return this.qualifier;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 1229;
+
+ result = 1223 * result + getMajorVersion();
+ result = 1223 * result + getMinorVersion();
+ result = 1223 * result + getIncrementalVersion();
+ result = 1223 * result + getBuildNumber();
+
+ if (null != getQualifier()) {
+ result = 1223 * result + getQualifier().hashCode();
+ }
+
+ return result;
+ }
+
+ public final void parseVersion(String version) {
+ this.unparsed = version;
+
+ int index = version.indexOf("-");
+
+ String part1;
+ String part2 = null;
+
+ if (index < 0) {
+ part1 = version;
+ } else {
+ part1 = version.substring(0, index);
+ part2 = version.substring(index + 1);
+ }
+
+ if (part2 != null) {
+ try {
+ if ((part2.length() == 1) || !part2.startsWith("0")) {
+ this.buildNumber = Integer.valueOf(part2);
+ } else {
+ this.qualifier = part2;
+ }
+ } catch (NumberFormatException e) {
+ this.qualifier = part2;
+ }
+ }
+
+ if ((part1.indexOf(".") < 0) && !part1.startsWith("0")) {
+ try {
+ this.majorVersion = Integer.valueOf(part1);
+ } catch (NumberFormatException e) {
+ // qualifier is the whole version, including "-"
+ this.qualifier = version;
+ this.buildNumber = null;
+ }
+ } else {
+ StringTokenizer tok = new StringTokenizer(part1, ".");
+
+ String s;
+
+ if (tok.hasMoreTokens()) {
+ s = tok.nextToken();
+ try {
+ this.majorVersion = Integer.valueOf(s);
+
+ if (tok.hasMoreTokens()) {
+ s = tok.nextToken();
+ try {
+ this.minorVersion = Integer.valueOf(s);
+ if (tok.hasMoreTokens()) {
+
+ s = tok.nextToken();
+ try {
+ this.incrementalVersion = Integer.valueOf(s);
+
+ } catch (NumberFormatException e) {
+ this.qualifier = s;
+ }
+ }
+ } catch (NumberFormatException e) {
+ this.qualifier = s;
+ }
+ }
+ } catch (NumberFormatException e) {
+ this.qualifier = s;
+ }
+ }
+
+ if (tok.hasMoreTokens()) {
+ StringBuffer qualifier = new StringBuffer(this.qualifier != null ? this.qualifier : "");
+ qualifier.append(tok.nextToken());
+ while (tok.hasMoreTokens()) {
+ qualifier.append("_");
+ qualifier.append(tok.nextToken());
+ }
+
+ this.qualifier = qualifier.toString();
+ }
+
+ }
+ }
+
+ @Override
+ public String toString() {
+ return this.unparsed;
+ }
}