-
Notifications
You must be signed in to change notification settings - Fork 68
/
build.gradle
208 lines (181 loc) · 5.61 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
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
206
207
208
import org.gradle.api.internal.artifacts.transform.UnzipTransform
import org.gradle.api.internal.artifacts.ArtifactAttributes
import java.security.MessageDigest
import groovy.json.JsonOutput
import static org.gradle.api.artifacts.type.ArtifactTypeDefinition.DIRECTORY_TYPE
import static org.gradle.api.artifacts.type.ArtifactTypeDefinition.ZIP_TYPE
plugins {
id 'java'
id 'application'
id 'com.gradleup.shadow' version '8.3.3'
id "com.jfrog.artifactory" version "4.26.2"
id "com.diffplug.spotless" version "6.4.2"
id "com.github.spotbugs" version "5.1.3"
id 'maven-publish'
id 'idea'
id 'jacoco'
id 'pmd'
id 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin' version '2024.0.0'
id 'edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin' version '2020.2'
id 'checkstyle'
id 'edu.wpi.first.WpilibTools' version '2.1.0'
}
wpilibVersioning.buildServerMode = project.hasProperty('buildServer')
wpilibVersioning.releaseMode = project.hasProperty('releaseMode')
allprojects {
repositories {
mavenCentral()
}
if (project.hasProperty('releaseMode')) {
wpilibRepositories.addAllReleaseRepositories(it)
} else {
wpilibRepositories.addAllDevelopmentRepositories(it)
}
}
wpilibVersioning.version.finalizeValue()
version = wpilibVersioning.version.get()
def outputsFolder = file("$buildDir/allOutputs")
def publishingFromAllOutputs = false
if (project.hasProperty('prCombinePublish')) {
publishingFromAllOutputs = true
}
if (System.getenv()['RUN_AZURE_ARTIFACTORY_RELEASE'] != null) {
publishingFromAllOutputs = true
artifactory {
contextUrl = 'https://frcmaven.wpi.edu/artifactory' // base artifactory url
publish {
repository {
if (project.hasProperty('releaseMode')) {
repoKey = 'release'
} else {
repoKey = 'development'
}
username = System.getenv()['ARTIFACTORY_PUBLISH_USERNAME']
password = System.getenv()['ARTIFACTORY_PUBLISH_PASSWORD']
maven = true
}
defaults {
publications('maven')
}
}
clientConfig.info.setBuildName(project.name)
}
publish.dependsOn artifactoryPublish
}
apply from: 'dependencies.gradle'
shadowJar {
archiveVersion = ""
exclude("module-info.class")
archiveClassifier.set(wpilibTools.currentPlatform.platformName)
if (wpilibTools.platformMapper.currentPlatform.platformName.startsWith("mac") &&
project.hasProperty("developerID") && project.findProperty("developerID") != "") {
doLast {
exec {
workingDir rootDir
def args = ["sh", "codesign.sh", project.findProperty("developerID"),
archiveFile.get().getAsFile().getAbsolutePath()]
commandLine args
}
}
}
}
publishing {
publications {
maven(MavenPublication) {
if (publishingFromAllOutputs) {
outputsFolder.eachFile {
def dashSplit = it.name.split('-')
def clfr = dashSplit[dashSplit.length - 1].split('\\.')[0]
artifact(it) {
classifier = clfr
}
}
} else {
artifact(shadowJar)
}
groupId 'edu.wpi.first.tools'
artifactId project.name
version project.version
}
}
}
checkstyle {
toolVersion = "8.30"
}
pmd {
toolVersion = "6.22.0"
consoleOutput = true
sourceSets = [project.sourceSets.main, project.sourceSets.test]
reportsDir = file("${project.buildDir}/reports/pmd")
ruleSetFiles = files(file("$rootDir/pmd-ruleset.xml"))
ruleSets = []
}
// Spotless is used to lint and reformat source files.
spotless {
groovyGradle {
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
format("extraneous") {
target("src/**/*.fxml", "src/**/*.css", "*.xml", "*.yml", "*.md")
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
}
spotbugs {
excludeFilter = file("$rootDir/findBugsSuppressions.xml")
ignoreFailures.set(false)
showProgress.set(true)
effort.set(com.github.spotbugs.snom.Effort.MAX)
tasks.withType(com.github.spotbugs.snom.SpotBugsTask) {
def sbTask = it
reports {
create("text") {
enabled = true
}
}
finalizedBy(task("${name}Report") {
mustRunAfter(sbTask)
doLast {
def dest = sbTask.reports.first().destination;
if (dest.exists()) {
def text = dest.text
if (text != null && !text.isBlank()) {
logger.warn(text)
}
}
}
})
}
}
jacoco {
toolVersion = "0.8.8"
}
tasks.withType(JacocoReport).configureEach {
reports {
xml.required = true
html.required = true
}
}
mainClassName = ext.projectMainClass
task copyAllOutputs(type: Copy) {
destinationDir outputsFolder
dependsOn shadowJar
from shadowJar
}
build.dependsOn copyAllOutputs
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.compilerArgs << "-Xlint:deprecation"
}
tasks.withType(Jar).configureEach {
manifest {
attributes["Implementation-Version"] = project.version as String
attributes["Built-Date"] = Instant.now().toString()
}
}
wrapper {
gradleVersion = '8.10.2'
}