Build: Use preprocessed tools.jar for compilation

tools.jar from JDK has different public api on different platforms which
makes impossible to reuse caches for tasks which depend on it. Since we
can't compile against those classes & stay cross-platform anyway, we
may just exclude them from compile classpath. This should make tools.jar
compatible at least within one build of JDK for different platforms
This commit is contained in:
Vyacheslav Gerasimov
2020-02-19 20:06:32 +03:00
parent 8fbd22ff73
commit ef169aa12b
10 changed files with 57 additions and 11 deletions
+44
View File
@@ -0,0 +1,44 @@
plugins {
base
}
val JDK_18: String by rootProject.extra
val toolsJarFile = toolsJarFile(jdkHome = File(JDK_18)) ?: error("Couldn't find tools.jar in $JDK_18")
// tools.jar from JDK has different public api on different platforms which makes impossible to reuse caches
// for tasks which depend on it. Since we can't compile against those classes & stay cross-platform anyway,
// we may just exclude them from compile classpath. This should make tools.jar compatible at least within
// one build of JDK for different platforms
val jar = tasks.register<Jar>("jar") {
from {
zipTree(toolsJarFile).matching {
exclude("META-INF/**")
exclude("sun/tools/attach/LinuxAttachProvider.class")
exclude("sun/tools/attach/LinuxVirtualMachine${'$'}SocketInputStream.class")
exclude("sun/tools/attach/LinuxVirtualMachine.class")
exclude("sun/tools/attach/BsdAttachProvider.class")
exclude("sun/tools/attach/BsdVirtualMachine${'$'}SocketInputStream.class")
exclude("sun/tools/attach/BsdVirtualMachine.class")
exclude("sun/tools/attach/WindowsAttachProvider.class")
exclude("sun/tools/attach/WindowsVirtualMachine${'$'}SocketInputStream.class")
exclude("sun/tools/attach/WindowsVirtualMachine.class")
// Windows only classes
exclude("com/sun/tools/jdi/SharedMemoryAttachingConnector$1.class")
exclude("com/sun/tools/jdi/SharedMemoryAttachingConnector.class")
exclude("com/sun/tools/jdi/SharedMemoryConnection.class")
exclude("com/sun/tools/jdi/SharedMemoryListeningConnector$1.class")
exclude("com/sun/tools/jdi/SharedMemoryListeningConnector.class")
exclude("com/sun/tools/jdi/SharedMemoryTransportService${'$'}SharedMemoryListenKey.class")
exclude("com/sun/tools/jdi/SharedMemoryTransportService.class")
exclude("com/sun/tools/jdi/SharedMemoryTransportServiceCapabilities.class")
exclude("com/sun/tools/jdi/SunSDK.class")
}
}
}
artifacts.add("default", jar)