Skip to content

Instantly share code, notes, and snippets.

@PeterFeicht
Created June 8, 2016 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PeterFeicht/58824b4db02857f40772ddccd07b785d to your computer and use it in GitHub Desktop.
Save PeterFeicht/58824b4db02857f40772ddccd07b785d to your computer and use it in GitHub Desktop.
Missing method error in Gradle 2.14-rc-5 on Windows
import java.nio.file.Paths
import java.nio.file.Files
apply plugin: 'cpp'
model {
repositories {
libs(PrebuiltLibraries) {
jvm {
def path = findJdkIncludePath()?.toString()
if(path == null) {
def msg = "Could not find JDK include directory."
throw new ProjectConfigurationException(msg, null)
}
headers.srcDirs path, "$path/win32", "$path/linux", "$path/darwin"
}
}
}
components {
main(NativeLibrarySpec) {
sources {
cpp.lib library: "jvm", linkage: "api"
}
}
}
}
def findJdkIncludePath() {
def home = System.properties['user.home']
def path = Paths.get(home, ".java_home", "include")
if(Files.exists(path.resolve("jni.h"))) {
return path
}
def os = System.properties['os.name'].toLowerCase()
if(os.contains("win")) {
def programFilesJava = Paths.get(System.env['PROGRAMFILES'], "Java")
def javaVersion = System.properties['java.version']
return programFilesJava.resolve("jdk${javaVersion}", "include")
} else if(os.contains("nix") || os.contains("nux")) {
return Paths.get(System.properties['java.home'], "..", "include")
}
return null
}
// Alternate version that produces no error
/*
def findJdkIncludePath() {
def home = System.properties['user.home']
return Paths.get(home, ".java_home", "include")
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment