Stylianos Gakis
07/05/2022, 3:15 PMcom.android.library
module?
I’ve got a simple module which is setup to be a com.android.library and also applies this ktlint setup.
However in the end, in the files that are contained in this core-common module things do not get formatted at all. :core-common:ktlintCheck
doesn’t find an error and ktlintFormat doesn’t edit them at all either.
It’s weird because I do the exact same setup on my app module which is a com.android.application instead and it works perfectly fine.
I’ve also tried stuff like applying the plugin only to that one module but still nothing, it only works on my application module.
If anyone else who’s using the plugin in a multi-module setup like this has any ideas I would really appreciate it.
(.editorconfig used is here and I am using ktlint gradle plugin 10.3.0 with ktlint “0.45.2”)mateusz.kwiecinski
07/05/2022, 3:22 PMStylianos Gakis
07/05/2022, 4:49 PMmateusz.kwiecinski
07/05/2022, 5:17 PMBy modifying the ktlint-gradle task sources you mean forking the project and altering the internals of it?no, I meant doing something like (pseudocode)
tasks.named("nameOfKtlintTaskForMainSourceset") {
sources += android.sourceSets.main.kotlin.srcDirs
}
If you considered using a fork you can simply use the one from: https://github.com/JLLeitschuh/ktlint-gradle/pull/558 🙂
I’d rather simply change to /java as sources since that’s merely an aesthetic change as far as I am concerned.I recall having mixed Kotlin & Java sources comes with performance penalty. I haven’t seen AGP’s release notes, but I bravely assume (and hope 😅) they introduced a separate bucket for Kotlin sources to improve build performance. This might not be the case (yet?) but if it was, keeping Kotlin sources under
/java
directory might not be something one would want (all of this are my personal thoughts, I don’t have any release notes nor issuetracker links to back it up, you might be all good with just /java
🙂)Paul Woitaschek
07/05/2022, 6:06 PMStylianos Gakis
07/05/2022, 8:37 PMno, I meant doing something like (pseudocode)Ah of course, might give it a try!
mixed Kotlin & Java sources comes with performance penaltyYeah your assumption does make sense. Our codebase is 100% Kotlin, and for now I could just go with all java. I would hope if it has any effect it will have a negligible one so I am willing to take the risk there 😄
And just in case: if you haven’t seen yetAwesome, this does look like something I’d enjoy listening to! I’m not commuting lately and I’ve been struggling to find the time to listen to these podcasts. What a problem to have huh 😅
We have greatly simplified our process by checking in the ktlint binary using git lfsThat does sound very interesting. I have not touched git lfs at all so my first instinct is to avoid going that route at least for now while this isn’t a problem for us, but it does sound like a great idea. Are you aware of any source where I can read more about how I would go about doing something like that by any chance? For our case the reason I even introduced the plugin in the first place is consistency. We were manually using ktlint on our devices and the CI was doing its own thing resulting in inconsistencies sometimes whennot running the correct command making this process quite frustrating for no reason. I thought going for the gradle plugin, having everyone just run
./gradlew ktlintFormat|check
would be a great step forward to not have to think about it again at all.
Plus our old github action was taking >4 minutes with most of the time spend building ktlint from source while the new one takes <2 minutes. I guess with your idea of using git lfs it’d be even faster right.mateusz.kwiecinski
07/08/2022, 10:10 AMwhat is the reason for that?To be honest, I don’t know 😛 kotlinter was initially more performant and I appreciated its simplicity.
ktlint-gradle
was more complex and it tried to support every use-case. I started using kotlinter for all my projects, which then evolved into contributing to pay back the community 🙂
I recently got promoted to a Collaborator, and I’m trying to keep the plugin working for the Android ecosystem (i.e. I was the author of the kotlinter fix for the same bug you encountered initially here).
That’s my story 😛 Why there are two Gradle plugins? idk 🤷Stylianos Gakis
07/08/2022, 10:25 AM