Upgrading and open sourcing the Gluon plugin for Eclipse


Using Gluon Mobile, Java developers can create mobile apps (for Android and iOS) using Java. The Gluon Plugin for IDEs makes it very easy to use Gluon Mobile. Gluon provides the Gluon plugin for your favorite IDEs: NetBeans, IntelliJ and Eclipse. You can find details about each of them in our documentation.

While NetBeans and IntelliJ versions have been recently updated (see the news about using the plugin to create Gluon Function projects), the Eclipse plugin was a little bit outdated.

With the recent release of Eclipse Oxygen, the use of Gradle Buildship 2+ caused a failure in the Eclipse plugin that was relying on Buildship 1+.

At this point, revamping the Eclipse plugin was in order. Today we are happy to announce that not only we have a brand new version, but we have also open sourced the plugin! The plugin source code is available in our GitHub repository. Also, as per usual, you’ll find the plugin directly in the Eclipse Marketplace.

Installation

If you are running the latest Eclipse Oxygen version, go to the Marketplace and search for Gluon.

Click install, accept the license, and when the installation finishes, click on restart now.

Once Eclipse opens again, to create a Gluon project click on New, open the Gluon folder and select one of the different templates available.

When the project is created, you can access the gradle tasks, by selecting Windows->Show View->Other->Gradle Tasks. There is a small down arrow icon to the right of the Gradle Tasks window, click on it and select Show All Tasks. This is required to display the Other category, that gives access to Android (android, androidInstall) or iOS (launchIOSDevice, launchIPhoneSimulator) tasks.

Now you can select any of these tasks to run your project on desktop or deploy it to mobile.

JDK requirements

Java 8

If you haven’t installed Java 9 yet, Eclipse will run on the JDK 8 version you have installed on your system, and the Gluon plugin will work as usual, creating projects that will run on desktop and can be deployed to mobile devices.

Java 9

If you have JDK 9 installed on your machine and you install Eclipse afterwards, it will be set as the default JDK, and that’s the JDK that the IDE will use.

There are two possible scenarios here:

I want to run on desktop and deploy to mobile

For Gluon Mobile projects that make use of the current jfxmobile plugin and dependencies (i.e. charm 4.4.1), JDK8 is still required. That means we need to modify Eclipse to run on 8.

For that, we have to set JDK8 as default by editing the eclipse.ini file, and modifying the vm parameter with a valid path:

-vm
/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home/bin

Save the changes and open Eclipse again. Then edit Eclipse Preferences, go to Java->Installed JREs, and select the same JDK8. And also to go to Java->Compiler, and set Compiler compliance level to 1.8.

I want to run Java 9

While we wait a little bit for Gluon VM to deploy mobile applications with Java 9, you can use Gluon Mobile dependency for Java 9:

dependencies {
compile 'com.gluonhq:charm:4.4.0-jdk9'
}

This will let you run your mobile project on desktop with Java 9.

Conclusions

If you are an Eclipse user, and you were using the Gluon plugin, make sure you update it. If you weren’t, give it a try and install it now from the Marketplace.

We are working on adding more features to the plugin, so stay tuned for updates.

In the meantime, start using it to create new exciting mobile projects, or check existing projects from our samples list.