Created
June 8, 2016 17:05
-
-
Save PeterFeicht/58824b4db02857f40772ddccd07b785d to your computer and use it in GitHub Desktop.
Missing method error in Gradle 2.14-rc-5 on Windows
This file contains 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
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