nebula-plugins / gradle-lint-plugin

A pluggable and configurable linter tool for identifying and reporting on patterns of misuse or deprecations in Gradle scripts.
Apache License 2.0
765 stars 88 forks source link

Gradle Kotlin DSL support #166

Open ghost opened 6 years ago

ghost commented 6 years ago

Support for Gradle Kotlin DSL would be really nice. It's my understanding that Kotlin will be the default language for Gradle scripts (https://www.youtube.com/watch?v=NMs8Z6rFnzE&feature=youtu.be&t=10m17s) sometime in the future.

This is a huge feature request and could take a lot of time to implement. Is it possible to turn off linting and only check dependencies? That's the key feature I would like to take advantage of now.

holubec-petr commented 5 years ago

Any progress here? Kotlin DSL becomes used more and more and support for it would be really helpful.

DanielThomas commented 5 years ago

The current implementation of the core and rules is entirely coupled to the Groovy AST. Its practically a complete rewrite to support Kotlin. We've also got no plans to move to the Kotlin DSL internally.

It's likelt either take a community effort, or Gradle proving core lint support.

jcornaz commented 5 years ago

I there any workaround in the mean time? Or it isn't possible to use the plugin from kotlin-dsl at all?

matfax commented 5 years ago

@jcornaz Not afaik. With other plugins, you only have to handle the interface changes. With this one, however, the plugin requires a complete rewrite, just as @DanielThomas said. I would even assume or suggest to host the rewritten version in a separate repository.

huehnerlady commented 5 years ago

Is there any update on this - for example if it will be considered? I am looking for a dependency analyse plugin for gradle - but unfortunately we use the kotlin DSL :(

3flex commented 4 years ago

I would even assume or suggest to host the rewritten version in a separate repository

@matfax Might that be under the nebula-plugins organisation or do you see it as completely managed externally?

I'd be interested in building a solution but couldn't commit as an individual to supporting long-term as I could only do that in my spare time.

TWiStErRob commented 2 years ago

Do I understand correctly that this limitation exists because you're parsing the dependencies blocks rather than hooking into the resolved configurations Gradle provides in-memory? Or is the limitation only "auto-removing" bad dependencies?

DanielThomas commented 2 years ago

The code that determines duplicate classes, unnecessary dependencies, etc do just look at the configurations and work regardless of DSL language and it is possible to fire violations against the build file without being AST aware. That said rules are Groovy AST based even when they rely on the configuration (undeclared/declared dependencies/etc) and would need work to make them fallback for Kotlin DSL. We still have no plans to support the Kotlin DSL, but would review and accept PRs that made these work at a project rather than build script aware level.

wakedeer commented 1 year ago

Oh, It makes me sad

3flex commented 1 year ago

We still have no plans to support the Kotlin DSL

Will that be revisited? https://blog.gradle.org/kotlin-dsl-is-now-the-default-for-new-gradle-builds

DanielThomas commented 1 year ago

Gradle changing the default doesn't change the thousands of projects we have using the Groovy DSL. We'd only implement Kotlin DSL support if we decided to switch internally, and that's unlikely, we don't see the value.

mxkmn commented 1 year ago

Please write about the lack of .kts support at the beginning of the readme!

gustavjon commented 6 months ago

Still no plans on supporting .kts?

Keith-Albright-Bose commented 3 weeks ago

It doesn't help that the official gradle docs still link to this plugin: https://docs.gradle.org/current/userguide/performance.html#avoid_unnecessary_and_unused_dependencies Thanks for adding the doesn't work to the top of the readme. The following plugin is getting updates but has false positives. Your mileage may vary: https://github.com/autonomousapps/dependency-analysis-gradle-plugin