-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
128 lines (110 loc) 路 3.39 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
import java.text.SimpleDateFormat
plugins {
id "org.jetbrains.kotlin.jvm" version "1.3.10"
id "edu.wpi.first.GradleRIO" version "2019.1.1"
}
ext.kotlinVersion = "1.3.10"
ext.ktlintVersion = "0.29.0"
ext.sertainVersion = "a2c505171b318836e0619b3c25dabae3a7857bf5"
ext.badlogVersion = "d3f791967f11888df925af0a32178b264fce42a6"
check.dependsOn "ktlint"
compileKotlin.dependsOn "versionTxt"
tasks.whenTaskAdded { task ->
if (task.name == "deploy" || task.name == "deployMain") task.dependsOn "assemble"
}
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
maven { url "http://first.wpi.edu/FRC/roborio/maven/release" }
maven { url "https://raw.githubusercontent.com/Open-RIO/Maven-Mirror/master/m2" }
maven { url "https://www.kauailabs.com/maven2" }
}
configurations {
ktlint
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
compile project("meanlib")
compile "com.github.SouthEugeneRoboticsTeam:badlog:$badlogVersion"
compile "com.github.sertain.sertain:core:$sertainVersion"
compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.0"
compile "com.kauailabs.navx.frc:navx-java:3.1.344"
compile wpi.deps.wpilib()
compile wpi.deps.vendor.java()
nativeZip wpi.deps.vendor.jni(wpi.platforms.roborio)
nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop)
ktlint "com.github.shyiko:ktlint:$ktlintVersion"
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
deploy {
targets {
roboRIO("roborio") {
team = frc.getTeamOrDefault(2521)
}
}
artifacts {
frcJavaArtifact('frcJava') {
targets << "roborio"
debug = frc.getDebugOrDefault(false)
}
fileTreeArtifact('frcStaticFileDeploy') {
files = fileTree(dir: 'src/main/deploy')
targets << "roborio"
directory = '/home/lvuser/deploy'
}
}
}
jar {
from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
manifest {
attributes(
"Main-Class": "org.sert2521.gamename.MainKt"
)
}
}
task ktlint(type: JavaExec) {
main = "com.github.shyiko.ktlint.Main"
classpath = configurations.ktlint
args "src/**/*.kt"
}
def getGitHash = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine "git", "rev-parse", "HEAD"
standardOutput = stdout
}
return stdout.toString().trim()
}
def getGitBranch = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
standardOutput = stdout
}
return stdout.toString().trim()
}
def getGitFilesChanged = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine "git", "diff", "--name-only", "HEAD"
standardOutput = stdout
}
return stdout.toString().trim().replace("\n", ", ")
}
task versionTxt() {
doLast {
String resourcesDir = "$projectDir/src/main/resources"
new File("$resourcesDir/branch.txt").text = getGitBranch()
new File("$resourcesDir/commit.txt").text = getGitHash()
new File("$resourcesDir/changes.txt").text = getGitFilesChanged()
new File("$resourcesDir/buildtime.txt").text =
new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date())
}
}
wrapper {
gradleVersion = "5.1"
}