dipien / bye-bye-jetifier

Gradle Plugin to verify if you can keep Android Jetifier disabled
http://byebyejetifier.dipien.com
Apache License 2.0
202 stars 5 forks source link

Recommended configuration when using custom lint checks? #45

Closed stkent closed 3 years ago

stkent commented 3 years ago

Hello!

We're using this plugin on a project that also includes custom lint checks.

Unfortunately, the plugin is flagging dependencies within the custom lint check project, even though those aren't compiled into the final application (and therefore do not need to be jetified to avoid conflicts with AndroidX dependencies).

Here's a sample app that demonstrates the issue: https://github.com/stkent/ByeByeJetifierSample

Running ./gradlew canISayByeByeJetifier -Pandroid.enableJetifier=false in the root of that repository leads to a failure.

What's the recommended configuration here? Is there a way to ignore the entire lintchecks project? Or do we need to suppress using excludedFilesFromScanning (which is a globally-scoped ignore list)?

maxirosson commented 3 years ago

Hi. There is no way to exclude a project. You need to add the suppress on excludedFilesFromScanning. Something like "com/stkent/lintchecks" should work.

stkent commented 3 years ago

Unfortunately excluding com/stkent/lintchecks in addition to default exclusions does not change the result, as the Android support classes within dependencies are still scanned.

I can pass the build by excluding

"com/android/support/AndroidxNameUtils.class",
"com/android/support/AndroidxName.class",
"com/android/SdkConstants.class",
"com/android/ide/common/rendering/api/ResourceNamespace.class",
"com/android/ddmlib/testrunner/AndroidTestOrchestratorRemoteAndroidTestRunner.class"

but this suppression applies to all projects (the lint check project, which I want it to; and the app project, which I don't).

Does supporting project exclusion based on project name seem like a reasonable feature request in light of this? :)

maxirosson commented 3 years ago

You are right, project exclusion is the only way. I am going to add support for that on next version

maxirosson commented 3 years ago

https://github.com/dipien/bye-bye-jetifier/issues/46

stkent commented 3 years ago

Amazing, thanks @maxirosson! Let me know if you need any help testing release candidates when you get there :)

stkent commented 3 years ago

Feel free to close this issue in favor of #46 if that makes sense for your flow :)

maxirosson commented 3 years ago

Thanks, I will share you the snapshot version before releasing so you verify whether it is working fine on your project

maxirosson commented 3 years ago

You can try the snapshot using this config:

buildscript {
    repositories {
        maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" }
    }
        dependencies {
               classpath("com.dipien:bye-bye-jetifier:1.2.0-SNAPSHOT")
       }
}

apply plugin: "com.dipien.byebyejetifier"

byeByeJetifier {
    excludedProjectsFromScanning = ["lintchecks"]
}
stkent commented 3 years ago

Tested this on our actual project and it looks great!

One tiny suggestion might be to additionally log the excluded project names with this group of log statements: https://github.com/dipien/bye-bye-jetifier/blob/12caef0a06c576cff36da84c683a17e5de66b841/bye-bye-jetifier/src/main/java/com/dipien/byebyejetifier/task/CanISayByeByeJetifierTask.kt#L63-L65 But not something critical, just nice-to-have :) Thanks for working on this :D

maxirosson commented 3 years ago

Nice, thanks for reporting this and for your help. I pushed your suggestion, thanks. I will release the new version soon