How do I find out Groovy runtime version from a running app?

前端 未结 2 1472
攒了一身酷
攒了一身酷 2021-02-02 05:54

I need to be able to find out the version of Groovy runtime via a groovy script. How do I do it? The examples I found on the net show a way, but apparently it has been deprecate

2条回答
  •  温柔的废话
    2021-02-02 06:27

    To improve slightly on tim_yates' answer, here's the universal code to get Groovy version:

    public String getGroovyVersion() {
            try {
                    return org.codehaus.groovy.runtime.InvokerHelper.version
            }
            catch (Throwable ignore) { }
            return GroovySystem.version
    }
    
    println getGroovyVersion()
    

提交回复
热议问题