forked from WPIRoboticsProjects/GRIP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
205 lines (177 loc) · 5.76 KB
/
build.gradle.kts
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
import org.ajoberstar.grgit.Grgit
import com.github.spotbugs.SpotBugsTask
buildscript {
repositories {
jcenter()
maven {
setUrl("https://github.com/WPIRoboticsProjects/opencv-maven/raw/mvn-repo")
}
}
dependencies {
classpath(group = "de.dynamicfiles.projects.gradle.plugins", name = "javafx-gradle-plugin", version = "8.8.2")
classpath(group = "edu.wpi.first.wpilib.opencv", name = "opencv-installer", version = "2.0.0")
}
}
plugins {
`java`
`jacoco`
`checkstyle`
`pmd`
id("com.github.johnrengelman.shadow") version "4.0.3"
id("com.google.osdetector") version "1.4.0"
id("org.ajoberstar.grgit") version "2.0.0" apply false
id("net.ltgt.errorprone") version "0.0.16"
id("com.github.spotbugs") version "1.6.4"
id("com.gradle.build-scan") version "2.1"
}
buildScan {
setTermsOfServiceUrl("https://gradle.com/terms-of-service")
setTermsOfServiceAgree("yes")
}
repositories {
mavenCentral()
jcenter()
}
tasks.withType<Wrapper>().configureEach {
gradleVersion = "5.0"
distributionType = Wrapper.DistributionType.ALL
}
fun javaSubprojects(action: Project.() -> Unit) {
subprojects.minus(project(":ui:linuxLauncher")).forEach { project ->
project.action()
}
}
var grgit: Grgit? = null
if (rootProject.file(".git").exists()) {
project.apply {
plugin("org.ajoberstar.grgit")
}
grgit = Grgit.open()
}
javaSubprojects {
apply {
plugin("java")
plugin("org.gradle.jacoco")
plugin("org.gradle.pmd")
plugin("org.gradle.checkstyle")
plugin("net.ltgt.errorprone")
plugin("com.github.spotbugs")
}
repositories {
mavenCentral()
jcenter()
maven {
name = "WPILib Maven Release"
setUrl("http://first.wpi.edu/FRC/roborio/maven/release")
}
maven {
name = "rosjava Maven"
setUrl("https://github.com/rosjava/rosjava_mvn_repo/raw/master")
}
maven {
name = "GRIP ROS Maven"
setUrl("https://github.com/WPIRoboticsProjects/rosjava_mvn_repo/raw/master")
}
}
version = getVersionName()
dependencies {
"compile"(group = "com.google.code.findbugs", name = "annotations", version = "3.0.1")
"testCompile"(group = "net.jodah", name = "concurrentunit", version = "0.4.2")
"testCompile"(group = "org.hamcrest", name = "hamcrest-all", version = "1.3")
"testCompile"(group = "junit", name = "junit", version = "4.12")
"testCompile"(group = "com.google.truth", name = "truth", version = "0.34")
"testCompile"(group = "com.google.guava", name = "guava-testlib", version = "22.0")
}
checkstyle {
configFile = rootDir.resolve("checkstyle.xml")
toolVersion = "6.19"
if (project.hasProperty("ignoreCheckstyle")) {
isIgnoreFailures = true
}
}
pmd {
toolVersion = "5.6.0"
isConsoleOutput = true
val projectSourcesSets = [email protected]
sourceSets = listOf(projectSourcesSets["main"], projectSourcesSets["test"])
reportsDir = buildDir.resolve("reports/pmd")
ruleSetFiles = files(rootDir.resolve("pmd-ruleset.xml"))
}
configurations["errorprone"].apply {
resolutionStrategy.force("com.google.errorprone:error_prone_core:2.3.2")
}
spotbugs {
toolVersion = "3.1.7"
val javaSources = [email protected]
sourceSets = setOf(javaSources["main"], javaSources["test"])
excludeFilter = file("$rootDir/findBugsSuppressions.xml")
effort = "max"
}
tasks.withType<SpotBugsTask> {
reports {
xml.isEnabled = false
emacs.isEnabled = true
}
finalizedBy(task("${name}Report") {
mustRunAfter(this@withType)
doLast {
this@withType
.reports
.emacs
.destination
.takeIf { it.exists() }
?.readText()
.takeIf { !it.isNullOrBlank() }
?.also { logger.warn(it) }
}
})
}
tasks.named<JacocoReport>("jacocoTestReport") {
reports {
html.isEnabled = true
xml.isEnabled = true
}
}
tasks.withType<Javadoc> {
source(tasks.named<JavaCompile>("compileJava").map { it.source })
}
}
tasks.register<JacocoReport>("jacocoRootReport") {
group = "Coverage reports"
description = "Generates an aggregate report from all subprojects"
// Based on the codecov Gradle example: https://github.com/codecov/example-gradle
javaSubprojects {
[email protected](sourceSets["main"])
[email protected](tasks.named<JacocoReport>("jacocoTestReport"))
}
executionData(fileTree(rootDir.absolutePath).include("**/build/jacoco/*.exec"))
reports {
xml.isEnabled = true
xml.destination = buildDir.resolve("reports/jacoco/report.xml")
html.isEnabled = false
csv.isEnabled = false
}
}
fun Project.getGitCommit(): String {
return grgit?.head()?.abbreviatedId ?: "<no commit>"
}
fun Project.getGitDescribe(): String {
return grgit?.describe() ?: "v0.0.0"
}
fun Project.getGitDescribeAbbrev(): String {
return grgit?.tag?.list()?.last()?.name ?: "v0.0.0"
}
fun Project.getVersionName(): String {
if (project.hasProperty("vers")) {
val vers: String by properties
return vers
}
return getGitDescribe()
}
fun Project.getVersionSimple(): String {
if (project.hasProperty("vers")) {
val vers: String by properties
return vers
}
return getGitDescribeAbbrev()
}