Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 665
alamar Avatar asked Nov 02 '25 17:11

alamar


1 Answers

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!

like image 104
ocarlsen Avatar answered Nov 04 '25 06:11

ocarlsen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!