-
Notifications
You must be signed in to change notification settings - Fork 166
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
Alternate sourceSets are not detected #153
Comments
Interesting, I suppose you've applied |
Sure, my sample project and also the real project in which I first found this work properly apart from this and the plugin also worked before the Android Gradle Plugin had this change with the lazy configuration (e.g. plugin versions < 6 work). |
Indeed, I was able to reproduce on android sample project. Will try to fix it. |
Also I will assume that plugin version |
The problem here that user defined source sets are only available in Will try to figure out how Gradle Java plugin approaches this issue. |
@rubengees fix will be available in |
Cool, thanks! |
I'm still having this problem in my integration tests. Not really in a real project. Generated project is something like below. Notice that I don't really have anything inside
|
As far as I see in the line from referenced PR https://github.com/JLLeitschuh/ktlint-gradle/pull/154/files#diff-513ff7df76b3a229c796d8d72281e589R123 You use |
@tasomaniac Those two suggestions are, functionally, equivalent. |
sourceSets function with an Action argument says configure in the docs. So it is used to configure sourceSets. Not sure if it returns a live collection. all returns a live collection where you will also get future instances in the collection. |
Anyways, it seems like not only the additional source sets but the default ones are also ignored when it is used with Novoda plugin. I will investigate this. |
@tasomaniac This is the code as it exists in the current release: ktlint-gradle/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/KtlintPlugin.kt Lines 158 to 172 in f32441b
Is this issue not fixed for you? Do you need it re-opened? |
It works if I configure it directly in my build.gradle file. It does not if I let Novoda static analysis plugin to configure KtLint. That's why I think it is ok to keep this issue closed. I will do some debugging and will get back to you on this. |
After long debug session, I finally found the problem. 🎉 It is not just about Novoda plugin, so you can actually re-open this one. It is a common practice to create tasks for each variant in Android. If you have The above link you posted created the task by only looking at the Long story short, running |
Here, as far as I see, you were using Android variants already. This is the last working version for me. |
@tasomaniac Can you provide a sample script that demonstrates your problem using the latest version of |
Working on fix now. PR is coming soon. Here how I reproduce it
|
One way to reproduce inside the repo:
|
Hmm, I intentionally removed usages of Android variant manager:
Usually user doesn't need to call specific task, but rather call
Possible solution from ktlint-gradle plugin side is to create special meta tasks for android variants (excluding instant app plugin) that will trigger variant source sets tasks. |
This is a huge behavior change though :( I would suggest to put it into changelog.
I don't think it is safe/good to assume this ☝️. On Android people usually call the check tasks only for a certain variant to speed up things. It is really a common practice. Some projects have many flavors. The big difference between plain Kotlin projects vs Android is that Kotlin only has As an example: |
Possible way:
Or:
|
Both sounds good to me. 👍 |
Opened new issue #170, as this particular problem doesn't related to original bug problem. |
Make sense. |
Plugin version:
6.2.0
Ktlint version:
Bundled
Project type:
Android
Android Gradle plugin version:
3.4.0-alpha01
(happened in earlier 3.3.x ones too)Config:
I have configured an alternative
sourceSet
for my kotlin sources:Once I do this, the plugin does not seem to be able to detect kotlin files in that directory. Kotlin files in
src/main/java
are detected.Is this some misconfiguration on my end? I can create and share a sample project if needed.
Thanks for looking into this!
The text was updated successfully, but these errors were encountered: