Stefan S.
Stefan S.

Reputation: 4103

Add Argument "--add-modules" to Tycho Compiler

I inherited a Tycho projekt which gets built with Java 8 but runs with Java 10. For reasons it should now be built with Java 10 as well. The problem is with all the missing JDK bundles with exceptions like

[ERROR] The type javax.xml.bind.annotation.XmlElementWrapper cannot be resolved. It is indirectly referenced from required .class files

I now want to add --add-modules=ALL-SYSTEM to the Tycho compiler (like it already is in the *.product file). However that doesn't seem possible. I tried:

<plugin>
    <groupId>org.eclipse.tycho</groupId>
    <artifactId>tycho-compiler-plugin</artifactId>
    <version>${tycho-version}</version>
    <configuration>
        <argLine>--add-modules=ALL-SYSTEM</argLine>
        <compilerArgument>--add-modules=ALL-SYSTEM</compilerArgument>
        <compilerArgs><compilerArg>-add-modules=ALL-SYSTEM</compilerArg></compilerArgs>
    </configuration>
</plugin>

Adding the dependency to Maven (I hoped this would bypass the need for an import package) and pomDependencies=consider:

<dependencies>
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.2.8</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

Aaand of course something like just passing it as a VM argument. Nothing works.

Most questions for this subject only focus on how stupid the idea is (it indubitably is), but there is no time to switch the project over to Java 10 (or something a bit more up-to-date).

So how do I add compiler arguments to Tycho?

Upvotes: 2

Views: 918

Answers (1)

pitseeker
pitseeker

Reputation: 2543

You can configure compiler arguments like this:

<plugin>
    <groupId>org.eclipse.tycho</groupId>
    <artifactId>tycho-compiler-plugin</artifactId>
    <version>${tycho-version}</version>
    <configuration>
       <compilerArgs>
          <arg>--module-path</arg>
          <arg>${java.home}/jmods</arg>
          <arg>--add-modules</arg>
          <arg>java.smartcardio</arg>
       </compilerArgs>
    </configuration>
</plugin>

See also this question and this bug report. They deal with the problem telling the java compiler to find the modules.

Upvotes: 1

Related Questions