Skip to content

Commit

Permalink
Add the 2.1 version to SpecifiedVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Eisenberg committed Feb 5, 2013
1 parent cdf9c0d commit d8e53ef
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
import org.osgi.framework.Version; import org.osgi.framework.Version;


public enum SpecifiedVersion { public enum SpecifiedVersion {
_16(1, 6, "16"), _17(1, 7, "17"), _18(1, 8, "18"), _19(1, 9, "19"), _20(2, 0, "20"), _21(2,1,"21"),UNSPECIFIED(-1, -1, "0"); _16(1, 6, "16"), _17(1, 7, "17"), _18(1, 8, "18"),
_19(1, 9, "19"), _20(2, 0, "20"), _21(2,1,"21"),
_22(2,2,"22"),UNSPECIFIED(-1, -1, "0");
public final int majorVersion; public final int majorVersion;
public final int minorVersion; public final int minorVersion;
public final String versionName; public final String versionName;
Expand Down Expand Up @@ -63,6 +65,9 @@ public static SpecifiedVersion findVersionFromString(String compilerLevel) {
if ("21".equals(compilerLevel) || "2.1".equals(compilerLevel)) { if ("21".equals(compilerLevel) || "2.1".equals(compilerLevel)) {
return _21; return _21;
} }
if ("22".equals(compilerLevel) || "2.2".equals(compilerLevel)) {
return _22;
}
if ("0".equals(compilerLevel)) { if ("0".equals(compilerLevel)) {
return UNSPECIFIED; return UNSPECIFIED;
} }
Expand All @@ -77,6 +82,12 @@ public static SpecifiedVersion findVersion(Version ver) {
if (ver.getMinor() == 0) { if (ver.getMinor() == 0) {
return _20; return _20;
} }
if (ver.getMinor() == 1) {
return _21;
}
if (ver.getMinor() == 2) {
return _22;
}
} }
if (ver.getMajor() == 1) { if (ver.getMajor() == 1) {
if (ver.getMinor() == 6) { if (ver.getMinor() == 6) {
Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,6 @@
/* /*
* Copyright 2011 SpringSource, a division of VMware, Inc * Copyright 2011 SpringSource, a division of VMware, Inc
* *
* andrew - Initial API and implementation * andrew - Initial API and implementation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -20,7 +20,8 @@
import org.osgi.framework.Version; import org.osgi.framework.Version;


public enum SpecifiedVersion { public enum SpecifiedVersion {
_16(1, 6, "16"), _17(1, 7, "17"), _18(1, 8, "18"), _19(1, 9, "19"), _20(2, 0, "20"), UNSPECIFIED(-1, -1, "0"); _16(1, 6, "16"), _17(1, 7, "17"), _18(1, 8, "18"), _19(1, 9, "19"), _20(2, 0, "20"), _21(2, 1, "21"), _22(2, 2, "22"), UNSPECIFIED(
-1, -1, "0");
public final int majorVersion; public final int majorVersion;
public final int minorVersion; public final int minorVersion;
public final String versionName; public final String versionName;
Expand All @@ -30,21 +31,21 @@ public enum SpecifiedVersion {
this.minorVersion = minorVersion; this.minorVersion = minorVersion;
this.versionName = versionName; this.versionName = versionName;
} }

public String toVersionString() { public String toVersionString() {
return "[" + majorVersion + "." + minorVersion + "." + 0 + "," + majorVersion + "." + minorVersion + "." + 99 + ")"; return "[" + majorVersion + "." + minorVersion + "." + 0 + "," + majorVersion + "." + minorVersion + "." + 99 + ")";
} }

public String toReadableVersionString() { public String toReadableVersionString() {
return majorVersion + "." + minorVersion + ".X"; return majorVersion + "." + minorVersion + ".X";
} }


public static SpecifiedVersion findVersionFromString(String compilerLevel) { public static SpecifiedVersion findVersionFromString(String compilerLevel) {
if (compilerLevel == null) { if (compilerLevel == null) {
return UNSPECIFIED; return UNSPECIFIED;
} }

if ("16".equals(compilerLevel) || "1.6".equals(compilerLevel)) { if ("16".equals(compilerLevel) || "1.6".equals(compilerLevel)) {
return _16; return _16;
} }
Expand All @@ -60,12 +61,18 @@ public static SpecifiedVersion findVersionFromString(String compilerLevel) {
if ("20".equals(compilerLevel) || "2.0".equals(compilerLevel)) { if ("20".equals(compilerLevel) || "2.0".equals(compilerLevel)) {
return _20; return _20;
} }
if ("21".equals(compilerLevel) || "2.1".equals(compilerLevel)) {
return _21;
}
if ("22".equals(compilerLevel) || "2.2".equals(compilerLevel)) {
return _22;
}
if ("0".equals(compilerLevel)) { if ("0".equals(compilerLevel)) {
return UNSPECIFIED; return UNSPECIFIED;
} }

// this is an error prevent startup // this is an error prevent startup
throw new IllegalArgumentException("Invalid Groovy compiler level specified: " + compilerLevel + throw new IllegalArgumentException("Invalid Groovy compiler level specified: " + compilerLevel +
"\nMust be one of 16, 1.6, 17, 1.7, 18, 1.8, 19, 1.9, 20, or 2.0"); "\nMust be one of 16, 1.6, 17, 1.7, 18, 1.8, 19, 1.9, 20, or 2.0");
} }


Expand All @@ -74,6 +81,12 @@ public static SpecifiedVersion findVersion(Version ver) {
if (ver.getMinor() == 0) { if (ver.getMinor() == 0) {
return _20; return _20;
} }
if (ver.getMinor() == 1) {
return _21;
}
if (ver.getMinor() == 2) {
return _22;
}
} }
if (ver.getMajor() == 1) { if (ver.getMajor() == 1) {
if (ver.getMinor() == 6) { if (ver.getMinor() == 6) {
Expand Down

0 comments on commit d8e53ef

Please sign in to comment.