-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
74 lines (63 loc) · 2.21 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
import java.security.MessageDigest
plugins {
id 'java'
}
group = 'com.github.EchoInMirror.EIMTimeStretchers'
version = System.getenv('VERSION') ?: '0.0.0'
subprojects {
apply plugin: 'java'
apply plugin: 'maven-publish'
group = 'com.github.EchoInMirror.EIMTimeStretchers'
version = System.getenv('VERSION') ?: '0.0.0'
tasks.withType(JavaCompile).each {
it.options.compilerArgs.add('--enable-preview')
}
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
groupId project.group
artifactId project.name
version project.version
}
}
}
task downloadLibs(type: Copy) {
downloadLib('-x86_64.dylib', 'macos')
downloadLib('.dylib', 'macos')
downloadLib('.dll', 'windows')
downloadLib('.so', 'linux')
}
tasks.withType(JavaCompile) {
dependsOn downloadLibs
}
}
def downloadLib(String ext, String source) {
def file = new File("$projectDir/$source/src/main/resources/eim-time-stretchers/libEIMTimeStretchers$ext")
if (file.exists()) return
file.parentFile.mkdirs()
println("Downloading: libEIMTimeStretchers$ext")
new FileOutputStream(file).withCloseable { out ->
new URL("https://github.com/EchoInMirror/EIMTimeStretchers/releases/latest/download/libEIMTimeStretchers$ext")
.withInputStream { input ->
out << input
// calc sha256 then write to .sha256 file
new File(file.absolutePath + '.sha256').withPrintWriter { writer ->
writer.print(sha256(file))
}
}
}
}
static def sha256(File file) {
def messageDigest = MessageDigest.getInstance("SHA-256")
new FileInputStream(file).withCloseable { input ->
byte[] buffer = new byte[8192]
int read
while ((read = input.read(buffer)) != -1) {
messageDigest.update(buffer, 0, read)
}
}
return messageDigest.digest().collect { String.format("%02x", it) }.join()
}