jeremymailen / kotlinter-gradle

Painless, fast ktlint plugin for Gradle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Changing the output directory of the LintTask

StylianosGakis opened this issue · comments

I was looking into using this GitHub Action in order to take the errors output by the reporters and have them be annotated in my PR.
Thing is, I used to be able to do that in a mono-module setup where I knew where the output of the reporters were, but now with a multi-module setup the LintTask is generating a lot of files all in separate build files one for each module and I can't quite get this all to work out.
I was wondering if there is any way I can configure that task to output everything at one spot where this GH Action can pickup and use instead.

Here is my current configuration, but since KotlinterExtension does not take in any such config I don't know if this would be possible. I was using the other gradle plugin before (ktlint-gradle), which allowed me to have this kind of configuration before, but since that one seems to now be abandoned and after reading this discussion I thought I'd switch over to kotlinter.

There probably will be more people like me who will be asking similar question so it'd be nice to have an answer on the feasibility of this.

I was wondering if there is any way I can configure that task to output everything at one spot where this GH Action can pickup and use instead.

Have you tried overriding task's reports property? I mean something like:

tasks.withType<LintTask>().configureEach {
    reports.set(mapOf("checkstyle" to rootDir.resolve("reports/${project.path}.xml")))
}

which would save all reports under {root}/reports/{unique-subproject-name}.xml} using checkstyle reporter (you can alter either the report format or output name). Is that something you were looking for?

Yeap that was it, I was trying to see if I can edit this in KotlinterExtension which is why I never figured I could edit the LintTask directly 🙌
This PR does do exactly what I was looking for. All the reporters output on that common file, thanks a lot!