Skip to content

Commit 417fa41

Browse files
committed
feat: jsr305 compat for kotlinc
- feat: treat jsr305 as strict - feat: consider pkl's annotations for jsr305 compat Signed-off-by: Sam Gammon <sam@elide.dev>
1 parent 8cfd235 commit 417fa41

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

buildSrc/src/main/kotlin/pklKotlinLibrary.gradle.kts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616
import org.gradle.accessors.dm.LibrariesForLibs
17+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
18+
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
1719

1820
plugins {
1921
id("pklJavaLibrary")
@@ -38,3 +40,26 @@ dependencies {
3840
tasks.compileKotlin {
3941
enabled = true // disabled by pklJavaLibrary
4042
}
43+
44+
tasks.withType<KotlinJvmCompile>().configureEach {
45+
compilerOptions {
46+
// must match the minimum JVM bytecode target for Pkl
47+
jvmTarget = JvmTarget.JVM_17
48+
49+
// enable java parameter names for stronger Kotlin-Java interop and debugging
50+
javaParameters = true
51+
52+
// consider kotlin warnings errors if not otherwise suppressed
53+
allWarningsAsErrors = true
54+
55+
freeCompilerArgs.addAll(
56+
listOf(
57+
// enable strict nullability checking and integration with pkl's own annotations
58+
"-Xjsr305=strict",
59+
"-Xjsr305=@org.pkl.core.util.Nullable:strict",
60+
"-Xjsr305=@org.pkl.core.util.Nonnull:strict",
61+
)
62+
)
63+
}
64+
}
65+

0 commit comments

Comments
 (0)