@@ -12,10 +12,12 @@ group = 'com.gitblit'
1212version = ' 1.9.2-SNAPSHOT'
1313description = ' Gitblit'
1414
15- // compiles build artefacts to
16- // run under Java 1.8 and later versions
17- sourceCompatibility = JavaVersion . VERSION_1_8
18- targetCompatibility = JavaVersion . VERSION_1_8
15+ java {
16+ // compiles build artifacts to
17+ // run under Java 1.8 and later versions
18+ sourceCompatibility = JavaVersion . VERSION_1_8
19+ targetCompatibility = JavaVersion . VERSION_1_8
20+ }
1921
2022ext {
2123 // Project Metadata
@@ -107,10 +109,19 @@ sourceSets {
107109}
108110
109111test {
110- // Dynamic exclude some unit tests through property defined in the command line
112+ // Dynamically exclude some unit tests through a property defined at runtime
111113 if (project. hasProperty(' excludeTests' )) {
112114 exclude project. property(' excludeTests' )
113115 }
116+ finalizedBy jacocoTestReport // generate JaCoCo code coverage report after unit test run
117+ }
118+
119+ jacocoTestReport {
120+ // code coverage reports will be generated in the default build/reports/jacoco directory
121+ reports {
122+ xml. enabled true
123+ html. enabled true
124+ }
114125}
115126
116127task copyToRunDir (type : Copy ) {
@@ -248,12 +259,42 @@ dependencies {
248259
249260checkstyle {
250261 configFile = file(' src/main/config/checkstyle.xml' )
251- ignoreFailures = true
252262 // sourceSets = [sourceSets.main, sourceSets.test]
253- // showViolations = true
254- // reportsDir = file("$project.buildDir/checkstyleReports")
255- dependencies {
256- checkstyle ' com.puppycrawl.tools:checkstyle:8.20'
263+ ignoreFailures = true
264+ showViolations = true
265+ toolVersion = ' 8.32'
266+ }
267+ tasks. withType(Checkstyle ) {
268+ // disable the default HTML reporting (but leave the XML reporting on);
269+ // instead, HTML reports are produced by the custom task checkstyleHtmlReports below
270+ reports. html. enabled false
271+ }
272+
273+ task checkstyleHtmlReports {
274+ description = ' Run checkstyle tasks and generate their HTML reports'
275+ group = ' verification'
276+
277+ // depends on checkstyle tasks as specified by checkstyle.sourceSets property
278+ dependsOn {
279+ project. tasks. withType(Checkstyle ). matching { task ->
280+ checkstyle. sourceSets. any { sourceSet ->
281+ task. name. equalsIgnoreCase(' checkstyle' + sourceSet. name)
282+ }
283+ }
284+ }
285+ doLast {
286+ // generate HTML reports from all checkstyle tasks' XML reports
287+ // to be in the default build/reports/checkstyle directory
288+ // and separately in each sourceSet's subdirectory
289+ checkstyle. sourceSets. each { sourceSet ->
290+ ant. xslt(
291+ style : ' src/main/config/checkstyle-frames-errors.xsl' ,
292+ in : " ${ checkstyle.reportsDir} /${ sourceSet.name} .xml" ,
293+ out : " ${ checkstyle.reportsDir} /${ sourceSet.name} .html" ) {
294+ param (name : ' output.dir' ,
295+ expression : " ${ checkstyle.reportsDir} /${ sourceSet.name} " )
296+ }
297+ }
257298 }
258299}
259300
@@ -682,8 +723,7 @@ task jarGitblitApiClasses(type: Jar) {
682723 ' Implementation-Version' : version,
683724 ' Created-By' : ' Gradle ' + getGradle(). getGradleVersion(),
684725 ' Build-Date' : snapshotDate,
685- ' Build-Jdk' : System . getProperty(' java.version' ),
686- // 'Main-Class': 'com.gitblit.client.GitblitClient'
726+ ' Build-Jdk' : System . getProperty(' java.version' )
687727 )
688728 }
689729
0 commit comments