2021-03-17 22:22:43 +00:00
|
|
|
/* ###
|
|
|
|
* IP: GHIDRA
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2019-03-26 17:45:32 +00:00
|
|
|
import groovy.io.FileType;
|
|
|
|
|
2019-11-07 18:17:06 +00:00
|
|
|
apply plugin:'jacoco'
|
2019-03-26 17:45:32 +00:00
|
|
|
|
2019-11-07 18:17:06 +00:00
|
|
|
dependencies {
|
2022-06-12 04:38:50 +00:00
|
|
|
jacocoAnt 'org.jacoco:org.jacoco.ant:0.8.8'
|
|
|
|
jacocoAgent 'org.jacoco:org.jacoco.agent:0.8.8'
|
2019-11-07 18:17:06 +00:00
|
|
|
}
|
2019-03-26 17:45:32 +00:00
|
|
|
|
2020-02-21 19:17:28 +00:00
|
|
|
/*********************************************************************************
|
|
|
|
* Generate the Jacoco excludes list from file (this will strip out comments and
|
|
|
|
* whitespace).
|
|
|
|
*
|
|
|
|
* This uses 'gradle/support/jacoco.excludes.src.txt' to generate list of
|
|
|
|
* class exclusions for the 'jacocoReport' task.
|
|
|
|
*
|
|
|
|
* Task to generate an aggregate jacoco report from subprojects with
|
|
|
|
* Java sourceSets
|
|
|
|
*********************************************************************************/
|
|
|
|
def String[] generateExcludesList() {
|
|
|
|
|
|
|
|
File inputFile = new File(rootProject.projectDir, "gradle/support/jacoco.excludes.src.txt")
|
|
|
|
|
|
|
|
def lines = inputFile.readLines()
|
|
|
|
.findAll({ line ->
|
|
|
|
!shouldIgnoreLine(line)
|
|
|
|
})
|
|
|
|
.collect()
|
|
|
|
return lines
|
|
|
|
}
|
|
|
|
|
|
|
|
/* An ignorable line is one that is only whitespace or that starts with a comment marker */
|
|
|
|
def shouldIgnoreLine(line) {
|
|
|
|
if (line.startsWith('#')){
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
if (line.startsWith("//")) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
if (line.trim().isEmpty()) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
List excludesList = generateExcludesList()
|
|
|
|
|
2019-03-26 17:45:32 +00:00
|
|
|
/*********************************************************************************
|
2023-02-17 18:01:37 +00:00
|
|
|
* Task to generate an aggregate jacoco report from subprojects with
|
|
|
|
* Java sourceSets
|
2019-03-26 17:45:32 +00:00
|
|
|
*********************************************************************************/
|
2023-02-17 18:01:37 +00:00
|
|
|
task jacocoReport(type: JacocoReport, group: 'Coverage reports') {
|
|
|
|
description = 'Generates an aggregate Jacoco report from all subprojects'
|
|
|
|
|
2019-11-07 18:17:06 +00:00
|
|
|
dependsOn { subprojects.findAll { p -> p.plugins.hasPlugin('jacoco') }.test }
|
|
|
|
dependsOn { subprojects.findAll { p -> p.plugins.hasPlugin('jacoco') }.integrationTest }
|
2023-02-17 18:01:37 +00:00
|
|
|
|
2019-11-07 18:17:06 +00:00
|
|
|
executionData fileTree(rootDir) {
|
|
|
|
include '**/*.exec'
|
|
|
|
}
|
|
|
|
|
|
|
|
// Setting these source/class dirs MUST be done in the configuration phase (we used
|
|
|
|
// to do it in a doFirst block but that was deprecated in later gradle builds). However,
|
|
|
|
// we have to delay evaluation of the subprojects (using the '{ }' notation) to wait for
|
|
|
|
// some project attributes (eg: 'sourceSets') to be made available.
|
2020-02-21 19:17:28 +00:00
|
|
|
additionalSourceDirs files({ subprojects.findAll { p -> p.plugins.hasPlugin('jacoco') }.sourceSets.main.java.srcDirs })
|
|
|
|
additionalClassDirs files({ subprojects.findAll { p -> p.plugins.hasPlugin('jacoco') }.sourceSets.main.output }).asFileTree.matching {
|
|
|
|
exclude excludesList
|
|
|
|
}
|
|
|
|
|
2019-11-07 18:17:06 +00:00
|
|
|
reports {
|
|
|
|
html {
|
2021-10-22 11:05:09 +00:00
|
|
|
required
|
2019-11-07 18:17:06 +00:00
|
|
|
destination new File(rootDir.absolutePath + "/jacocoReport")
|
|
|
|
}
|
2021-10-22 11:05:09 +00:00
|
|
|
xml { }
|
2019-11-07 18:17:06 +00:00
|
|
|
}
|
2021-03-17 22:22:43 +00:00
|
|
|
}
|