如何为基于 Maven 的 Kotlin 项目启用显式 API 模式?
How to enable Explicit API mode for maven based Kotlin projects?
我想为我的 Kotlin 项目启用 Explicit API mode。但是,我找不到如何去做的方法。在网站上,我只能看到基于 gradle
的配置:
kotlin {
// for strict mode
explicitApi()
// or
explicitApi = ExplicitApiMode.Strict
}
我相信您正在使用 kotlin-maven-plugin
,因此您可以像这样向编译器传递额外的参数
<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>
可以在此处找到更多信息:https://kotlinlang.org/docs/reference/using-maven.html#specifying-compiler-options
我想为我的 Kotlin 项目启用 Explicit API mode。但是,我找不到如何去做的方法。在网站上,我只能看到基于 gradle
的配置:
kotlin {
// for strict mode
explicitApi()
// or
explicitApi = ExplicitApiMode.Strict
}
我相信您正在使用 kotlin-maven-plugin
,因此您可以像这样向编译器传递额外的参数
<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>
可以在此处找到更多信息:https://kotlinlang.org/docs/reference/using-maven.html#specifying-compiler-options