Created
November 1, 2014 03:40
-
-
Save Unh0lyTigg/ea826cb59f184c3a0f4c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def findNativeName() { | |
final String osNameStr = System.properties['os.name'] | |
return [ | |
'linux': { | |
osNameStr ==~ /(?i)linux.*/ | |
}, | |
'windows': { | |
osNameStr ==~ /(?i)windows.*/ | |
}, | |
'osx': { | |
osNameStr ==~ /(?i)os.?x.*/ | |
}, | |
].find({k, v -> v()}).key | |
} | |
def listNativeDeps(nativeName) { | |
return configurations.runtime.findAll { | |
final String filename = it.name | |
filename.contains(nativeName) | |
} | |
} | |
def unpackNativeDeps(dstDir) { | |
final String nativeName = 'natives-' + findNativeName() | |
println("nativeName = " + nativeName) | |
final Collection deps = listNativeDeps(nativeName) | |
println("nativeDeps = " + deps) | |
// make-dir | |
if(new File(dstDir).exists()){ | |
println("skip unpackNatives -- dstDir exists = " + dstDir) | |
}else{ | |
ant.mkdir(dir: dstDir) | |
deps.each { | |
println("unpack-native-deps to " + dstDir + " <-- " + it.name) | |
ant.unzip(src: it.absolutePath, dest: dstDir) | |
} | |
} | |
} | |
project.ext.nativesDir = project.buildDir.absolutePath + "\\natives" | |
println "nativesDir: " + project.ext.nativesDir | |
task unpackNatives << { | |
println "task :unpackNatives" | |
unpackNativeDeps(project.ext.nativesDir) | |
} | |
run.dependsOn ':unpackNatives' | |
run { | |
final String javaLibraryPathOpt = String.format("-Djava.library.path=%s", project.ext.nativesDir) | |
println("jvmArgs java.library.path = " + javaLibraryPathOpt) | |
jvmArgs = [javaLibraryPathOpt] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment