Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wondering how to use Groovy 2.3 with Netbeans 8?

I am disappointed when I installed Groovy 2.3 I discover that I can't use it with Netbeans 8. Why? Because the Netbeans Groovy support is fixed on the build-in Groovy 2.1. This is in contrast with the way Netbeans supports Ruby, JRuby, Java... Where you can add a different platforms.

--[ update 2016-10-14 ]--

I went through this exercise for Netbeans 8.2. The results are confused to say the least. I think Netbeans would benefit by having a Tools menu item like the Java platform option to manage different Groovy platform(s). Or use GROOVY_HOME

On this PC the installed Groovy is:

  • Groovy 2.4.7
    • one groovy Jar - groovy-all-2.4.7.jar
  • Java 8 u102

This is quite strange. The Groovy library in the Netbeans Libraries list was:

  • Groovy 2.1.7
    • groovy-all

I actually removed this from the Library list and replaced it with the groovy-all 2.4.7.

I added this line to a Groovy main class ...

  println  "Groovy version: "+ GroovySystem.version;
  println  "Java version:   "+ System.getProperty("java.version");

The output:

 Groovy version: 2.1.3
 Java version:   1.8.0_102

I have been looking further. The Netbeans log show me that the Groovy module loaded was:

  "Groovy 2.1.7"
  jar:nbinst://org.netbeans.modules.libs.groovy/modules/ext/groovy-all.jar!/

I checked that file, this JAR file reports its version:

 java -jar /opt/dev/netbeans/home/groovy/modules/ext/groovy-all.jar  -version
  Groovy Version: 2.4.5 JVM: 1.8.0_102 Vendor: Oracle Corporation OS: Linux

Ergo the label: "2.1.7" was out of date.

The thing to wonder about is WHERE does the groovy 2.1.3 come from when I run my Groovy from Netbeans?

--[ end update ]--

I scanned other Stackoverflow questions touching on this from earlier Netbeans versions. The consensus I gathered was that you can "hack" at the way the bundled Groovy version is installed and it should work. A Groovy release is more than just one JAR file so that doesn't seem like enough to me. There ought therefore be more things to do for swapping-in a newer version of Groovy. In addition, this procedure means that one cannot use two different Groovy profiles with Netbeans.

  • How to use Groovy 2.0 in netbeans
  • Groovy Support in NetBeans IDE
  • Groovy support in NetBeans

It can't be said that Netbeans could not support multiple versions of Groovy as it does for Ruby and for Java -- The IntelliJ IDEA does as does Eclipse.

I'm hoping someone comes with a suggestion for a complete swap-in to replace Groovy 2.1 with Groovy 2.3.

Alternatively has anyone seen a "language support" plugin similar to the Ruby platforms and Java platforms for language support, or a more general way to run scripts as external tools, Gradle or via Maven? I definitely think it is a limited way to support scripting languages to just rely on a bundled-in single version. It means a project will be stuck with 'old' language bugs and other issues just because of a lack of flexibility in an IDE.

like image 909
will Avatar asked Nov 10 '22 04:11

will


1 Answers

To use Groovy 2.4.3 in my projects, I followed the instructions in the Groovy tab at Tools > Options > Miscellaneous:

  1. Download Groovy 2.4.3 binary distro from groovy-lang.org
  2. Create new Groovy 2.4.3 class library in Tools > Libraries
  3. Set library's Classpath jar to groovy-2.4.3/embeddable/groovy-all-2.4.3.jar
like image 98
Joe Bowbeer Avatar answered Nov 14 '22 21:11

Joe Bowbeer