-
Notifications
You must be signed in to change notification settings - Fork 123
/
build.gradle
210 lines (173 loc) · 5.83 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
209
210
//noinspection GradleDependency
buildscript {
ext.min_sdk_version = "8.2.0"
}
plugins {
id "com.github.node-gradle.node" version "2.2.4"
}
apply plugin: "com.android.library"
apply plugin: "maven-publish"
apply plugin: "checkstyle"
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 23
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 26
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions {
abortOnError false
}
}
node {
version = "18.12.1"
download = true
nodeModulesDir = file("${project.projectDir}/dash")
}
yarn_build.dependsOn yarn_install
task cleanDashAssets(type: Delete) {
delete "${android.sourceSets.getByName("main").assets.srcDirs[0]}/dash"
}
clean.dependsOn cleanDashAssets
task copyDashAssets(type: Copy) {
from "${project.projectDir}/dash/dist"
into "${android.sourceSets.getByName("main").assets.srcDirs[0]}/dash"
}
copyDashAssets.dependsOn cleanDashAssets
copyDashAssets.dependsOn yarn_build
android.libraryVariants.all { variant ->
variant.preBuildProvider.get().dependsOn copyDashAssets
}
// adapted from https://github.com/Genymobile/gnirehtet/blob/master/config/android-checkstyle.gradle
check.dependsOn "checkstyle"
checkstyle {
toolVersion = checkstyle_version
}
task checkstyle(type: Checkstyle) {
description = "Check Java style with Checkstyle"
configFile = rootProject.file("config/checkstyle/checkstyle.xml")
source = javaSources()
classpath = files()
ignoreFailures = true
}
// I"d like to replace each() with collectMany() if only I knew how
// Also, the static suggestion here is wrong but I lack the incantation to suppress it
def javaSources() {
def files = []
android.sourceSets.each { sourceSet ->
sourceSet.java.each { javaSource ->
javaSource.getSrcDirs().each {
if (it.exists()) {
files.add(it)
}
}
}
}
return files
}
repositories {
flatDir {
dirs "../libs"
}
mavenCentral()
}
// Probably not worth combining with addPomDependencies()
// Keep them in sync manually
dependencies {
api(project(":DashboardCore")) {
transitive = false
}
api "org.firstinspires.ftc:RobotCore:$min_sdk_version"
api "org.firstinspires.ftc:Hardware:$min_sdk_version"
api "org.firstinspires.ftc:RobotServer:$min_sdk_version"
api "org.firstinspires.ftc:FtcCommon:$min_sdk_version"
implementation "androidx.annotation:annotation:1.1.0"
implementation("org.nanohttpd:nanohttpd-websocket:2.3.1") {
exclude module: "nanohttpd"
}
}
def addPomDependencies(root) {
def depsNode = root.appendNode("dependencies")
// Apparently you can make closures but not "inner methods"
def addDep = { groupId, artifactId, version ->
def n = depsNode.appendNode("dependency")
n.appendNode("groupId", groupId)
n.appendNode("artifactId", artifactId)
n.appendNode("version", version)
return n
}
addDep("com.acmerobotics.dashboard", "core", dashboard_version)
["RobotCore", "Hardware", "RobotServer", "FtcCommon"].forEach {
addDep("org.firstinspires.ftc", it, min_sdk_version)
}
addDep("androidx.annotation", "annotation", "1.1.0")
addDep("org.nanohttpd", "nanohttpd-websocket", "2.3.1")
.appendNode("exclusions")
.appendNode("exclusion")
.with {
appendNode("groupId", "org.nanohttpd")
appendNode("artifactId", "nanohttpd")
}
}
task androidSourcesJar(type: Jar) {
classifier = "sources"
from android.sourceSets.main.java.srcDirs
}
task androidJavadocs(type: Javadoc) {
failOnError = false
source = android.sourceSets.main.java.srcDirs
ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
classpath += files(ext.androidJar)
}
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = "javadoc"
from androidJavadocs.destinationDir
}
project.afterEvaluate {
publishing {
publications {
maven(MavenPublication) {
artifact bundleReleaseAar
artifact androidSourcesJar
artifact androidJavadocsJar
groupId = "com.acmerobotics.dashboard"
artifactId = "dashboard"
version dashboard_version
pom {
description = "Web dashboard designed for FTC"
name = "FTC Dashboard"
url = "https://github.com/acmerobotics/ftc-dashboard"
licenses {
license {
name = "The MIT License"
url = "https://opensource.org/licenses/MIT"
distribution = "repo"
}
}
developers {
developer {
id = "rbrott"
name = "Ryan Brott"
email = "[email protected]"
}
}
scm {
url = "https://github.com/acmerobotics/ftc-dashboard"
}
}
// Seems like you can"t define ad hoc software components without a plugin.
// Remind me never to read the Gradle docs again.
pom.withXml {
// Android Studio complains here, but passing null straight up doesn't work
//noinspection GroovyImplicitNullArgumentCall
def root = asNode()
addPomDependencies(root)
}
}
}
}
}