diff --git a/build.gradle b/build.gradle index 74d6158ac..0e464bd54 100644 --- a/build.gradle +++ b/build.gradle @@ -28,6 +28,13 @@ plugins { id 'com.github.johnrengelman.shadow' version '8.1.1' id 'maven-publish' id("io.freefair.aspectj.post-compile-weaving") version "8.0.1" + id "jacoco" +} + +jacoco { + toolVersion = "0.8.8" +// If need to create the reports only in this directory - rather than on report folder in build.gradle +// reportsDirectory = layout.buildDirectory.dir('jacoco') } group = 'com.github.znsio' @@ -173,6 +180,20 @@ tasks.register('run', JavaExec) { classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output } +// This code is created to trigger the jacoco test on the basis of run tag - currently it executes only on test and build +//task jacocoRun(type: JacocoReport, dependsOn: ['run']) { +// // Set the appropriate source directories for your project +// sourceDirectories.from = files('src/test/java') +// classDirectories.from = files('build/classes/java/test') +// executionData.from = fileTree(dir: 'build/jacoco', includes: ['*.exec']) +// reports { +// // html.enabled = true +// html.required = true +// // xml.enabled = true +// xml.required = true +// } +//} + test { useJUnitPlatform() @@ -199,6 +220,45 @@ test { html.outputLocation.set(file("$buildDir/unit-test-results")) junitXml.outputLocation.set(file("$buildDir/unit-test-results")) } + + // Here we are manually updating the report portal as true +// jacoco { +// enabled = true +// } + + finalizedBy jacocoTestReport } +// Defined jacoco in this manner as well +//jacoco { +// toolVersion = "0.8.8" +// applyTo run +// reportsDirectory = layout.buildDirectory.dir('jacoco') +//} + + + +//jacocoTestReport { +// dependsOn test // tests are required to run before generating the report +//} +// +// +//jacocoTestReport { +// dependsOn run // tests are required to run before generating the report +// reports { +// xml.required = false +// csv.required = false +// html.outputLocation = layout.buildDirectory.dir('jacoco') +// } +//} +// +// +//tasks.register('applicationCodeCoverageReport', JacocoReport) { +// executionData run +// sourceSets sourceSets.main + + +// It is just indirectly calling jacoco - so it get trigger on hitting ./gradlew run +// jacocoTestReport.dependsOn jacocoRun + shadowJar.finalizedBy sourcesJar \ No newline at end of file