Skip to content

Instantly share code, notes, and snippets.

@skhatri
Created February 24, 2012 00:45

Revisions

  1. skhatri revised this gist Feb 24, 2012. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions quality.gradle
    Original file line number Diff line number Diff line change
    @@ -28,9 +28,7 @@ task checkstyleReport << {
    ant.xslt(in: "$buildDir/reports/checkstyle/${checkType}.xml",
    style:"config/checkstyle/checkstyle.xsl",
    out:"$buildDir/reports/checkstyle/checkstyle_${checkType}.html"
    ) {
    param(name:"project.name",expression:"${rootProject.name}")
    }
    )
    }
    }

  2. skhatri created this gist Feb 24, 2012.
    51 changes: 51 additions & 0 deletions quality.gradle
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    apply plugin: 'checkstyle'

    checkstyleMain {
    ignoreFailures = false
    reports {
    include ( '**/*.java')
    xml {
    destination "${rootProject.buildDir}/reports/checkstyle/main.xml"
    }
    }
    configFile = file('./config/checkstyle/checkstyle.xml')
    }

    checkstyleTest {
    ignoreFailures = false
    reports {
    include ( '**/*.java')
    xml {
    destination "${rootProject.buildDir}/reports/checkstyle/test.xml"
    }
    }
    configFile = file('./config/checkstyle/checkstyle-test.xml')
    }


    task checkstyleReport << {
    if (file("$buildDir/reports/checkstyle/${checkType}.xml").exists()) {
    ant.xslt(in: "$buildDir/reports/checkstyle/${checkType}.xml",
    style:"config/checkstyle/checkstyle.xsl",
    out:"$buildDir/reports/checkstyle/checkstyle_${checkType}.html"
    ) {
    param(name:"project.name",expression:"${rootProject.name}")
    }
    }
    }

    task quality(dependsOn:['checkstyleMain', 'checkstyleTest'])

    gradle.taskGraph.afterTask {Task task, TaskState state ->
    if(state.failure) {
    if (task.name in ['checkstyleMain', 'checkstyleTest']) {
    checkstyleReport {
    def matcher = task.name =~ /^checkstyle(.*)$/
    if (matcher.matches()) {
    checkType = matcher.group(1).toLowerCase()
    }
    }
    checkstyleReport.execute()
    }
    }
    }