-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchecks.gradle
137 lines (116 loc) · 3.63 KB
/
checks.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
import javax.xml.transform.TransformerFactory
import javax.xml.transform.stream.StreamResult
import javax.xml.transform.stream.StreamSource
import static org.gradle.api.tasks.PathSensitivity.NONE
allprojects {
ext {
pmd_tool_ver = "6.16.0"
checkstyle_tool_ver = "8.21"
spotbugs_tool_ver = "4.0.0-beta3"
}
apply {
plugin 'pmd'
plugin 'checkstyle'
plugin 'idea'
plugin 'com.github.spotbugs'
}
pmd {
ignoreFailures = false
rulePriority = 2
toolVersion = pmd_tool_ver
pmdTest.enabled = false
sourceSets = [sourceSets.main]
ruleSets = []
ruleSetFiles = files("${rootProject.projectDir}/codestyle/pmd.xml")
pmdMain {
reports {
html.enabled = true
xml.enabled = false
}
}
}
spotbugs {
effort = "max"
reportLevel = "high"
toolVersion = spotbugs_tool_ver
ignoreFailures = false
spotbugsTest.enabled = false
}
checkstyle {
ignoreFailures = false
config = resources.text.fromFile("${rootProject.projectDir}/codestyle/checkstyle.xml")
maxWarnings = 10
toolVersion = checkstyle_tool_ver
sourceSets = [sourceSets.main]
showViolations = false
checkstyleTest.enabled = false
checkstyleMain {
reports {
html.enabled = true
xml.enabled = false
}
}
}
task copyPmdReport(type: Copy) {
from "$buildDir/reports/pmd"
into "${rootProject.buildDir}/reports/pmd"
include "main.html"
rename "main.html", "${project.name}.html"
includeEmptyDirs = false
doLast {
if (project.name == rootProject.name) {
delete file("${rootProject.buildDir}/reports/pmd/main.html")
}
}
}
task copySpotBugsReports(type: Copy) {
from "$buildDir/reports/spotbugs"
into "${rootProject.buildDir}/reports/spotbugs/"
include "main.html"
rename "main.html", "${module.project.name}.html"
includeEmptyDirs = false
doLast {
if (project.name == rootProject.name) {
delete file("${rootProject.buildDir}/reports/spotbugs/main.html")
}
}
}
task copyCheckstyleReports(type: Copy) {
from "$buildDir/reports/checkstyle"
into "${rootProject.buildDir}/reports/checkstyle/"
include "main.html"
rename "main.html", "${module.project.name}.html"
includeEmptyDirs = false
doLast {
if (project.name == rootProject.name) {
delete file("${rootProject.buildDir}/reports/checkstyle/main.html")
delete file("${rootProject.buildDir}/reports/checkstyle/main.xml")
}
}
}
spotbugsMain {
reports {
xml.withMessages true
}
task spotbugsMainHtmlReport {
//def transformer = new net.sf.saxon.TransformerFactoryImpl()
def input = reports.xml.destination
inputs.file file("${rootProject.projectDir}/codestyle/fancy-hist.xsl") withPropertyName 'spotbugsStylesheet' withPathSensitivity NONE
inputs.files fileTree(input) withPropertyName 'input' withPathSensitivity NONE skipWhenEmpty()
def output = file(input.absolutePath.replaceFirst(/\.xml$/, '.html'))
outputs.file output withPropertyName 'output'
doLast {
def factory = TransformerFactory.newInstance()
def transformer = factory.newTransformer(new StreamSource(file("${rootProject.projectDir}/codestyle/fancy-hist.xsl")))
transformer.transform(new StreamSource(input), new StreamResult(output))
}
}
spotbugsMain.finalizedBy spotbugsMainHtmlReport
spotbugsMainHtmlReport.finalizedBy copySpotBugsReports
}
pmdMain.finalizedBy copyPmdReport
checkstyleMain.finalizedBy copyCheckstyleReports
task lint {
dependsOn spotbugsMain, pmdMain, checkstyleMain
}
}