[Gradle] Fixed downloading konan when .konan/klib exists
^KT-65222 Fixed ^KT-65248 Verification Pending Merge-request: KT-MR-14048 Merged-by: Dmitrii Krasnov <Dmitrii.Krasnov@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
d1664c6791
commit
6e763f5c41
+22
@@ -79,6 +79,28 @@ class KotlinNativeCompilerDownloadIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("KT-65222: Kotlin Native must be downloaded during even if klib dir exists")
|
||||
@GradleTest
|
||||
fun shouldDownloadKotlinNativeWithExistingKlibDir(gradleVersion: GradleVersion, @TempDir konanTemp: Path) {
|
||||
nativeProject(
|
||||
"native-simple-project",
|
||||
gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copy(
|
||||
konanDataDir = konanTemp,
|
||||
),
|
||||
) {
|
||||
build(":commonizeNativeDistribution") {
|
||||
assertDirectoryExists(konanTemp.resolve(STABLE_VERSION_DIR_NAME).resolve("klib"))
|
||||
assertDirectoryDoesNotExist(konanTemp.resolve(STABLE_VERSION_DIR_NAME).resolve("bin"))
|
||||
}
|
||||
build("assemble") {
|
||||
assertOutputDoesNotContain(DOWNLOAD_KONAN_FINISHED_LOG)
|
||||
assertOutputContains(UNPUCK_KONAN_FINISHED_LOG)
|
||||
assertOutputDoesNotContain("Please wait while Kotlin/Native")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("KT-58303: Downloading Kotlin Native on configuration phase(deprecated version)")
|
||||
@GradleTest
|
||||
fun shouldDownloadKotlinNativeOnConfigurationPhaseWithToolchainDisabled(gradleVersion: GradleVersion, @TempDir konanTemp: Path) {
|
||||
|
||||
+14
-14
@@ -46,20 +46,11 @@ internal class KotlinNativeProvider(project: Project, konanTarget: KonanTarget)
|
||||
@get:Input
|
||||
internal val kotlinNativeBundleVersion: Provider<String> = bundleDirectory.zip(reinstallBundle) { bundleDir, reinstallFlag ->
|
||||
val kotlinNativeVersion = NativeCompilerDownloader.getDependencyNameWithOsAndVersion(project)
|
||||
if (project.kotlinNativeToolchainEnabled && (reinstallFlag || !bundleDir.asFile.exists())) {
|
||||
val kotlinNativeCompilerExtractedFolder =
|
||||
kotlinNativeCompilerConfiguration
|
||||
.singleOrNull()
|
||||
?.resolve(kotlinNativeVersion)
|
||||
?: error(
|
||||
"Kotlin Native dependency has not been properly resolved. " +
|
||||
"Please, make sure that you've declared the repository, which contains $kotlinNativeVersion."
|
||||
)
|
||||
|
||||
if (project.kotlinNativeToolchainEnabled) {
|
||||
project.prepareKotlinNativeBundle(
|
||||
kotlinNativeVersion,
|
||||
bundleDir.asFile,
|
||||
reinstallFlag,
|
||||
kotlinNativeCompilerExtractedFolder,
|
||||
konanTarget
|
||||
)
|
||||
}
|
||||
@@ -78,17 +69,26 @@ internal class KotlinNativeProvider(project: Project, konanTarget: KonanTarget)
|
||||
}
|
||||
|
||||
private fun Project.prepareKotlinNativeBundle(
|
||||
kotlinNativeVersion: String,
|
||||
bundleDir: File,
|
||||
reinstallFlag: Boolean,
|
||||
gradleCachesKotlinNativeDir: File,
|
||||
konanTarget: KonanTarget,
|
||||
) {
|
||||
|
||||
if (reinstallFlag) {
|
||||
NativeCompilerDownloader.getCompilerDirectory(project).deleteRecursively()
|
||||
bundleDir.deleteRecursively()
|
||||
}
|
||||
|
||||
if (!bundleDir.exists()) {
|
||||
if (!bundleDir.resolve("bin").exists()) {
|
||||
val gradleCachesKotlinNativeDir =
|
||||
kotlinNativeCompilerConfiguration
|
||||
.singleOrNull()
|
||||
?.resolve(kotlinNativeVersion)
|
||||
?: error(
|
||||
"Kotlin Native dependency has not been properly resolved. " +
|
||||
"Please, make sure that you've declared the repository, which contains $kotlinNativeVersion."
|
||||
)
|
||||
|
||||
logger.info("Moving Kotlin/Native bundle from tmp directory $gradleCachesKotlinNativeDir to ${bundleDir.absolutePath}")
|
||||
copy {
|
||||
it.from(gradleCachesKotlinNativeDir)
|
||||
|
||||
Reference in New Issue
Block a user