Index: build.xml
===================================================================
--- build.xml (revision 18359)
+++ build.xml (working copy)
@@ -467,8 +467,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: src/main/groovy/lang/GroovySystem.java
===================================================================
--- src/main/groovy/lang/GroovySystem.java (revision 18359)
+++ src/main/groovy/lang/GroovySystem.java (working copy)
@@ -15,6 +15,7 @@
*/
package groovy.lang;
+import org.codehaus.groovy.runtime.InvokerHelper;
import org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl;
import org.codehaus.groovy.util.ReferenceBundle;
@@ -78,4 +79,8 @@
ReferenceBundle.getSoftBundle().getManager().stopThread();
ReferenceBundle.getWeakBundle().getManager().stopThread();
}
+
+ public static String getVersion() {
+ return InvokerHelper.getVersion();
+ }
}
Index: src/main/META-INF/release-info.properties
===================================================================
--- src/main/META-INF/release-info.properties (revision 0)
+++ src/main/META-INF/release-info.properties (revision 0)
@@ -0,0 +1,4 @@
+ImplementationVersion=##ImplementationVersion##
+BundleVersion=##BundleVersion##
+BuildDate=##BuildDate##
+BuildTime=##BuildTime##
\ No newline at end of file
Index: src/main/org/codehaus/groovy/runtime/InvokerHelper.java
===================================================================
--- src/main/org/codehaus/groovy/runtime/InvokerHelper.java (revision 18359)
+++ src/main/org/codehaus/groovy/runtime/InvokerHelper.java (working copy)
@@ -44,6 +44,9 @@
public static final Object[] EMPTY_ARGS = {};
protected static final Object[] EMPTY_ARGUMENTS = EMPTY_ARGS;
protected static final Class[] EMPTY_TYPES = {};
+ private static Properties releaseInfo = new Properties();
+ private static String RELEASE_INFO_FILE = "META-INF/release-info.properties";
+ private static String KEY_VERSION = "ImplementationVersion";
public static final MetaClassRegistry metaRegistry = GroovySystem.getMetaClassRegistry();
@@ -446,15 +449,23 @@
}
public static String getVersion() {
- String version = null;
- Package p = Package.getPackage("groovy.lang");
- if (p != null) {
- version = p.getImplementationVersion();
+ String version = "";
+ if(releaseInfo.isEmpty()) {
+ populateReleaseInfo();
}
- if (version == null) {
- version = "";
+ version = releaseInfo.getProperty(KEY_VERSION);
+ return (version == null ? "" : version);
+ }
+
+ private static void populateReleaseInfo() {
+ InputStream is = InvokerHelper.class.getClassLoader().getResourceAsStream(RELEASE_INFO_FILE);
+ if(is != null) {
+ try {
+ releaseInfo.load(is);
+ } catch(IOException ioex) {
+ // ignore. In case of some exception, release info is not available
+ }
}
- return version;
}
/**
Index: src/test/groovy/lang/GroovySystemTest.groovy
===================================================================
--- src/test/groovy/lang/GroovySystemTest.groovy (revision 18359)
+++ src/test/groovy/lang/GroovySystemTest.groovy (working copy)
@@ -6,6 +6,7 @@
* Tests for the GroovySystem class
*
* @author Graeme Rocher
+ * @author Roshan Dawrani
**/
class GroovySystemTest extends GroovyTestCase {
@@ -14,4 +15,8 @@
assert GroovySystem.metaClassRegistry
assert GroovySystem.getMetaClassRegistry()
}
+
+ void testGroovyVersion() {
+ assert GroovySystem.getVersion()
+ }
}
\ No newline at end of file