forked from roc-streaming/roc-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.gradle
40 lines (36 loc) · 1.17 KB
/
common.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
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.StandardCopyOption
def getTagVersion = {
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine "git", "describe", "--tags", "--match", "v*"
standardOutput = stdout
}
def tag = stdout.toString().trim()
return tag.substring(1)
} catch (exception) {
return "SNAPSHOT"
}
}
ext {
tagVersion = getTagVersion()
}
ext.copyNativeLibs = { start, target ->
Path startPath = Paths.get(start)
Path targetPath = Paths.get(target)
targetPath.toFile().mkdirs()
Files.walk(startPath).withCloseable { stream ->
stream
.filter({ path -> path.getFileName().toString().endsWith(".dylib") || path.getFileName().toString().endsWith(".so") })
.forEach({ path ->
try {
Files.copy(path, targetPath.resolve(path.getFileName()), StandardCopyOption.REPLACE_EXISTING)
} catch (IOException e) {
throw new RuntimeException(e);
}
});
}
}