Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate Gradle Tooling API support #85

Open
fwcd opened this issue Feb 7, 2019 · 3 comments
Open

Investigate Gradle Tooling API support #85

fwcd opened this issue Feb 7, 2019 · 3 comments
Labels
dependency resolution Related to the project dependency/standard library resolver enhancement New feature or request experimental The feature is experimental and might be revoked gradle Related to the language server's support for Gradle projects

Comments

@fwcd
Copy link
Owner

fwcd commented Feb 7, 2019

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 that is invoked as described above. Instead, a custom model could be built using the Tooling API.

Resources:

@fwcd fwcd added enhancement New feature or request experimental The feature is experimental and might be revoked dependency resolution Related to the project dependency/standard library resolver labels Feb 7, 2019
@fwcd fwcd added the gradle Related to the language server's support for Gradle projects label Feb 13, 2019
@vasiltabakov
Copy link

You can use Android's own models via the Android Gradle Plugin:

compile group: 'com.android.tools.build', name: 'gradle', version: '3.2.1'

https://google.github.io/android-gradle-dsl/current/

This way you'll have access to say AppExtension and do everything you do in your custom Gradle file but with more control indeed.

@kneep
Copy link

kneep commented Jul 6, 2020

@fwcd Hi fwcd. I just happened to find this thread. Do you find a solution to this problem?

@daplf
Copy link
Contributor

daplf commented Jun 9, 2021

@fwcd I started looking into this recently and I was wondering: does it really make sense for us to build a custom model instead of using the existing ones? I understand they are specific to their use cases, but can't we choose the model based on the type of project?

I've played around with the tooling API and we can obviously create one from scratch, but I'm wondering if it wouldn't be too much of a hassle, since we would need to maintain it as well (not to mention, the model would basically support all kinds of different projects, which might become a mess IMO).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependency resolution Related to the project dependency/standard library resolver enhancement New feature or request experimental The feature is experimental and might be revoked gradle Related to the language server's support for Gradle projects
Projects
None yet
Development

No branches or pull requests

4 participants