-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
162 lines (141 loc) · 4.77 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
apply plugin: 'java'
apply plugin: 'findbugs'
apply plugin: 'pmd'
apply plugin: 'checkstyle'
apply plugin: 'jacoco'
def shibboleth_idp_version = '4.3.3'
group = 'au.edu.aaf'
version = '1.1.1'
sourceCompatibility = 1.8
repositories {
mavenCentral()
maven {
url 'https://build.shibboleth.net/nexus/content/repositories/releases/'
}
}
dependencies {
compile 'net.shibboleth.idp:idp-attribute-api:' + shibboleth_idp_version
compile 'net.shibboleth.idp:idp-attribute-resolver-api:' + shibboleth_idp_version
compile 'net.shibboleth.idp:idp-attribute-resolver-impl:' + shibboleth_idp_version
compile 'net.shibboleth.idp:idp-attribute-resolver-spring:' + shibboleth_idp_version
compile 'org.springframework:spring-jdbc:6.2.1'
testCompile 'junit:junit:4.12'
testCompile 'org.springframework:spring-test:6.2.1'
testCompile "org.mockito:mockito-core:5.15.2"
testCompile 'org.springframework:spring-test:4.3.2.RELEASE'
testCompile 'com.h2database:h2:2.3.232'
}
test {
testLogging {
events "passed", "skipped", "failed"
}
}
findbugs {
ignoreFailures = false
effort = "max"
}
tasks.withType(FindBugs) {
reports {
xml.enabled = false
html.enabled = true
}
}
pmd {
ruleSets = [
'java-basic',
'java-codesize',
'java-empty',
'java-strictexception',
'java-strings',
'java-typeresolution',
'java-unnecessary',
'java-unusedcode'
]
ignoreFailures = false
sourceSets = [sourceSets.main, sourceSets.test]
}
checkstyle {
toolVersion = '10.21.1'
configFile = new File(rootDir, "config/checkstyle.xml")
ignoreFailures = false
sourceSets = [sourceSets.main, sourceSets.test]
}
task checkstyleMainHtml << {
ant.xslt(in: checkstyleMain.reports.xml.destination,
style: file('config/checkstyle-noframes-sorted.xsl'),
out: new File(checkstyleMain.reports.xml.destination.parent, 'main.html'))
}
checkstyleMain.finalizedBy checkstyleMainHtml
task checkstyleTestHtml << {
ant.xslt(in: checkstyleTest.reports.xml.destination,
style: file('config/checkstyle-noframes-sorted.xsl'),
out: new File(checkstyleTest.reports.xml.destination.parent, 'test.html'))
}
checkstyleTest.finalizedBy checkstyleTestHtml
ext {
limits = [
'instruction': 85,
'branch' : 85,
'line' : 85,
'complexity' : 85,
'method' : 85,
'class' : 85
]
}
jacoco {
toolVersion = "0.8.12"
}
jacocoTestReport {
reports {
xml.enabled true
}
doLast {
def report = file("${jacoco.reportsDir}/test/jacocoTestReport.xml")
logger.lifecycle("Checking coverage results: ${report}")
def parser = new XmlParser()
parser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
parser.setFeature("http://apache.org/xml/features/disallow-doctype-decl", false)
def results = parser.parse(report)
def percentage = {
def covered = it.'@covered' as Double
def missed = it.'@missed' as Double
((covered / (covered + missed)) * 100).round(2)
}
def counters = results.counter
def metrics = [:]
metrics << [
'instruction': percentage(counters.find { it.'@type'.equals('INSTRUCTION') }),
'branch' : percentage(counters.find { it.'@type'.equals('BRANCH') }),
'line' : percentage(counters.find { it.'@type'.equals('LINE') }),
'complexity' : percentage(counters.find { it.'@type'.equals('COMPLEXITY') }),
'method' : percentage(counters.find { it.'@type'.equals('METHOD') }),
'class' : percentage(counters.find { it.'@type'.equals('CLASS') })
]
def failures = []
def passed = []
metrics.each {
def limit = limits[it.key]
if (it.value < limit) {
failures.add("- ${it.key} coverage rate is: ${it.value}%, minimum is ${limit}%")
} else {
passed.add("- ${it.key} coverage rate is: ${it.value}%, minimum is ${limit}%")
}
}
logger.quiet("------------------ Code Coverage -----------------------")
if (passed) {
passed.each {
logger.quiet(it)
}
}
if (failures) {
logger.quiet("FAILURES: ")
failures.each {
logger.quiet(it)
}
throw new GradleException("Code coverage failed")
}
logger.quiet("--------------------------------------------------------")
}
}
check.dependsOn jacocoTestReport
check.dependsOn javadoc