fwcd / fwcd/kotlin-language-server

Investigate Gradle Tooling API support

Open
#85 3 comments 0 reactions 0 assignees View on GitHub
dependency resolution enhancement experimental gradle
Dominant language
Kotlin
Stars
2k
Forks
252
PR merge metrics
No merged PRs in 30d

Description

The current solution to find the dependencies of a module/project invokes Gradle from the command line and parses the output:

https://github.com/fwcd/KotlinLanguageServer/blob/322594f491369f51fdda33295101098d81d5bf3d/src/main/kotlin/org/javacs/kt/classpath/GradleDependencyResolver.kt#L54-L62

A more elegant solution, however, would be to have direct, programmatic access to Gradle's APIs in order to fetch a list of dependency JARs. Both Eclipse and IntelliJ IDEA have custom project models inside the Gradle API that fit their specific use cases, but which can be used externally too (`EclipseModel` and `IdeaModel`). Unfortunately, these do have some limitations regarding Android support, which is why the current solution involves a [custom Gradle script](https://github.com/fwcd/KotlinLanguageServer/blob/master/src/main/resources/classpathFinder.gradle) that is invoked as described above. Instead, a custom model could be built using the Tooling API.

Resources:
* https://github.com/gradle/gradle/issues/4215#issuecomment-361840825
* https://docs.gradle.org/current/javadoc/org/gradle/tooling/provider/model/ToolingModelBuilderRegistry.html (Tooling API extensibility points)
* https://stackoverflow.com/questions/40739674/external-registration-of-tooling-api-custom-models
* https://github.com/gradle/gradle/blob/38e0df22ecff6c894f5c3eeecb94106e2ba557ff/subprojects/docs/src/samples/toolingApi/eclipse/src/main/java/org/gradle/sample/Main.java#L28-L28 (EclipseModel sample)
* https://github.com/gradle/gradle/blob/38e0df22ecff6c894f5c3eeecb94106e2ba557ff/subprojects/docs/src/samples/toolingApi/idea/src/main/java/org/gradle/sample/Main.java (IdeaModel sample)
* https://mvnrepository.com/artifact/org.gradle/gradle-kotlin-dsl-tooling-models/0.18.1 (DSL tooling models)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.