Skip to content

Commit

Permalink
Look for JDK using the setup-java env variable too
Browse files Browse the repository at this point in the history
  • Loading branch information
RedNesto committed Aug 13, 2024
1 parent 67896da commit 5ffeb75
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
java-version: |
11
17
21
- uses: actions/cache@v3
with:
path: |
Expand Down
8 changes: 6 additions & 2 deletions src/test/kotlin/framework/GradleImportTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import com.intellij.openapi.externalSystem.settings.ExternalProjectSettings
import com.intellij.openapi.module.Module
import com.intellij.openapi.project.modules
import com.intellij.openapi.projectRoots.JavaSdk
import com.intellij.openapi.projectRoots.JavaSdkVersion
import com.intellij.openapi.projectRoots.ProjectJdkTable
import com.intellij.openapi.projectRoots.ex.JavaSdkUtil
import com.intellij.openapi.roots.ProjectRootManager
Expand Down Expand Up @@ -71,10 +72,13 @@ abstract class BaseGradleImportTest : ExternalSystemImportingTestCase() {
super.setUp()

runWriteTask {
val jdk21Home = System.getenv("JDK_21_0") ?: System.getenv("JDK_21") ?: System.getenv("JDK21")
val envNames = setOf("JDK_21_0", "JDK_21", "JDK21", "JAVA_HOME_21_x64")
val jdk21Home = envNames.firstNotNullOfOrNull(System::getenv)
assertNotNull("Could not find JDK 21 home", jdk21Home)

val jdk = JavaSdk.getInstance().createJdk("JDK 21", jdk21Home, false)
val jdk = JavaSdk.getInstance().createJdk("JDK 21", jdk21Home!!, false)
assertEquals(JavaSdkVersion.JDK_21, JavaSdk.getInstance().getVersion(jdk))

ProjectJdkTable.getInstance().addJdk(jdk)
JavaSdkUtil.applyJdkToProject(myProject, jdk)
}
Expand Down

0 comments on commit 5ffeb75

Please sign in to comment.