-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
259 lines (216 loc) · 7.45 KB
/
Copy pathbuild.gradle
File metadata and controls
259 lines (216 loc) · 7.45 KB
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
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.1.0'
}
group = 'com.funkylogclient'
version = '2.0.8'
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
compileJava {
options.encoding = 'UTF-8'
}
repositories {
mavenCentral()
maven { url = 'https://jitpack.io' }
maven {
url = 'https://frcmaven.wpi.edu/artifactory/release/'
}
}
dependencies {
implementation 'edu.wpi.first.ntcore:ntcore-java:2025.3.2'
implementation 'edu.wpi.first.ntcore:ntcore-jni:2025.3.2:windowsx86-64'
implementation 'edu.wpi.first.ntcore:ntcore-jni:2025.3.2:osxuniversal'
implementation 'edu.wpi.first.wpiutil:wpiutil-java:2025.3.2'
implementation 'edu.wpi.first.wpiutil:wpiutil-jni:2025.3.2:windowsx86-64'
implementation 'edu.wpi.first.wpiutil:wpiutil-jni:2025.3.2:osxuniversal'
implementation 'com.fasterxml.jackson.core:jackson-core:2.15.2'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2'
implementation 'net.java.jinput:jinput:2.0.10'
runtimeOnly 'net.java.jinput:jinput:2.0.10:natives-all'
// XInput support so Xbox / "XINPUT compatible HID" controllers are detected on Windows
implementation 'com.github.RalleYTN:XInput-Plugin-for-JInput:1.2.1'
}
javafx {
version = '21.0.7'
modules = [ 'javafx.controls', 'javafx.fxml' ]
}
application {
mainClass = 'com.funkylogclient.Main'
}
run {
workingDir = projectDir
def osName = System.getProperty("os.name").toLowerCase()
def libPath = new File(projectDir, 'build/libs/windows/x86-64').absolutePath
if (osName.contains("mac")) {
libPath = new File(projectDir, 'build/libs/osx/universal').absolutePath
}
jvmArgs = [
'-Djava.library.path=' + libPath,
'-Dwpiutil.debug=true',
'-Dwpiutil.nativelibdir=' + libPath,
'-XX:+UseG1GC',
'-XX:MaxGCPauseMillis=20'
]
}
task unpackNativeLibs(type: Copy) {
doFirst {
def jniDeps = configurations.runtimeClasspath.filter {
it.name.contains('jni')
}
if (jniDeps.empty) {
println "No JNI dependency found"
} else {
jniDeps.each { dep ->
println "Found JNI jar: ${dep.name}"
}
}
}
from(configurations.runtimeClasspath.filter {
it.name.contains('jni')
}.collect { zipTree(it) })
eachFile { println "Extracting: ${it.path}" }
include '**/*.dll'
include '**/*.so'
include '**/*.dylib'
into 'build/libs'
}
task unpackJInputNatives(type: Copy) {
def jinputNatives = configurations.runtimeClasspath.filter {
it.name.contains('jinput') && it.name.contains('natives')
}
onlyIf { !jinputNatives.isEmpty() }
from(jinputNatives.collect { zipTree(it) })
include '**/*.dll'
include '**/*.jnilib'
include '**/*.dylib'
eachFile { fcd -> fcd.path = fcd.name }
def osName = System.getProperty("os.name").toLowerCase()
if (osName.contains("mac")) {
into 'build/libs/osx/universal'
} else {
into 'build/libs/windows/x86-64'
}
}
tasks.named('startScripts').configure {
dependsOn unpackNativeLibs
mustRunAfter unpackNativeLibs
}
tasks.named('distZip').configure {
dependsOn unpackNativeLibs
mustRunAfter unpackNativeLibs
}
tasks.named('distTar').configure {
dependsOn unpackNativeLibs
mustRunAfter unpackNativeLibs
}
unpackJInputNatives.mustRunAfter unpackNativeLibs
run.dependsOn unpackNativeLibs, unpackJInputNatives
jar {
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
manifest {
attributes 'Main-Class': 'com.funkylogclient.Main'
}
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
clean {
delete 'build', 'target'
}
build.dependsOn unpackNativeLibs
task prepareJpackageInput(type: Copy) {
dependsOn jar, unpackNativeLibs, unpackJInputNatives
from jar.archiveFile
into 'build/jpackage-input'
from('build/libs/windows') {
into 'windows'
}
from('build/libs/osx') {
into 'osx'
}
}
task jpackageExe(type: Exec) {
dependsOn prepareJpackageInput
description = 'Create Windows EXE bundle with bundled JRE'
group = 'build'
def javaHome = System.getProperty('java.home')
def jpackageExePath = new File(javaHome, 'bin/jpackage.exe')
def jpackageCmd = []
doFirst {
if (!jpackageExePath.exists()) {
throw new GradleException("jpackage not found at ${jpackageExePath}. Please use JDK 17 or later (not JRE).")
}
delete 'build/dist/chimpcheck'
println "Building Windows EXE bundle with jpackage..."
jpackageCmd = [
jpackageExePath.absolutePath,
'--type', 'app-image',
'--name', 'chimpcheck',
'--app-version', version,
'--input', 'build/jpackage-input',
'--main-jar', "funkylogclient-${version}.jar",
'--main-class', 'com.funkylogclient.Main',
'--dest', 'build/dist',
'--java-options', '-Djava.library.path=$APPDIR\\windows\\x86-64',
'--java-options', '-Dwpiutil.nativelibdir=$APPDIR\\windows',
'--java-options', '-XX:+UseG1GC',
'--java-options', '-XX:MaxGCPauseMillis=20'
]
commandLine jpackageCmd
}
doLast {
println ""
println "=========================================="
println "Build complete: build/dist/chimpcheck/chimpcheck.exe"
println "=========================================="
}
}
task jpackageMac(type: Exec) {
dependsOn prepareJpackageInput
description = 'Create macOS .app bundle with bundled JRE'
group = 'build'
def javaHome = System.getProperty('java.home')
def jpackagePath = new File(javaHome, 'bin/jpackage')
def jpackageCmd = []
doFirst {
if (!jpackagePath.exists()) {
throw new GradleException("jpackage not found at ${jpackagePath}. Please use JDK 17 or later (not JRE).")
}
delete 'build/dist/ChimpCheck.app'
println "Building macOS .app bundle with jpackage..."
jpackageCmd = [
jpackagePath.absolutePath,
'--type', 'app-image',
'--name', 'ChimpCheck',
'--app-version', version,
'--input', 'build/jpackage-input',
'--main-jar', "funkylogclient-${version}.jar",
'--main-class', 'com.funkylogclient.Main',
'--dest', 'build/dist',
'--java-options', '-Djava.library.path=$APPDIR/osx/universal',
'--java-options', '-Dwpiutil.nativelibdir=$APPDIR/osx/universal',
'--java-options', '-XX:+UseG1GC',
'--java-options', '-XX:MaxGCPauseMillis=20'
]
def iconFile = file('src/main/resources/com/funkylogclient/logo846.icns')
if (iconFile.exists()) {
jpackageCmd.addAll(['--icon', iconFile.absolutePath])
}
commandLine jpackageCmd
}
doLast {
println ""
println "=========================================="
println "Build complete: build/dist/ChimpCheck.app"
println "=========================================="
}
}
def currentOs = System.getProperty('os.name').toLowerCase()
if (currentOs.contains('mac')) {
build.finalizedBy jpackageMac
} else {
build.finalizedBy jpackageExe
}