Skip to content

Commit

Permalink
Revert "Compare bin subdirs of java home on root mismatch [fix 187] (#…
Browse files Browse the repository at this point in the history
…240)" (#241)

This reverts commit f2c6242.
  • Loading branch information
runningcode authored Jan 18, 2023
1 parent 9a4191a commit 6c114d8
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions doctor-plugin/src/main/java/com/osacky/doctor/JavaHomeCheck.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class JavaHomeCheck(
if (extension.javaHomeHandler.ensureJavaHomeMatches.get() && !isGradleUsingJavaHome()) {
val message = buildString {
appendln("Gradle is not using JAVA_HOME.")
appendln("JAVA_HOME is ${environmentJavaHome?.toFile()?.toPath()?.toRealPath()}")
appendln("Gradle is using ${gradleJavaHome.toPath().toRealPath()}")
appendln("JAVA_HOME is ${environmentJavaHome?.toFile()?.toPath()?.toAbsolutePath()}")
appendln("Gradle is using ${gradleJavaHome.toPath().toAbsolutePath()}")
appendln("This can slow down your build significantly when switching from Android Studio to the terminal.")
appendln("To fix: Project Structure -> JDK Location.")
appendln("Set this to your JAVA_HOME.")
Expand All @@ -66,12 +66,8 @@ class JavaHomeCheck(

private fun isGradleUsingJavaHome(): Boolean {
// Follow symlinks when checking that java home matches.
if (environmentJavaHome != null) {
val gradleJavaHomePath = gradleJavaHome.toPath()
val environmentJavaHomePath = File(environmentJavaHome).toPath()
if (gradleJavaHomePath.toRealPath() != environmentJavaHomePath.toRealPath()) {
return gradleJavaHomePath.toRealPath().resolve("bin") == environmentJavaHomePath.resolve("bin").toRealPath()
}
if (environmentJavaHome != null && gradleJavaHome.toPath().toRealPath() == File(environmentJavaHome).toPath().toRealPath()) {
return true
}
return false
}
Expand Down

0 comments on commit 6c114d8

Please sign in to comment.