I’m developing a library in Kotlin, and as it is best practise, I enabled explicit API mode in my gradle buildscript:
kotlin {
explicitApi()
}
Now, for this library I also generate source code with the openapitools/kotlin-gradle generator (which is IMO flawed in a lot of ways anyway) and I put the generated files into build/generated/openapi/main/kotlin
which I marked as a source set by doing:
sourceSets {
main {
kotlin.setSrcDirs(kotlin.srcDirs + "$projectDir/build/generated/openapi/main/kotlin")
}
}
However, my project doesn’t compile because the generated sources don’t comply with explicit API mode (declarations aren’t explicitly marked public
), which is fine for me. But I’d like to know if there’s any way to exclude generated sources from the explicit API checks, because it’s currently failing my build. As I see it currently, I have three options:
- Find some way to exclude my generated sources from the explicit API checks (which I don’t know if that’s possible, hopefully someone can answer me this)
- Disable explicit API mode entirely (which would be quite sad because I do believe it helps me a lot to keep my API clean)
- Switch to generating Java POJOs instead (which I really don’t want to do, because I quite enjoy the extra type safety that OpenAPI required → Kotlin non-nullable brings)