An API incompatibility was encountered while executing com.github.gantsign.maven:ktlint-maven-plugin:1.13.1:format

1.4k Views Asked by At

I added a ktlint plugin to my project, but getting this error when running mvn clean install

            <plugin>
                <groupId>com.github.gantsign.maven</groupId>
                <artifactId>ktlint-maven-plugin</artifactId>
                <version>1.13.1</version>
                <executions>
                    <execution>
                        <id>format-and-check</id>
                        <goals>
                            <goal>format</goal>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

An API incompatibility was encountered while executing com.github.gantsign.maven:ktlint- maven-plugin:1.13.1:format: java.lang.ExceptionInInitializerError: null

and

Unable to make field private transient java.lang.Object java.lang.Throwable.backtrace accessible: module java.base does not "opens java.lang" to unnamed module @4a76c90

versions:

 <java.version>17</java.version>
 <kotlin.version>1.6.21</kotlin.version>

What should I check here? How to find what is conflicting?

1

There are 1 best solutions below

0
On

See the README.md here - https://github.com/gantsign/ktlint-maven-plugin

Java 17 is the first LTS release to enforce strong encapsulation. For ktlint to work we need to add --add-opens java.base/java.lang=ALL-UNNAMED to the JVM arguments.

We recommend that you add a .mvn/jvm.config file (relative to the top level project directory) to all of your projects using this plugin. The file should have the following contents:

--add-opens java.base/java.lang=ALL-UNNAMED