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

Gradle detektBaselineMain task not creating baseline for particular folder structure #4177

Closed
tinder-kuldeeptanna opened this issue Oct 11, 2021 · 5 comments

Comments

@tinder-kuldeeptanna
Copy link

tinder-kuldeeptanna commented Oct 11, 2021

Expected Behavior

Baseline file should be created when running detektBaselineMain for a module

Observed Behavior

Baseline file is not created when running detektBaselineMain for a module
(detektBaseline does create the baseline file for same module)

Steps to Reproduce

  1. Clone https://github.com/ktanna/TestDetekt
  2. Run ./gradlew :swipe-party:card-stack:data:detektBaselineMain
  3. Notice no baseline file was created in swipe-party/card-stack/data folder.

Note: If you run ./gradlew :swipe-party:card-stack:data:detektBaseline, the baseline file will be created.

Context

We use baselines to allow to suppress warnings for legacy code. With this bug, some modules don't have baseline created.

Your Environment

@cortinico
Copy link
Member

I've briefly looked into this. The problem is that you used the src/main/kotlin folder. If you use instead src/main/java folder, it will work correctly.

When we register the Android tasks, we use javaDirectories from AGP.

registerDetektTask(taskName, extension) {
setSource(variant.sourceSets.map { it.javaDirectories })

I haven't really looked deeply into this but seems like AGP is not properly returning the kotlin folder when we call .javaDirectories. Therefore we would have to patch it locally I believe. I'm unsure we're going to do it.

@chao2zhang
Copy link
Member

SourceProvider.getKotlinDirectories is added in Android Gradle Plugin 7.0.0, which drops Java 8. Therefore, we can't resolve this issue until #4130 is resolved.

@cortinico
Copy link
Member

SourceProvider.getKotlinDirectories is added in Android Gradle Plugin 7.0.0,

Oh that's great news! One more reason to drop Java 8 then :)

@osipxd
Copy link
Contributor

osipxd commented Apr 11, 2022

Looks like fixed in #4554 isn't it?

@cortinico
Copy link
Member

Yes this can be closed 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants