File tree Expand file tree Collapse file tree 6 files changed +26
-0
lines changed
gradle-conventions/src/main/kotlin Expand file tree Collapse file tree 6 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
77plugins {
88 alias(libs.plugins.conventions.jvm)
99 alias(libs.plugins.compiler.specific.module)
10+ alias(libs.plugins.conventions.no.psi.element)
1011}
1112
1213kotlin {
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
77plugins {
88 alias(libs.plugins.conventions.jvm)
99 alias(libs.plugins.compiler.specific.module)
10+ alias(libs.plugins.conventions.no.psi.element)
1011}
1112
1213kotlin {
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
77plugins {
88 alias(libs.plugins.conventions.jvm)
99 alias(libs.plugins.compiler.specific.module)
10+ alias(libs.plugins.conventions.no.psi.element)
1011}
1112
1213kotlin {
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import util.whenKotlinCompilerIsAtLeast
1010plugins {
1111 alias(libs.plugins.conventions.jvm)
1212 alias(libs.plugins.compiler.specific.module)
13+ alias(libs.plugins.conventions.no.psi.element)
1314}
1415
1516tasks.jar {
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+ */
4+
5+ import kotlin.io.path.readLines
6+
7+ gradle.afterProject {
8+ layout.projectDirectory.dir(" src" ).asFileTree.visit {
9+ if (isDirectory) return @visit
10+ if (file.name.endsWith(" .kt" )) {
11+ file.toPath().readLines().forEach { line ->
12+ if (! line.trim().startsWith(" //" ) && line.contains(" PsiElement" )) {
13+ throw GradleException (
14+ " Kotlin source file $file must not contain `PsiElement` reference " +
15+ " in the compiler plugin. Use KtElement instead."
16+ )
17+ }
18+ }
19+ }
20+ }
21+ }
Original file line number Diff line number Diff line change @@ -159,6 +159,7 @@ conventions-npm = { id = "conventions-npm" }
159159conventions-root = { id = " conventions-root" }
160160conventions-dokka-spec = { id = " conventions-dokka-spec" }
161161conventions-dokka-public = { id = " conventions-dokka-public" }
162+ conventions-no-psi-element = { id = " conventions-no-psi-element" }
162163compiler-specific-module = { id = " compiler-specific-module" }
163164
164165# gradle-plugin project
You can’t perform that action at this time.
0 commit comments