|
|
@ -14,6 +14,8 @@ import org.gradle.api.tasks.TaskContainer |
|
|
|
import org.gradle.api.tasks.TaskProvider |
|
|
|
import org.gradle.api.tasks.TaskProvider |
|
|
|
import org.gradle.api.tasks.bundling.Jar |
|
|
|
import org.gradle.api.tasks.bundling.Jar |
|
|
|
import org.gradle.api.tasks.testing.Test |
|
|
|
import org.gradle.api.tasks.testing.Test |
|
|
|
|
|
|
|
import org.gradle.jvm.toolchain.JavaLanguageVersion |
|
|
|
|
|
|
|
import org.gradle.jvm.toolchain.JavaToolchainService |
|
|
|
import org.gradle.kotlin.dsl.dependencies |
|
|
|
import org.gradle.kotlin.dsl.dependencies |
|
|
|
import org.gradle.kotlin.dsl.register |
|
|
|
import org.gradle.kotlin.dsl.register |
|
|
|
import org.gradle.kotlin.dsl.withType |
|
|
|
import org.gradle.kotlin.dsl.withType |
|
|
@ -24,22 +26,13 @@ inline fun <reified T> Project.configureIfExists(fn: T.() -> Unit) { |
|
|
|
extensions.findByType(T::class.java)?.fn() |
|
|
|
extensions.findByType(T::class.java)?.fn() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val javaHomeForTests: String? = when { |
|
|
|
|
|
|
|
// __COMPOSE_NATIVE_DISTRIBUTIONS_MIN_JAVA_VERSION__ |
|
|
|
|
|
|
|
JavaVersion.current() >= JavaVersion.VERSION_15 -> System.getProperty("java.home") |
|
|
|
|
|
|
|
else -> System.getenv("JDK_15") |
|
|
|
|
|
|
|
?: System.getenv("JDK_FOR_GRADLE_TESTS") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val isWindows = DefaultNativePlatform.getCurrentOperatingSystem().isWindows |
|
|
|
val isWindows = DefaultNativePlatform.getCurrentOperatingSystem().isWindows |
|
|
|
|
|
|
|
|
|
|
|
fun Test.configureJavaForComposeTest() { |
|
|
|
fun Test.configureJavaForComposeTest() { |
|
|
|
if (javaHomeForTests != null) { |
|
|
|
val toolchains = project.extensions.getByName("javaToolchains") as JavaToolchainService |
|
|
|
val executableFileName = if (isWindows) "java.exe" else "java" |
|
|
|
javaLauncher.set(toolchains.launcherFor { |
|
|
|
executable = File(javaHomeForTests).resolve("bin/$executableFileName").absolutePath |
|
|
|
languageVersion.set(JavaLanguageVersion.of(16)) |
|
|
|
} else { |
|
|
|
}) |
|
|
|
doFirst { error("Use JDK 15+ to run tests or set up JDK_15/JDK_FOR_GRADLE_TESTS env. var") } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun Project.configureAllTests(fn: Test.() -> Unit = {}) { |
|
|
|
fun Project.configureAllTests(fn: Test.() -> Unit = {}) { |
|
|
|