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
Refactor detekt-gradle-plugin off com.android.tools.build:gradle #3327
Comments
I couldn't find anything about this
I agree with you that have two tasks own per production code and other for test code is not handy. And this is not a problem just with out android compatibility. We have the same problem with pure kotlin projects too. I think that we should rethink all our gradle tasks. My current idea is to have 4 principal tasks for 2.0:
I think that gradle should not support checks without type solving for 2.0. |
A lot of the interfaces in
|
This would also resolve issues such as #3476 |
FWIW the experimental compiler plugin works well and avoids this issue (and related AGP/plugin issues) entirely because it hooks directly into the Kotlin compilation tasks after they've been configured by AGP. I think effort would be better spent getting that production ready. I believe the only major feature missing is generation of baseline files. |
More details on migration to Android's Gradle API artefact: https://developer.android.com/studio/releases/gradle-plugin-roadmap |
More information from Google I/O: https://www.youtube.com/watch?v=AZBW5StgF8o |
🎉 https://developer.android.com/studio/releases/gradle-plugin#7-0-0 🎉 We can start working on it. |
And we probably should follow this path that lint is taking:
From: https://developer.android.com/studio/releases/gradle-plugin#running_lint_on_default_variant_only |
This issue is stale because it has been open 90 days with no activity. Please comment or this will be closed in 7 days. |
We can't do this yet because of https://issuetracker.google.com/issues/158777988. More about this here: #4133 (comment) At Droidcon London @cortinico and I talked with Wojtek Kaliciński (Android Developer Advocate @ Google) about this issue. I just remember that he told us to send him a link to see if he could help us. Here the tweet: https://twitter.com/braisgabin/status/1457310902773075973 |
I've looked into the feasibility of doing this now. The Variant API must allow access to Kotlin sources, compile classpath and the compiled classes (both .class and JARs) for detekt to work correctly. It seems the earliest AGP version we could migrate to is 7.3. We can get Kotlin source here, compile classpath here, and the compiled classes from here and here. So, we could migrate, support AGP 7.3 and up (which might be a bit aggressive, but let's go with it for now) and we're done, right? Wrong! ALL_CLASSES_DIRS and ALL_CLASSES_JARS are deprecated in 7.4 and removed in 8.0.0-alpha09. There's a new API available from 7.4 which can be used instead and should continue working through Gradle 8 (when Variant APIs are supposed to be stabilised) and the foreseeable future. When AGP 9 is released we will have to switch to the 8.0 API anyway, as AGP 9 drops support for the API that the plugin currently uses. TL;DR: we can either:
It would be nice to move to the new API, but the current plugin offers better backwards & forwards compatibility. Interested in what others think. |
I would vote for option 2. This change is not just to make our code "easier". This should also fix issues, right? Then I think it's acceptable to drop support for earlier versions. Other option is to drop support for 7.3 now and don't wait for AGP8. If someone can't update just yet they can keep detekt at |
Agree with option 2. 7.4 just released so we will likely get AGP 8 release in a few months, so if AGP 8 API is confirmed compatible with 7.4+, can make the move then and drop support for 7.3 and earlier. |
Based on experiences with #5693, when we migrate to Variant API and start compiling against AGP 7.4, we'll have to compile the detekt Gradle plugin with JDK 11+, so end users will then have to run the Gradle plugin on JVM 11+, even if they're not using AGP. They'll still be able to work on projects that compile with earlier JDKs though using toolchains and other features offered by Gradle. The only way I can think of to avoid this would be to separate the Gradle plugins so we have a detekt Android plugin for Gradle (requires JVM 11+), and another for non-Android (requires JVM 8+) but I don't think we should go down this path. |
Sorry for being late to the convo.
Actually this doesn't sound that bad to be. Is having 2 distinct Gralde plugins too much of pain because of the interactions between the two or because of how complicated the build would get? I was thinking that instead it would help us to modularize a bit and also run more Gradle tests in parallel which now are the major offender in the |
Android Gradle plugin enters a new phase of aligning versions with Gradle Official announcement, this does have an impact on plugin authors. We should not depend on com.android.tools.build:gradle but com.android.tools.build:gradle-api. As Google plans to deprecate com.android.tools.build:gradle in 7.0 and remove it completely in 8.0 (This is according to the conversation between my colleague and the technical lead of Android Developer Tools, so there could be falsehood).
What I am proposing to do for detekt on Android projects:
I am open to any feedback or correction in the information I received.
The text was updated successfully, but these errors were encountered: