Build: Fix usages of "java.home" for tools.jar dependency

#KT-33984
This commit is contained in:
Vyacheslav Gerasimov
2019-09-24 15:34:20 +03:00
parent eae6fbad3a
commit c1e1dbd83e
13 changed files with 17 additions and 14 deletions

View File

@@ -8,6 +8,7 @@ import org.gradle.api.Project
import org.gradle.api.artifacts.ProjectDependency import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.artifacts.dsl.DependencyHandler import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.api.file.ConfigurableFileCollection import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.FileCollection
import org.gradle.api.tasks.AbstractCopyTask import org.gradle.api.tasks.AbstractCopyTask
import org.gradle.kotlin.dsl.extra import org.gradle.kotlin.dsl.extra
import org.gradle.kotlin.dsl.project import org.gradle.kotlin.dsl.project
@@ -128,7 +129,9 @@ fun Project.firstFromJavaHomeThatExists(vararg paths: String, jdkHome: File = Fi
logger.warn("Cannot find file by paths: ${paths.toList()} in $jdkHome") logger.warn("Cannot find file by paths: ${paths.toList()} in $jdkHome")
} }
fun Project.toolsJar(jdkHome: File = File(this.property("JDK_18") as String)): File? = fun Project.toolsJar(): FileCollection = files(toolsJarFile() ?: error("tools.jar is not found!"))
fun Project.toolsJarFile(jdkHome: File = File(this.property("JDK_18") as String)): File? =
firstFromJavaHomeThatExists("lib/tools.jar", jdkHome = jdkHome) firstFromJavaHomeThatExists("lib/tools.jar", jdkHome = jdkHome)
val compilerManifestClassPath val compilerManifestClassPath

View File

