-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
281 lines (235 loc) · 8.87 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
import org.apache.tools.ant.taskdefs.condition.Os
import com.github.intrigus.ftd.util.OsUtil
import com.github.intrigus.ftd.internal.dev.DoMacPatching
buildscript {
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
classpath group: 'org.mini2Dx', name: 'parcl', version: '1.6.1'
}
}
plugins {
// Apply the java-library plugin to add support for Java Library
id 'java-library'
id "de.undercouch.download" version "4.0.1"
}
gradle.startParameter.showStacktrace = org.gradle.api.logging.configuration.ShowStacktrace.ALWAYS
wrapper {
gradleVersion = "5.0"
}
ext {
junitVersion = "5.5.2"
mockitoVersion = "2.2.7"
powermockVersion = "2.0.2"
}
allprojects {
apply plugin: "java"
group = 'com.github.intrigus.ftd'
version = '1.0.0'
test {
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
}
}
dependencies {
implementation "org.slf4j:slf4j-simple:1.7.28"
implementation "com.fasterxml.jackson.core:jackson-databind:2.9.8"
// Use JUnit test framework
testImplementation "org.junit.jupiter:junit-jupiter:$junitVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
testImplementation "org.junit.jupiter:junit-jupiter-params:$junitVersion"
}
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
}
project(":arduino-cli") {
apply plugin: "application"
application {
mainClassName = "com.github.intrigus.ftd.ArduinoCLI"
}
dependencies {
implementation "com.beust:jcommander:1.71"
implementation "org.zeroturnaround:zt-exec:1.11"
testCompile "org.mockito:mockito-core:$mockitoVersion"
testCompile "org.powermock:powermock-module-junit4:$powermockVersion"
testCompile "org.powermock:powermock-api-mockito2:$powermockVersion"
testCompile "org.powermock:powermock-api-easymock:$powermockVersion"
}
}
project(":scratch-to-c") {
apply plugin: "application"
apply plugin: "org.mini2Dx.parcl"
application {
mainClassName = "com.github.intrigus.ftd.Sb3ToArduinoC"
}
dependencies {
implementation "com.beust:jcommander:1.71"
implementation project(":arduino-cli")
}
test {
workingDir = project(":arduino-cli").projectDir
}
parcl {
linux {
binName = "stc"
}
}
}
project(":ftd-ui-server") {
apply plugin: "application"
apply plugin: "org.mini2Dx.parcl"
application {
mainClassName = "com.github.intrigus.ftd.ui.MainUI"
}
dependencies {
implementation "com.beust:jcommander:1.71"
implementation "io.undertow:undertow-core:2.1.0.Final"
implementation "org.zeroturnaround:zt-exec:1.11"
implementation project(":arduino-cli")
implementation project(":scratch-to-c")
}
parcl {
linux {
binName = "fus"
withJre("$buildDir/jre_to_be_bundled/jdk-11.0.5+10-jre")
}
exe {
exeName = "fus"
withJre("$buildDir/jre_to_be_bundled/jdk-11.0.5+10-jre")
}
app {
appName = "fus"
icon = "${project.projectDir}/icon.icns"
applicationCategory = "public.app-category.education"
displayName = 'fus'
identifier = 'com.github.intrigus.ftd.ui'
copyright = 'Copyright 2019 intrigus'
withJre("$buildDir/jre_to_be_bundled/jdk-11.0.5+10-jre/Contents/Home")
}
}
def targetFolder = {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
"${project.buildDir}/windows/"
} else if (Os.isFamily(Os.FAMILY_MAC)) {
"${project.buildDir}/mac/${parcl.app.appName}.app/Contents/Resources/"
} else if (Os.isFamily(Os.FAMILY_UNIX)) {
"${project.buildDir}/linux/"
} else {
throw new GradleException("Failed to detect the running os")
}
}()
def matchingJREUrlBase = "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.5%2B10/"
def matchingJREFileName = {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
"OpenJDK11U-jre_x64_windows_hotspot_11.0.5_10.zip"
} else if (Os.isFamily(Os.FAMILY_MAC)) {
"OpenJDK11U-jre_x64_mac_hotspot_11.0.5_10.tar.gz"
} else if (Os.isFamily(Os.FAMILY_UNIX)) {
"OpenJDK11U-jre_x64_linux_hotspot_11.0.5_10.tar.gz"
} else {
throw new GradleException("Failed to detect the running os")
}
}()
def matchingJRESHA256 = {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
"3f9e3e4256cb2c1b63b56864dca248d7f406874b21e859e5ac7ba7ada989eceb"
} else if (Os.isFamily(Os.FAMILY_MAC)) {
"dfd212023321ebb41bce8cced15b4668001e86ecff6bffdd4f2591ccaae41566"
} else if (Os.isFamily(Os.FAMILY_UNIX)) {
"2f08c469c9a8adea1b6ee3444ba2a8242a7e99d87976a077faf037a9eb7f884b"
} else {
throw new GradleException("Failed to detect the running os")
}
}()
task copyArduinoCli(type: Copy) {
from ("${project(":arduino-cli").projectDir}") {
include "arduino_cli/${OsUtil.targetName}/**"
}
into targetFolder
}
task verifyCopyArduinoCli(dependsOn: copyArduinoCli) {
doLast {
if(!file("${targetFolder}/arduino_cli/${OsUtil.targetName}/arduino-cli.yaml").exists()) {
throw new GradleException("arduino cli files for target: ${OsUtil.targetName} not found.")
}
}
}
task fetchMatchingScratchRelease(type: Download) {
src "https://github.com/intrigus/scratch-gui/releases/download/v1.0.1/scratch_dist.tar"
new File("${buildDir}/scratch_tmp/").mkdirs()
dest new File("${buildDir}/scratch_tmp/scratch_dist.tar")
}
task verifyMatchingScratchRelease(type: Verify, dependsOn: fetchMatchingScratchRelease) {
src new File("${buildDir}/scratch_tmp/", "scratch_dist.tar")
algorithm 'SHA-256'
checksum "2ed6598928a43a0b59d885ad8f6a09a78778d2fe21e82be94a31c68666fc1820"
}
task unpackMatchingScratchRelease(type: Copy, dependsOn: verifyMatchingScratchRelease) {
from tarTree(new File("${buildDir}/scratch_tmp/", "scratch_dist.tar"))
into "${targetFolder}/scratch/"
}
task fetchMatchingJRE(type: Download) {
src matchingJREUrlBase + matchingJREFileName
new File("${buildDir}/jre_tmp/").mkdirs()
dest new File("${buildDir}/jre_tmp/", matchingJREFileName)
}
task verifyMatchingJRE(type: Verify, dependsOn: fetchMatchingJRE) {
src new File("${buildDir}/jre_tmp/", matchingJREFileName)
algorithm 'SHA-256'
checksum matchingJRESHA256
}
task unpackMatchingJRE(type: Copy, dependsOn: verifyMatchingJRE) {
if(matchingJREFileName.endsWith(".zip")) {
from zipTree(new File("${buildDir}/jre_tmp/", matchingJREFileName))
} else {
from tarTree(new File("${buildDir}/jre_tmp/", matchingJREFileName))
}
into "$buildDir/jre_to_be_bundled"
}
task patchMacOsDistribution(type: DoMacPatching) {
appBundleName = parcl.app.appName
}
task distributeUnix(type: Tar) {
compression = Compression.GZIP
destinationDir = file("$buildDir/dist")
if (Os.isFamily(Os.FAMILY_MAC)) {
archiveName = "ftduino_offline_scratch_mac_x86_64.tar"
from "${project.buildDir}/mac"
} else if (Os.isFamily(Os.FAMILY_UNIX)) {
archiveName = "ftduino_offline_scratch_linux_x86_64.tar"
destinationDir = file("$buildDir/dist")
from "${project.buildDir}/linux"
}
}
task distributeWindows(type: Zip) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
archiveName = "ftduino_offline_scratch_windows_x86_64.zip"
destinationDir = file("$buildDir/dist")
from "${project.buildDir}/windows"
}
}
task distribute {
// see ArduinoCliCreator#target for information about the possible values
tasks.getByPath(":arduino-cli:gatherNecessaryBinaries").target = "ALL"
doLast {
println 'distribute'
}
}
bundleNative.dependsOn unpackMatchingJRE
copyArduinoCli.dependsOn bundleNative
unpackMatchingScratchRelease.dependsOn bundleNative
distributeWindows.dependsOn verifyCopyArduinoCli, unpackMatchingScratchRelease
patchMacOsDistribution.mustRunAfter bundleNative
distributeUnix.dependsOn patchMacOsDistribution
distributeUnix.dependsOn verifyCopyArduinoCli, unpackMatchingScratchRelease
distribute.dependsOn distributeWindows, distributeUnix
}