-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
163 lines (137 loc) · 5 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
import edu.wpi.first.gradlerio.GradleRIOPlugin
plugins {
id "java"
id "maven"
id "edu.wpi.first.GradleRIO" version "2020.1.1"
id "org.jetbrains.kotlin.jvm" version "1.3.50"
id "com.palantir.git-version" version "0.12.2"
}
group "org.team1540"
version gitVersion()
// Maven/Jitpack configuration
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
install {
doLast {
System.out.println("Installing with version " + gitVersion())
}
}
artifacts {
archives sourcesJar
archives javadocJar
}
javadoc {
options {
header '<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>'
links 'http://first.wpi.edu/FRC/roborio/release/docs/java/', "https://docs.oracle.com/en/java/javase/11/docs/api/"
}
options.addStringOption("doctitle", "ROOSTER API")
options.addStringOption("windowtitle", "ROOSTER API")
options.addBooleanOption("-allow-script-in-comments", true)
options.addBooleanOption('Xdoclint:all,-missing', true)
}
// Dependencies
repositories {
mavenCentral()
maven {
name "JitPack"
url "https://jitpack.io/"
}
}
dependencies {
// FRC dependencies
implementation wpi.deps.wpilib()
nativeZip wpi.deps.wpilibJni(wpi.platforms.roborio)
nativeDesktopZip wpi.deps.wpilibJni(wpi.platforms.desktop)
implementation wpi.deps.vendor.java()
nativeZip wpi.deps.vendor.jni(wpi.platforms.roborio)
nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop)
// Non-FRC dependencies
compile 'org.jetbrains:annotations:16.0.3'
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.50"
compile 'org.slf4j:slf4j-log4j12:1.6.1'
compile 'log4j:log4j:1.2.16'
compile "com.google.guava:guava:27.0-jre"
compile "org.apache.commons:commons-math3:3.6.1"
// Last release was in 2014, so we're just pinning it to this commit instead
compile "com.github.oxo42:stateless4j:3dd512049f"
}
// deployment and GradleRIO
// define the testbots source set
sourceSets {
testbots {
compileClasspath += sourceSets.main.output
runtimeClasspath += sourceSets.main.output
}
}
configurations {
testbotsImplementation.extendsFrom implementation
testbotsRuntimeOnly.extendsFrom runtimeOnly
}
// task to create robotclass.txt
task createRobotclassTxt {
inputs.property("robotClass", project.hasProperty("robotClass") ? project.robotClass : "")
outputs.files("$buildDir/robotclass.txt")
doLast {
if (!project.hasProperty("robotClass")) {
throw new GradleException("Robot class not set. Pass a value in on the command line by adding -ProbotClass=<your robot class>.")
} else {
System.out.println("Using robot class " + project.robotClass)
new File("$buildDir/robotclass.txt").text = project.robotClass
}
}
}
deploy {
targets {
roboRIO("roborio") {
team = frc.getTeamOrDefault(1540)
}
}
artifacts {
frcJavaArtifact('frcJava') {
targets << "roborio"
/*
IMPORTANT: With the "deploy-debug" property set (i.e. -Pdeploy-debug is on the
command line), the robot code will not start until you connect your debugger to the
robot. Connect by running the "Remote Robot Debug" run configuration which should be
shared through version control. Alternatively, remove this line and redeploy.
*/
debug = project.hasProperty("deploy-debug")
}
// This is a file (generated by the task above) that contains the name of the robot class we want to deploy.
// The file then gets read by TestbotLoaderMain and it instantiates the class using
// reflection.
// TODO: Maybe a build-time check that said class file actually exists somewhere in the project?
fileArtifact('robotclassTxt') {
targets << "roborio"
file = file("$buildDir/robotclass.txt")
directory = "/home/lvuser/"
dependsOn(createRobotclassTxt)
}
}
}
jar.dependsOn(compileTestbotsJava)
jar {
inputs.files(compileTestbotsJava.outputs.files)
gradle.taskGraph.whenReady {
if (gradle.taskGraph.hasTask(":deployFrcJavaRoborio") || gradle.taskGraph.hasTask(":simulateJava") || gradle.taskGraph.hasTask(":simulateExternalJava")) {
// fully qualified task name is needed
System.out.println("Deployment or simulation detected.")
from((configurations.compile.collect {
it.isDirectory() ? it : zipTree(it)
}) + sourceSets.testbots.output)
manifest GradleRIOPlugin.javaManifest("org.team1540.rooster.testing.TestbotLoaderMain")
}
}
}
// wrapper
wrapper {
gradleVersion = '6.0.1'
distributionType = Wrapper.DistributionType.ALL
}