@@ -85,10 +85,10 @@ dependencies {
} }
testRuntime(androidDxJar()) testRuntime(androidDxJar())
testRuntime(files(toolsJar())) testRuntime(toolsJar())
antLauncherJar(commonDep("org.apache.ant", "ant")) antLauncherJar(commonDep("org.apache.ant", "ant"))
antLauncherJar(files(toolsJar())) antLauncherJar(toolsJar())
} }
sourceSets { sourceSets {

View File

@@ -24,7 +24,7 @@ dependencies {
compile(project(":compiler:fir:resolve")) compile(project(":compiler:fir:resolve"))
compile(project(":compiler:fir:java")) compile(project(":compiler:fir:java"))
compile(project(":compiler:fir:fir2ir")) compile(project(":compiler:fir:fir2ir"))
compile(files("${System.getProperty("java.home")}/../lib/tools.jar")) compile(toolsJar())
compileOnly(intellijCoreDep()) { includeJars("intellij-core") } compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
compileOnly(intellijDep()) { includeIntellijCoreJarDependencies(project) } compileOnly(intellijDep()) { includeIntellijCoreJarDependencies(project) }

View File

@@ -12,7 +12,7 @@ dependencies {
runtimeOnly(intellijDep()) runtimeOnly(intellijDep())
runtimeOnly(intellijRuntimeAnnotations()) runtimeOnly(intellijRuntimeAnnotations())
runtimeOnly(files(toolsJar())) runtimeOnly(toolsJar())
} }
val ideaPluginDir: File by rootProject.extra val ideaPluginDir: File by rootProject.extra

View File

@@ -6,7 +6,7 @@ plugins {
dependencies { dependencies {
compile(kotlinStdlib()) compile(kotlinStdlib())
compile(project(":compiler:backend")) compile(project(":compiler:backend"))
compile(files(toolsJar())) compile(toolsJar())
compileOnly(intellijCoreDep()) { includeJars("intellij-core", "asm-all", rootProject = rootProject) } compileOnly(intellijCoreDep()) { includeJars("intellij-core", "asm-all", rootProject = rootProject) }
testCompile(project(":kotlin-test:kotlin-test-junit")) testCompile(project(":kotlin-test:kotlin-test-junit"))
testCompile(commonDep("junit:junit")) testCompile(commonDep("junit:junit"))

View File

@@ -10,7 +10,7 @@ dependencies {
compile(project(":idea:idea-core")) compile(project(":idea:idea-core"))
compile(project(":idea:ide-common")) compile(project(":idea:ide-common"))
compile(project(":idea:jvm-debugger:jvm-debugger-util")) compile(project(":idea:jvm-debugger:jvm-debugger-util"))
compile(files("${System.getProperty("java.home")}/../lib/tools.jar")) compile(toolsJar())
compileOnly(intellijDep()) compileOnly(intellijDep())

View File

@@ -9,7 +9,7 @@ dependencies {
compile(project(":idea:idea-core")) compile(project(":idea:idea-core"))
compile(project(":idea:idea-j2k")) compile(project(":idea:idea-j2k"))
compile(project(":idea:jvm-debugger:jvm-debugger-util")) compile(project(":idea:jvm-debugger:jvm-debugger-util"))
compile(files("${System.getProperty("java.home")}/../lib/tools.jar")) compile(toolsJar())
Platform[192].orHigher { Platform[192].orHigher {
compileOnly(intellijPluginDep("java")) compileOnly(intellijPluginDep("java"))
} }

View File

@@ -6,7 +6,7 @@ plugins {
dependencies { dependencies {
compile(project(":compiler:backend")) compile(project(":compiler:backend"))
compile(project(":idea:ide-common")) compile(project(":idea:ide-common"))
compile(files("${System.getProperty("java.home")}/../lib/tools.jar")) compile(toolsJar())
compileOnly(intellijDep()) compileOnly(intellijDep())
Platform[192].orHigher { Platform[192].orHigher {

View File

@@ -11,7 +11,7 @@ dependencies {
// TODO: get rid of this // TODO: get rid of this
compile(project(":idea:jvm-debugger:eval4j")) compile(project(":idea:jvm-debugger:eval4j"))
compile(files("${System.getProperty("java.home")}/../lib/tools.jar")) compile(toolsJar())
Platform[192].orHigher { Platform[192].orHigher {
compileOnly(intellijPluginDep("java")) compileOnly(intellijPluginDep("java"))

View File

@@ -60,7 +60,7 @@ dependencies {
} }
antLauncherJar(commonDep("org.apache.ant", "ant")) antLauncherJar(commonDep("org.apache.ant", "ant"))
antLauncherJar(files(toolsJar())) antLauncherJar(toolsJar())
} }
sourceSets { sourceSets {

View File

@@ -31,7 +31,7 @@ dependencies {
embedded(commonDep("org.jetbrains.kotlinx", "kotlinx-coroutines-core")) { isTransitive = false } embedded(commonDep("org.jetbrains.kotlinx", "kotlinx-coroutines-core")) { isTransitive = false }
proguardLibraryJars(files(firstFromJavaHomeThatExists("jre/lib/rt.jar", "../Classes/classes.jar"), proguardLibraryJars(files(firstFromJavaHomeThatExists("jre/lib/rt.jar", "../Classes/classes.jar"),
firstFromJavaHomeThatExists("jre/lib/jsse.jar", "../Classes/jsse.jar"), firstFromJavaHomeThatExists("jre/lib/jsse.jar", "../Classes/jsse.jar"),
toolsJar())) toolsJarFile()))
proguardLibraryJars(kotlinStdlib()) proguardLibraryJars(kotlinStdlib())
proguardLibraryJars(project(":kotlin-reflect")) proguardLibraryJars(project(":kotlin-reflect"))
proguardLibraryJars(project(":kotlin-compiler")) proguardLibraryJars(project(":kotlin-compiler"))

View File

@@ -5,7 +5,7 @@ plugins {
dependencies { dependencies {
compile(kotlinStdlib()) compile(kotlinStdlib())
compile(files("${System.getProperty("java.home")}/../lib/tools.jar")) compile(toolsJar())
testCompile(commonDep("junit:junit")) testCompile(commonDep("junit:junit"))
} }

View File

@@ -133,7 +133,7 @@ dependencies {
files( files(
firstFromJavaHomeThatExists("jre/lib/rt.jar", "../Classes/classes.jar"), firstFromJavaHomeThatExists("jre/lib/rt.jar", "../Classes/classes.jar"),
firstFromJavaHomeThatExists("jre/lib/jsse.jar", "../Classes/jsse.jar"), firstFromJavaHomeThatExists("jre/lib/jsse.jar", "../Classes/jsse.jar"),
toolsJar() toolsJarFile()
) )
) )