forked from wpilibsuite/PathWeaver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
220 lines (189 loc) · 6.38 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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.jvm.tasks.Jar
import org.gradle.testing.jacoco.tasks.JacocoReport
import java.time.Instant
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jfrog.gradle.plugin.artifactory.dsl.PublisherConfig
import groovy.lang.GroovyObject
buildscript {
repositories {
mavenCentral()
jcenter()
}
}
plugins {
`maven-publish`
jacoco
java
pmd
application
id("edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin") version "4.0.1"
id("edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin") version "2020.1"
id("com.jfrog.artifactory") version "4.9.8"
id("com.github.johnrengelman.shadow") version "4.0.3"
id("com.diffplug.gradle.spotless") version "3.25.0"
}
if (hasProperty("buildServer")) {
wpilibVersioning.isBuildServerMode = true
}
if (hasProperty("releaseMode")) {
wpilibVersioning.isReleaseMode = true
}
repositories {
mavenCentral()
}
if (hasProperty("releaseMode")) {
wpilibRepositories.addAllReleaseRepositories(project)
} else {
wpilibRepositories.addAllDevelopmentRepositories(project)
}
repositories {
maven {
url = uri("https://dev.imjac.in/maven/")
}
maven {
url = uri("https://first.wpi.edu/FRC/roborio/maven/release/")
}
}
wpilibVersioning.version.finalizeValue()
version = wpilibVersioning.version.get()
if (System.getenv()["RUN_AZURE_ARTIFACTORY_RELEASE"] != null) {
artifactory {
setContextUrl("https://frcmaven.wpi.edu/artifactory") // base artifactory url
publish(delegateClosureOf<PublisherConfig> {
repository(delegateClosureOf<GroovyObject> {
if (project.hasProperty("releaseMode")) {
setProperty("repoKey", "release")
} else {
setProperty("repoKey", "development")
}
setProperty("username", System.getenv()["ARTIFACTORY_PUBLISH_USERNAME"])
setProperty("password", System.getenv()["ARTIFACTORY_PUBLISH_PASSWORD"])
setProperty("maven", true)
})
defaults(delegateClosureOf<GroovyObject> {
invokeMethod("publications", "app")
})
})
clientConfig.info.buildName = "PathWeaver"
}
tasks.named("publish") {
dependsOn(tasks.named("artifactoryPublish"))
}
}
val theMainClassName = "edu.wpi.first.pathweaver.Main"
tasks.withType<Jar>().configureEach {
manifest {
attributes["Implementation-Version"] = project.version as String
attributes["Built-Date"] = Instant.now().toString()
attributes["Main-Class"] = theMainClassName
}
}
application {
mainClassName = theMainClassName
}
// Spotless is used to lint and reformat source files.
spotless {
java {
removeUnusedImports()
}
kotlinGradle {
ktlint("0.33.0")
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
format("extraneous") {
target("Dockerfile", "*.sh", "*.yml")
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
}
createNativeConfigurations()
dependencies {
javafx(name = "base")
javafx(name = "controls")
javafx(name = "fxml")
javafx(name = "graphics")
compile(group = "org.fxmisc.easybind", name = "easybind", version = "1.0.3")
compile(group = "javax.measure", name = "unit-api", version = "1.0")
compile(group = "si.uom", name = "si-units", version = "2.0.1")
compile(group = "systems.uom", name = "systems-common", version = "2.0")
compile(group = "tech.units", name = "indriya", version = "2.0.1")
compile(group = "com.google.code.gson", name = "gson", version = "2.8.5")
compile(group = "org.apache.commons", name = "commons-csv", version = "1.5")
compile(group = "org.ejml", name = "ejml-simple", version = "0.38")
compile(group = "edu.wpi.first.wpiutil", name = "wpiutil-java", version = "2020.+")
compile(group = "edu.wpi.first.wpilibj", name = "wpilibj-java", version = "2020.+")
compile(group = "com.fasterxml.jackson.core", name = "jackson-annotations", version = "2.10.0")
compile(group = "com.fasterxml.jackson.core", name = "jackson-core", version = "2.10.0")
compile(group = "com.fasterxml.jackson.core", name = "jackson-databind", version = "2.10.0")
fun junitJupiter(name: String, version: String = "5.5.0") =
create(group = "org.junit.jupiter", name = name, version = version)
testCompile(junitJupiter(name = "junit-jupiter-api"))
testCompile(junitJupiter(name = "junit-jupiter-params"))
testRuntime(junitJupiter(name = "junit-jupiter-engine"))
}
tasks.withType<JavaCompile>().configureEach {
// UTF-8 characters are used in menus
options.encoding = "UTF-8"
options.compilerArgs.add("-Xlint:unchecked")
options.compilerArgs.add("-Xlint:deprecation")
}
jacoco {
toolVersion = "0.8.2"
}
extensions.getByType<PmdExtension>().apply {
toolVersion = "6.19.0"
isConsoleOutput = true
reportsDir = file("${project.buildDir}/reports/pmd")
ruleSetFiles = files(file("$rootDir/pmd-ruleset.xml"))
ruleSets = emptyList()
}
tasks.withType<JacocoReport>().configureEach {
reports {
xml.isEnabled = true
html.isEnabled = true
}
}
tasks.withType<Test>().configureEach {
useJUnitPlatform()
}
val nativeShadowTasks = NativePlatforms.values().map { platform ->
tasks.create<ShadowJar>("shadowJar-${platform.platformName}") {
classifier = platform.platformName
configurations = listOf(
project.configurations.getByName("compile"),
project.configurations.getByName(platform.platformName)
)
from(
project.sourceSets["main"].output
)
}
}
tasks.create("shadowJarAllPlatforms") {
nativeShadowTasks.forEach {
this.dependsOn(it)
}
}
tasks.withType<ShadowJar>().configureEach {
exclude("module-info.class")
}
publishing {
publications {
create<MavenPublication>("app") {
groupId = "edu.wpi.first.wpilib"
artifactId = "PathWeaver"
version = project.version as String
nativeShadowTasks.forEach {
artifact(it) {
classifier = it.classifier
}
}
}
}
}
tasks.withType<Wrapper>().configureEach {
gradleVersion = "5.0"
}