Bug 1938622 - Enable kotlin code indexing again using forked semanticdb-kotlinc. r=nalexander,geckoview-reviewers,jcristau

Upstream semanticdb-kotlinc at github.com/sourcegraph/scip-kotlin does
not support kotlin 2 yet, so we forked the repository and added support
at github.com/mozsearch/semanticdb-kotlinc.

The upstream project originally builds on GitHub Actions and publishes
to Maven Central as com.sourcegraph:semanticdb-kotlinc.

Instead, we currently publish to maven.mozilla.org as
com.github.mozsearch:semanticdb-kotlinc.

Differential Revision: https://phabricator.services.mozilla.com/D245420
This commit is contained in:
Nicolas Guichard
2025-04-28 09:39:03 +00:00
parent 8262016029
commit e57f0beabb
2 changed files with 10 additions and 1 deletions

View File

@@ -139,7 +139,6 @@ allprojects {
}
// Use the semanticdb-javac and semanticdb-kotlinc plugins to generate semanticdb files for Searchfox
// NOTE: Kotlin code indexing is currently removed due to lack of Kotlin 2.x support (see bug 1938622)
if (mozconfig.substs.ENABLE_MOZSEARCH_PLUGIN || mozconfig.substs.DOWNLOAD_ALL_GRADLE_DEPENDENCIES) {
def targetRoot = new File(topobjdir, "mozsearch_java_index")
@@ -154,6 +153,7 @@ allprojects {
addDependencyToConfigurationIfExists("compileOnly", libs.semanticdb.java)
addDependencyToConfigurationIfExists("testCompileOnly", libs.semanticdb.java)
addDependencyToConfigurationIfExists("androidTestCompileOnly", libs.semanticdb.java)
addDependencyToConfigurationIfExists("kotlinCompilerPluginClasspath", libs.semanticdb.kotlin)
}
tasks.withType(JavaCompile) {
@@ -161,6 +161,13 @@ allprojects {
"-Xplugin:semanticdb -sourceroot:${topsrcdir} -targetroot:${targetRoot}",
]
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
compilerOptions.freeCompilerArgs.addAll([
"-P", "plugin:semanticdb-kotlinc:sourceroot=${topsrcdir}".toString(),
"-P", "plugin:semanticdb-kotlinc:targetroot=${targetRoot}".toString(),
])
}
}
task downloadDependencies() {

View File

@@ -70,6 +70,7 @@ jacoco = "0.8.13"
kotlin-dsl = "5.2.0"
protobuf-plugin = "0.9.5"
scip-java = "0.10.4"
semanticdb-kotlinc = "0.5.0"
# Kotlin versions
coroutines = "1.10.2"
@@ -245,6 +246,7 @@ jna = { group = "net.java.dev.jna", name = "jna", version.ref = "jna" }
# Gradle plugins
semanticdb-java = { group = "com.sourcegraph", name = "semanticdb-javac", version.ref = "scip-java" }
semanticdb-kotlin = { group = "com.github.mozsearch", name = "semanticdb-kotlinc", version.ref = "semanticdb-kotlinc" }
glean-gradle-plugin = { group = "org.mozilla.telemetry", name = "glean-gradle-plugin", version.ref = "mozilla-glean" }
kotlin-annotations-jvm = { group = "org.jetbrains.kotlin", name = "kotlin-annotations-jvm", version.ref = "kotlin" }