Run a Checkstyle aggregate task after all the sub project checkstyle tasks

plugins

(Raja Nadar) #1

I have a root project with 5 sub-projects. The root project has no code, and has a build.gradle to do a lot of common work.

Right now, I have a checkstyle task that runs for all the subprojects

subprojects
{
 // my checkstyle task which creates xml and html reports 
 // per project. (so totally 5 such reports. all good here.)
}

I am trying to define an aggregateCheckstyle task, which takes the output xml of all the 5 projects, combines them and creates a final Html report.

subprojects
{
    // other tasks.. etc.
    
    task checkstyleAll {

        doLast {
           // fileTree based pickup of individual xml files, 
           // combine and ant xslt for the final html.
        }
    }
}

i am able to create the final report successfully, but there is something wrong with the order of the tasks.

e.g. when a checkstyle violation happens, i can see it in the individual checkstyle report of the sub-project build directory.
but this aggregated report shows zero violations. if i run the build again, this aggregate report catches up.

i have tried following this forum link:

and also this:

and also tried dependsOn subprojects.check, finalizedBy etc…

What is the simple way to do this in Gradle?
I want to run my aggregate task after all the check/checkstyleMain/checkstyleTest tasks of the subprojects?