maven-tycho 0.20.0 and java8 source code


People writing e4/OSGi JavaFX application these days will most likely do it using JavaFX8 and probably they then make use of Java8 language features as well.

While the latest milestones of Eclipse 4.4 Luna have Java8 support with it your favorite build tool maven-tycho 0.20.0 for those applications is not yet directly supporting java8 because the compiler packaged with it is from the kepler repositories.

Yet e(fx)clipse which is using Java8 syntax itself is able to build so it must be possible and here’s a short description how we managed to get it work.

Install fresh version of jdt into your local m2 repo

I’m running the following commands on our hudson to get it recognize a newer jdt-version:

# install jdt-core
wget http://download.eclipse.org/eclipse/updates/4.4-I-builds/I20140512-2000/plugins/org.eclipse.jdt.core_3.10.0.v20140512-1116.jar
mvn install:install-file
-Dpackaging=jar -DgroupId=org.eclipse.tycho
-DartifactId=org.eclipse.jdt.core -Dversion=3.10.0.v20140512-1116
-Dfile=org.eclipse.jdt.core_3.10.0.v20140512-1116.jar

# install jdt-apt
wget http://download.eclipse.org/eclipse/updates/4.4-I-builds/I20140512-2000/plugins/org.eclipse.jdt.compiler.apt_1.1.0.v20140509-1235.jar
mvn install:install-file
-Dpackaging=jar -DgroupId=org.eclipse.tycho
-DartifactId=org.eclipse.jdt.compiler.apt -Dversion=1.1.0.v20140509-1235
-Dfile=org.eclipse.jdt.compiler.apt_1.1.0.v20140509-1235.jar

Force the maven compiler plugin to use the versions you installed to your local maven repo

You need to reconfigure your tycho-compiler-plugin

<!-- ... -->
<pluginManagement>
  <plugins>
    <plugin>
      <groupId>org.eclipse.tycho</groupId>
      <artifactId>tycho-compiler-plugin</artifactId>
      <version>${tycho-version}</version>
      <dependencies>
        <dependency>
          <groupId>org.eclipse.tycho</groupId>
          <artifactId>org.eclipse.jdt.core</artifactId>
          <version>3.10.0.v20140512-1116</version>
        </dependency>
        <dependency>
          <groupId>org.eclipse.tycho</groupId>
          <artifactId>org.eclipse.jdt.compiler.apt</artifactId>
          <version>1.1.0.v20140509-1235</version>
        </dependency>
      </dependencies>
      <configuration>
        <encoding>UTF-8</encoding>
        <extraClasspathElements>
          <extraClasspathElement>
            <groupId>com.oracle</groupId>
            <artifactId>javafx</artifactId>
            <version>8.0.0-SNAPSHOT</version>
            <systemPath>${java.home}/lib/jfxswt.jar</systemPath>
            <scope>system</scope>
          </extraClasspathElement>
        </extraClasspathElements> 
      </configuration>
    </plugin>
<!-- ... -->

Now your build is once more happy!

Advertisements
This entry was posted in e(fx)clipse, Eclipse. Bookmark the permalink.

3 Responses to maven-tycho 0.20.0 and java8 source code

  1. Hy Tom,

    why does this problem still exist with Luna release? Is this expected to change with an m2e update?

    thanks

  2. Markus says:

    Hi Tom,

    is it with tycho 0.22 and eclipse luna still necessary to add jfxswt.jar to the build-classpath (${java.home}/lib/jfxswt.jar) ?

    Regards,
    Markus

    • Tom Schindl says:

      Yes this has nothing to do with tycho but jfxswt.jar will never ever get on a default classpath where the compiler can pick it up.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s