Upgrade to a new version of Buildship to work with Java 9

I’m using the bundle Eclipse Java EE IDE for Web Developers (Oxygen 4.7.1a) that already comes with Buildship 2.1.2 installed. The problem is that I want to use Java 9 and Buildship displays this error:

java.lang.IllegalArgumentException: Could not determine java version from ‘9.0.1’

I’ve heard that this problem is already solved in Buildship 2.2.x, but I can’t upgrade to the newer version because it already comes installed. Is there a way to do this manually or some other way?

Just open the Eclipse marketplace from the IDE (Help > Eclipse Marketplace…) and search for Buildship. The UI is a bit tricky: if you click install then the button’s label will change to update.

Please note, that the Java 9 support was also added to Gradle recently, so your project should use the latest release.

Thank you. I was able now to upgrade. The buildship version now is 2.2.0.v20171211-1404. But unfortunately the problem remains. The ‘Gradle Tasks’ view is still showing the IllegalArgumentException error and I can’t import any Gradle existing projects: in the Import Preview window the Finish button is enabled but when you click on it nothing happens. Also, the Gradle project structure is not shown in this window. In my eclipse.ini file I’m pointing to a Java 9 installation like this:

-vm
C:\Java\jdk9\bin\javaw.exe

Could you try re-importing your project using Gradle 4.4?

If you’re talking about selecting ‘Specific Gradle version’ = 4.4 in the Import Options window, I’ve just done that and I still can’t import the project. The problems are the same: Finish button doesn’t work and project structure is not shown.

Yes, that’s what I meant. Sorry about not being specific enough.

The current Buildship version sometimes swallows the thrown exception, that could be a reason the UI seems empty. I’m working on this very problem at the moment.

To investigate further could you please check a few things:

  • Does this happen when you create a new Gradle project using the Create new Gradle project wizard?
  • Does the Error log view have a relevant log entry?
  • Do you see anything in the following log file: ${workspace_loc}/.metadata/.log?

Does this happen when you create a new Gradle project using the Create new Gradle project wizard?

Yes.

Does the Error log view have a relevant log entry?

Error: Failed to load preview.
Stack Trace:
java.lang.IllegalArgumentException: Could not determine java version from ‘9.0.1’.
at org.gradle.api.JavaVersion.toVersion(JavaVersion.java:70)
at org.gradle.api.JavaVersion.current(JavaVersion.java:80)

Warning: Launching Gradle tasks failed due to an error in the referenced Gradle build.
Stack Trace:
org.gradle.tooling.BuildException: Could not execute build using Gradle distribution ‘https://services.gradle.org/distributions/gradle-3.5-bin.zip’.
at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:51)
at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:29)

Do you see anything in the following log file: ${workspace_loc}/.metadata/.log?

Just messages like these:

!ENTRY org.eclipse.ui 4 0 2017-12-12 13:27:40.196
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.IllegalArgumentException: Could not determine java version from ‘9.0.1’.
at org.gradle.api.JavaVersion.toVersion(JavaVersion.java:70)
at org.gradle.api.JavaVersion.current(JavaVersion.java:80)

!ENTRY org.eclipse.buildship.ui 4 0 2017-12-12 13:27:37.782
!MESSAGE Failed to load preview.
!STACK 0
java.lang.IllegalArgumentException: Could not determine java version from ‘9.0.1’.
at org.gradle.api.JavaVersion.toVersion(JavaVersion.java:70)
at org.gradle.api.JavaVersion.current(JavaVersion.java:80)

Strange. I’ve done some manual testing and for me, everything works fine. Judging from the stack traces it can be two things:

  1. The Buildship update failed and you are still using the 2.1.2 version. I usually check it via the Host OSGi console (type ss buildship there to see the version numbers):

  1. You failed to configure your project to use Gradle 4.3 or 4.4. Your stack trace says

org.gradle.tooling.BuildException: Could not execute build using Gradle distribution ‘https://services.gradle.org/distributions/gradle-3.5-bin.zip’.

This seems unlikely though because you said you configured ‘Specific Gradle version’ = 4.4.

My Host OSGi console, confirming the 2.2 version is installed:

imagem

The 3.5 Gradle version in the stacktrace is from an old project that is already in the workspace. As I said, when I tried to import an existing project using Gradle 4.4 I got the errors mentioned. The same thing is true if I try to use the Gradle wrapper.

OK, we might have a problem here, your Eclipse should work correctly. I’ll try a few more things to reproduce the problem.

Just to remember, my environment was like this:

  • I downloaded the latest Eclipse IDE for Java EE Developers (Oxygen 4.7.1a) that comes with Buildship 2.1.2.
  • My eclipse.ini file points to a jdk 9 (-vm C:\Java\jdk9\bin\javaw.exe)
  • Then I upgraded to the 2.2 version of Buildship using the Eclipse Marketplace.

With this I can already see the error in the Gradle Tasks view. I don’t even need to import an existing Gradle project.

1 Like

I was able to overcome the problem by downloading a raw Eclipse version with only the core plugins and installing everything from scratch (EGit, WTP, JBoss Tools), even Buildship. So it worked. It seems that there was a problem upgrading Buildship from the Eclipse Marketplace.

I’m glad you’ve found a solution. Let’s see if the same problem pops up for someone else.

Is the marketplace the new default way to upgrade Buildship? I really liked letting Eclipse check for updates automatically (even doing so manually did not show the available Buildship update).