-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
55 lines (45 loc) · 1.43 KB
/
build.gradle
File metadata and controls
55 lines (45 loc) · 1.43 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
plugins {
id 'java'
}
group = 'dev.codeman'
version = '0.0.7'
repositories {
mavenCentral()
}
dependencies {
implementation 'com.google.code.gson:gson:2.13.2'
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
def nativeDownloadDir = layout.buildDirectory.dir("native-download").get().asFile
def downloadedNativeDllFile = nativeDownloadDir.toPath().resolve("SMTC4J.dll").toFile()
def resourcesNativeDir = layout.buildDirectory.dir("resources/main/native").get().asFile
def nativeDllFile = file("src/main/resources/native/SMTC4J.dll") // for dev environment
tasks.register("downloadNative") {
doLast {
if (downloadedNativeDllFile.exists() || nativeDllFile.exists()) {
println "Native DLL already exists, skipping download."
return
}
nativeDownloadDir.mkdirs()
def url = "https://github.com/CodeManDev/SMTC4J/releases/download/${version}/SMTC4J.dll"
println "Downloading native DLL from $url"
new URL(url).withInputStream { input ->
downloadedNativeDllFile.withOutputStream { output ->
output << input
}
}
}
}
tasks.register("copyNativeIntoResources", Copy) {
dependsOn "downloadNative"
from(downloadedNativeDllFile)
into(resourcesNativeDir)
onlyIf { downloadedNativeDllFile.exists() }
}
tasks.named("processResources") {
dependsOn "copyNativeIntoResources"
}