-
Notifications
You must be signed in to change notification settings - Fork 156
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
Use variants dynamically to put sourceSets #167
Conversation
target.files(Callable { androidSourceSet.java.srcDirs }) | ||
) | ||
} | ||
ext.variants.all { variant -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ext.variants
is coming from the PluginUtils
.
Here all
makes it lazy loop over variants. When a variant is created, it is sourceSet is also set and contains all directories.
…use the sources defined in there.
62a9873
to
67354f5
Compare
plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/KtlintPlugin.kt
Outdated
Show resolved
Hide resolved
plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/KtlintPlugin.kt
Outdated
Show resolved
Hide resolved
Is there any good way to add a unit test for this? |
Ktlint integration with a Kotlin project is tested already in the repo. The same should be done for an Android project too. We have some tests in Novoda plugin, I used those test to double check these changes. If a setup is done, I would be happy to contribute to tests. |
@Tapchicoma Can unit tests against android be written or would that couple our test infrastructure to requiring the Android SDKs to be installed? |
…gin.kt Co-Authored-By: tasomaniac <tasomaniac@gmail.com>
…gin.kt Co-Authored-By: tasomaniac <tasomaniac@gmail.com>
|
||
internal val BaseExtension.variants | ||
get(): DomainObjectSet<out BaseVariant> = when (this) { | ||
is AppExtension -> applicationVariants |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @Tapchicoma mentioned, this extension is not available on InstantApp
modules. Don't really know what to do in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate on what the problem is?
I'm not an Android developer. Hahah.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Android have multiple plugins. In KtlintPlugin.kt
class where we configure the Android plugin, we support InstantApp modules. But here, unfortunately we cannot access the variants in InstantAppExtension
because it is not visible for some reason.
I've done this a lot of times but I never supported instant app plugin before. Not sure what to do in this case.
@tasomaniac thank you for your contribution! As we discussed in #153 and #170 - can you update your PR: |
Hey, I believe that would be the best. But I need to start from scratch to do that. I will just close this so anybody can take it. |
@tasomaniac I think, I will approach this after #180 will be merged 👍 |
Thanks @Tapchicoma |
Instead of resolving sourceSets from extension, resolve variants and use the sources defined in there.
Fixes #153