This repository has been archived by the owner on Jul 22, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbuild.gradle
136 lines (112 loc) · 3.85 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
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'commons-codec:commons-codec:1.10'
}
}
plugins {
id 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin' version '1.6'
id 'de.undercouch.download' version '3.2.0'
}
import org.apache.commons.codec.digest.DigestUtils
def jreRelease = 'v2018.1'
def jreFile = 'zulu-jre_1.8.0-131_cortexa9-vfpv3.ipk'
task downloadJRE() {
group = 'Build'
description = 'Downloads JRE ipk.'
def destFile = new File('edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/', jreFile)
def golden = 'a7e339f21c44e01017538e96fdf07963d5a22b25fd3b61456306699a24993500'
String checksum
if (destFile.exists()) {
destFile.withInputStream { ins -> checksum = DigestUtils.sha256Hex(ins) }
}
if (checksum != golden) {
download {
src "/~https://github.com/wpilibsuite/zulu-jre-ipk/releases/download/${jreRelease}/${jreFile}"
dest destFile
overwrite true
}
destFile.withInputStream { ins -> checksum = DigestUtils.sha256Hex(ins) }
if (checksum != golden) {
throw new GradleException("download checksum did not match")
}
}
}
def niPropertiesSource = file('ni_image.properties')
def niPropertiesSpec = copySpec {
from niPropertiesSource
}
task generateNiImageProperties() {
group = 'Build'
description = 'Generates ni_image.properties.'
def cppPropFile = file('edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/')
def javaPropFile = file('edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/')
inputs.file niPropertiesSource
outputs.files cppPropFile, javaPropFile
doLast {
[cppPropFile, javaPropFile].each { dest ->
copy {
with niPropertiesSpec
into dest
}
}
}
}
apply from: 'maven_commands.gradle'
executeMaven.mustRunAfter generateNiImageProperties, downloadJRE
def generatedVersionFile = file('generated_version')
task updateDependencies() {
group = 'Build'
description = 'Updates the versions of all edu.wpi.first.*:* dependencies to the latest version available.'
dependsOn updateWPILibVersionCommand, updateDependencyVersionsCommand, executeMaven
doLast {
if (!generatedVersionFile.exists()) {
generatedVersionFile.createNewFile()
}
}
}
task build() {
group = 'Build'
description = 'Assembles this project.'
dependsOn generateNiImageProperties, downloadJRE, addPackageCommand, executeMaven
// If this is an official build, or if we have never updates the dependencies (ie, this is a fresh clone), or if
// the user has specified always update dependencies, we update the version of the plugin and of our dependencies
if (WPILibVersion.releaseType.toString().equalsIgnoreCase('official') || generatedFileCheck(generatedVersionFile)) {
dependsOn updateDependencies
}
}
task assemble() {
group = 'Build'
description = 'Assembles the outputs of this project.'
dependsOn build
}
task check() {
group = 'Verification'
description = 'Runs all checks.'
dependsOn assemble
}
task mvnClean() {
group = 'Build'
description = 'Runs a \'mvn clean\'.'
dependsOn executeMaven, addCleanCommand
}
task clean(type: Delete) {
group = 'Build'
description = 'Deletes the built artifacts.'
dependsOn mvnClean
}
task wrapper(type: Wrapper) {
gradleVersion = '4.1'
}
// If the generatedVersionFile doesn't exist, or if it's content is 'always generate' ignoring case, then return true.
def generatedFileCheck(generatedVersionFile) {
if (generatedVersionFile.exists()) {
def content = generatedVersionFile.text
return content.equalsIgnoreCase('always generate')
} else {
return true
}
}