Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable Explicit API mode for maven based Kotlin projects?

I would like to enable Explicit API mode for my Kotlin project. However, I cannot find a way how to do it. On the site, I can see only gradle based configuration:

kotlin {    
    // for strict mode
    explicitApi() 
    // or
    explicitApi = ExplicitApiMode.Strict
}
like image 580
Denis Avatar asked Sep 14 '25 18:09

Denis


1 Answers

I believe that you're using kotlin-maven-plugin, so you can pass additional arguments to compiler like this

<plugin>
    <groupId>org.jetbrains.kotlin</groupId>
    <artifactId>kotlin-maven-plugin</artifactId>
    <version>${kotlin.version}</version>
    <executions>...</executions>
    <configuration>
        <args>
            <arg>-Xexplicit-api=strict</arg> <!-- Enable explicit api mode -->
            ...
        </args>
    </configuration>
</plugin>

more info can be found here: https://kotlinlang.org/docs/reference/using-maven.html#specifying-compiler-options

like image 187
szymon_prz Avatar answered Sep 16 '25 09:09

szymon_prz