mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 06:50:54 +07:00
[android] (Koala) Merge AS 2024.1.1 Canary 8. KotlinGradleImportingTestCase: Use JDK_17_0 for import tests
GitOrigin-RevId: ae7a3b5d62c8706b185da6586956c4f3f80481db
This commit is contained in:
committed by
intellij-monorepo-bot
parent
cc1a4070f8
commit
8e4054c576
@@ -73,10 +73,23 @@ abstract class KotlinGradleImportingTestCase : GradleImportingTestCase(),
|
||||
protected val importStatusCollector = ImportStatusCollector()
|
||||
|
||||
override fun findJdkPath(): String {
|
||||
return System.getenv("JDK_11") ?: System.getenv("JAVA11_HOME") ?: run {
|
||||
val message = "Missing JDK_11 or JAVA11_HOME environment variable"
|
||||
if (IS_UNDER_TEAMCITY) LOG.error(message) else LOG.warn(message)
|
||||
super.findJdkPath()
|
||||
/*
|
||||
https://docs.gradle.org/current/userguide/compatibility.html
|
||||
*/
|
||||
return if (currentGradleVersion >= GradleVersion.version("7.3")) {
|
||||
/* Version 7.3 or higher supports JDK_17 */
|
||||
System.getenv("JDK_17_0") ?: System.getenv("JDK_17") ?: System.getenv("JAVA17_HOME") ?: run {
|
||||
val message = "Missing JDK_17_0 or JAVA17_HOME environment variable"
|
||||
if (IS_UNDER_TEAMCITY) LOG.error(message) else LOG.warn(message)
|
||||
super.findJdkPath()
|
||||
}
|
||||
} else {
|
||||
/* Versions below 7.3 shall run with JDK 11 (supported since Gradle 5) */
|
||||
System.getenv("JDK_11") ?: System.getenv("JAVA11_HOME") ?: run {
|
||||
val message = "Missing JDK_11 or JAVA11_HOME environment variable"
|
||||
if (IS_UNDER_TEAMCITY) LOG.error(message) else LOG.warn(message)
|
||||
super.findJdkPath()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,9 +185,11 @@ abstract class KotlinGradleImportingTestCase : GradleImportingTestCase(),
|
||||
}
|
||||
.forEach {
|
||||
if (it.name == GradleConstants.SETTINGS_FILE_NAME &&
|
||||
!File(testDataDirectory(), GradleConstants.SETTINGS_FILE_NAME + AFTER_SUFFIX).exists()) return@forEach
|
||||
!File(testDataDirectory(), GradleConstants.SETTINGS_FILE_NAME + AFTER_SUFFIX).exists()
|
||||
) return@forEach
|
||||
if (it.name == GradleConstants.KOTLIN_DSL_SETTINGS_FILE_NAME &&
|
||||
!File(testDataDirectory(), GradleConstants.KOTLIN_DSL_SETTINGS_FILE_NAME + AFTER_SUFFIX).exists()) return@forEach
|
||||
!File(testDataDirectory(), GradleConstants.KOTLIN_DSL_SETTINGS_FILE_NAME + AFTER_SUFFIX).exists()
|
||||
) return@forEach
|
||||
|
||||
val actualText = configureKotlinVersionAndProperties(LoadTextUtil.loadText(it).toString(), properties)
|
||||
val expectedFileName = if (File(testDataDirectory(), it.name + ".$gradleVersion" + AFTER_SUFFIX).exists()) {
|
||||
@@ -190,7 +205,11 @@ abstract class KotlinGradleImportingTestCase : GradleImportingTestCase(),
|
||||
/**
|
||||
* Compares expected (with ".after" postfix) and actual files with directory traversal.
|
||||
*/
|
||||
protected fun checkFilesInMultimoduleProject(files: List<VirtualFile>, subModules: List<String>, properties: Map<String, String>? = null) {
|
||||
protected fun checkFilesInMultimoduleProject(
|
||||
files: List<VirtualFile>,
|
||||
subModules: List<String>,
|
||||
properties: Map<String, String>? = null
|
||||
) {
|
||||
FileDocumentManager.getInstance().saveAllDocuments()
|
||||
|
||||
files.filter {
|
||||
@@ -201,24 +220,31 @@ abstract class KotlinGradleImportingTestCase : GradleImportingTestCase(),
|
||||
}
|
||||
.forEach {
|
||||
if (it.name == GradleConstants.SETTINGS_FILE_NAME &&
|
||||
!File(testDataDirectory(), GradleConstants.SETTINGS_FILE_NAME + AFTER_SUFFIX).exists()) return@forEach
|
||||
!File(testDataDirectory(), GradleConstants.SETTINGS_FILE_NAME + AFTER_SUFFIX).exists()
|
||||
) return@forEach
|
||||
if (it.name == GradleConstants.KOTLIN_DSL_SETTINGS_FILE_NAME &&
|
||||
!File(testDataDirectory(), GradleConstants.KOTLIN_DSL_SETTINGS_FILE_NAME + AFTER_SUFFIX).exists()) return@forEach
|
||||
!File(testDataDirectory(), GradleConstants.KOTLIN_DSL_SETTINGS_FILE_NAME + AFTER_SUFFIX).exists()
|
||||
) return@forEach
|
||||
|
||||
val actualText = configureKotlinVersionAndProperties(LoadTextUtil.loadText(it).toString(), properties)
|
||||
var moduleForBuildScript = ""
|
||||
for (module in subModules) {
|
||||
if(it.path.substringBefore("/" + it.name).endsWith(module)) {
|
||||
if (it.path.substringBefore("/" + it.name).endsWith(module)) {
|
||||
moduleForBuildScript = module
|
||||
break
|
||||
}
|
||||
}
|
||||
val expectedFileName = if (File(File(testDataDirectory(), moduleForBuildScript), it.name + ".$gradleVersion" + AFTER_SUFFIX).exists()) {
|
||||
it.name + ".$gradleVersion" + AFTER_SUFFIX
|
||||
} else {
|
||||
it.name + AFTER_SUFFIX
|
||||
}
|
||||
val expectedFile = File(testDataDirectory(), if (moduleForBuildScript.isNotEmpty()) {"$moduleForBuildScript/$expectedFileName"} else expectedFileName)
|
||||
val expectedFileName =
|
||||
if (File(File(testDataDirectory(), moduleForBuildScript), it.name + ".$gradleVersion" + AFTER_SUFFIX).exists()) {
|
||||
it.name + ".$gradleVersion" + AFTER_SUFFIX
|
||||
} else {
|
||||
it.name + AFTER_SUFFIX
|
||||
}
|
||||
val expectedFile = File(
|
||||
testDataDirectory(), if (moduleForBuildScript.isNotEmpty()) {
|
||||
"$moduleForBuildScript/$expectedFileName"
|
||||
} else expectedFileName
|
||||
)
|
||||
KotlinTestUtils.assertEqualsToFile(expectedFile, actualText) { s -> configureKotlinVersionAndProperties(s, properties) }
|
||||
}
|
||||
}
|
||||
@@ -241,7 +267,13 @@ abstract class KotlinGradleImportingTestCase : GradleImportingTestCase(),
|
||||
clazz: KClass<T>,
|
||||
debuggerOptions: BuildGradleModelDebuggerOptions? = null
|
||||
): BuiltGradleModel<T> =
|
||||
buildGradleModel(myProjectRoot.toNioPath().toFile(), GradleVersion.version(gradleVersion), findJdkPath(), clazz, debuggerOptions)
|
||||
buildGradleModel(
|
||||
myProjectRoot.toNioPath().toFile(),
|
||||
GradleVersion.version(gradleVersion),
|
||||
findJdkPath(),
|
||||
clazz,
|
||||
debuggerOptions
|
||||
)
|
||||
|
||||
protected fun buildKotlinMPPGradleModel(
|
||||
debuggerOptions: BuildGradleModelDebuggerOptions? = null
|
||||
@@ -334,16 +366,17 @@ abstract class KotlinGradleImportingTestCase : GradleImportingTestCase(),
|
||||
settings.externalSystemIdString = GradleConstants.SYSTEM_ID.id
|
||||
|
||||
val future = CompletableFuture<String>()
|
||||
ExternalSystemUtil.runTask(settings, DefaultRunExecutor.EXECUTOR_ID, myProject, GradleConstants.SYSTEM_ID,
|
||||
object : TaskCallback {
|
||||
override fun onSuccess() {
|
||||
future.complete(taskErrOutput.toString())
|
||||
}
|
||||
ExternalSystemUtil.runTask(
|
||||
settings, DefaultRunExecutor.EXECUTOR_ID, myProject, GradleConstants.SYSTEM_ID,
|
||||
object : TaskCallback {
|
||||
override fun onSuccess() {
|
||||
future.complete(taskErrOutput.toString())
|
||||
}
|
||||
|
||||
override fun onFailure() {
|
||||
future.complete(taskErrOutput.toString())
|
||||
}
|
||||
}, ProgressExecutionMode.IN_BACKGROUND_ASYNC
|
||||
override fun onFailure() {
|
||||
future.complete(taskErrOutput.toString())
|
||||
}
|
||||
}, ProgressExecutionMode.IN_BACKGROUND_ASYNC
|
||||
)
|
||||
return future.get(10, TimeUnit.SECONDS)
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user