How to set Java compiler compatibility in a Tycho build?

Viewed 347

I am using Tycho to build an RCP application. The build runs in a Gitlab CI script on a Windows Runner. The app is setup to run at Java 8 level due to some components in one of the plugins. The runner uses OpenJDK 12. At the moment, this causes compiler errors.

How can I set the source and target compiler level for the build?

I have tried setting the following in the parent pom:

<properties>
    <tycho.version>1.5.1</tycho.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

and also

<plugins>
    <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-compiler-plugin</artifactId>
        <version>${tycho.version}</version>
        <configuration>
            <compilerVersion>1.8</compilerVersion>
            <source>1.8</source>
            <target>1.8</target>
        </configuration>
    </plugin>
</plugins>

but I still get compiler errors such as JAXBElement cannot be resolved to a type.

1 Answers

You'll have to set execution environment on the overview tab of the MANIFEST.MF file. Tycho will infer maven properties from there.

...
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
...
Related