diff options
author | Jake Petroules <jake.petroules@qt.io> | 2016-12-15 22:22:51 -0800 |
---|---|---|
committer | Jake Petroules <jake.petroules@qt.io> | 2016-12-19 21:05:24 +0000 |
commit | be2ce59cbb380e279771f88cd3c0d22c98a9b9cc (patch) | |
tree | 4384af7820e6d78dc9077502e13acc751bc785cd | |
parent | cbd58d2ff66f3b3ca6c9d6bb6b54b4865b7aecea (diff) |
Fix javaDependencyTracking autotest with Java 6 on Windows and Linux
Both rt.jar *and* tools.jar are part of classes.jar in Apple Java 6, not
only the former. tools.jar is present in all other versions of the JDK.
Change-Id: Ia045d17c768963fd454f0ed81d95940c4a33d2b7
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r-- | share/qbs/modules/java/JavaModule.qbs | 26 | ||||
-rw-r--r-- | share/qbs/modules/java/utils.js | 2 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata-java/java/vehicles.qbs | 16 |
3 files changed, 28 insertions, 16 deletions
diff --git a/share/qbs/modules/java/JavaModule.qbs b/share/qbs/modules/java/JavaModule.qbs index d1d92c835..147d7b003 100644 --- a/share/qbs/modules/java/JavaModule.qbs +++ b/share/qbs/modules/java/JavaModule.qbs @@ -105,8 +105,9 @@ Module { property pathList jdkIncludePaths: { var paths = []; - if (qbs.hostOS.contains("darwin") && compilerVersionMinor <= 6) { - paths.push("/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers"); + if (isAppleJava) { + paths.push(FileInfo.joinPaths(qbs.sysroot, + "/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers")); } else { paths.push(FileInfo.joinPaths(jdkPath, "include")); @@ -128,15 +129,28 @@ Module { property path classFilesDir: FileInfo.joinPaths(product.buildDirectory, "classes") property path internalClassFilesDir: FileInfo.joinPaths(product.buildDirectory, ".classes") - property path runtimeJarPath: { - if (qbs.hostOS.contains("macos") && compilerVersionMajor === 1 && compilerVersionMinor < 7) + property bool isAppleJava: qbs.hostOS.contains("darwin") + && (compilerVersionMajor < 1 + || (compilerVersionMajor === 1 && compilerVersionMinor < 7)) + + // https://developer.apple.com/library/content/documentation/Java/Conceptual/Java14Development/02-JavaDevTools/JavaDevTools.html + // tools.jar does not exist. Classes usually located here are instead included in classes.jar. + // The same is true for rt.jar, although not mentioned in the documentation + property path classesJarPath: { + if (isAppleJava) return FileInfo.joinPaths(jdkPath, "bundle", "Classes", "classes.jar"); + } + + property path runtimeJarPath: { + if (classesJarPath) + return classesJarPath; return FileInfo.joinPaths(jdkPath, "jre", "lib", "rt.jar"); } property path toolsJarPath: { - if (compilerVersionMajor > 1 || (compilerVersionMajor === 1 && compilerVersionMinor >= 7)) - return FileInfo.joinPaths(jdkPath, "lib", "tools.jar"); + if (classesJarPath) + return classesJarPath; + return FileInfo.joinPaths(jdkPath, "lib", "tools.jar"); } validate: { diff --git a/share/qbs/modules/java/utils.js b/share/qbs/modules/java/utils.js index aebe9c617..26b31a055 100644 --- a/share/qbs/modules/java/utils.js +++ b/share/qbs/modules/java/utils.js @@ -266,7 +266,7 @@ function helperOverrideArgs(product, tool) { // Build the helper tool's class files separately from the actual product's class files overrides["classFilesDir"] = ModUtils.moduleProperty(product, "internalClassFilesDir"); - // Add tools.jar to the classpath as required for the tree scanner API on JDK 7+ + // Add tools.jar to the classpath as required for the tree scanner API var toolsJarPath = ModUtils.moduleProperty(product, "toolsJarPath"); if (toolsJarPath) overrides["additionalClassPaths"] = [toolsJarPath].concat( diff --git a/tests/auto/blackbox/testdata-java/java/vehicles.qbs b/tests/auto/blackbox/testdata-java/java/vehicles.qbs index 78c092174..0a8c4a62e 100644 --- a/tests/auto/blackbox/testdata-java/java/vehicles.qbs +++ b/tests/auto/blackbox/testdata-java/java/vehicles.qbs @@ -60,17 +60,15 @@ Project { files: ["Car8.java"] } - property stringList cppIncludePaths: { - var paths = java.jdkIncludePaths; - if (java.compilerVersionMinor >= 8) { - paths.push(buildDirectory); // generated JNI headers - } - return paths; - } - Export { Depends { name: "cpp" } - cpp.systemIncludePaths: product.cppIncludePaths + cpp.systemIncludePaths: { + var paths = importingProduct.java.jdkIncludePaths; + if (importingProduct.java.compilerVersionMinor >= 8) { + paths.push(product.buildDirectory); // generated JNI headers + } + return paths; + } Depends { name: "java" } java.manifestClassPath: [product.targetName + ".jar"] |