javamavenmaven-compiler-pluginsystem-properties

Clear/unset a system property maven.compiler.release so that is is no longer present


I have a project with complicated build setup (parent POM's with parent POM's) and so it happens that my compiler plugin executes with maven.compiler.release=8.

This prevents me from setting source/target to Java 11 and I can't set release to 11 since I need to specify some --add-exports.

Is there a way to remove a system property in a profile so that it will not appear and my source/target switches would work? The best I could think of is setting maven.compiler.release to empty value but it won't work with compiler plugin.

How do I clear the system property in a profile? Alternatively, is there a way to trace who actually set it in the first place?


Solution

  • I had similar problem. Here is how to delete release property from parent POM and use --add-exports.

    Use the combine.self="override" attribute like this

        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <release combine.self="override"/>
                    <compilerArgs>
                        <arg>--add-exports</arg>
                        <arg>jdk.compiler/com.sun.tools.javac.api=ALL-NNAMED</arg>
                    </compilerArgs>
                    ...
    

    et, voila!