[Gradle, Native] Switched downloading k/n to from Maven Central in KGP
#KT-62907 Fixed
This commit is contained in:
committed by
Space Team
parent
c5d1c4e816
commit
f8507d5220
+6
@@ -275,6 +275,8 @@ abstract class BaseGradleIT {
|
|||||||
val showDiagnosticsStacktrace: Boolean? = false, // false by default to not clutter the testdata + stacktraces change often
|
val showDiagnosticsStacktrace: Boolean? = false, // false by default to not clutter the testdata + stacktraces change often
|
||||||
val stacktraceMode: String? = StacktraceOption.FULL_STACKTRACE_LONG_OPTION,
|
val stacktraceMode: String? = StacktraceOption.FULL_STACKTRACE_LONG_OPTION,
|
||||||
val konanDataDir: Path = konanDir,
|
val konanDataDir: Path = konanDir,
|
||||||
|
// TODO(Dmitrii Krasnov): we can remove this, when downloading konan from maven local will be possible KT-63198
|
||||||
|
val distributionDownloadFromMaven: Boolean? = false,
|
||||||
) {
|
) {
|
||||||
val safeAndroidGradlePluginVersion: AGPVersion
|
val safeAndroidGradlePluginVersion: AGPVersion
|
||||||
get() = androidGradlePluginVersion ?: error("AGP version is expected to be set")
|
get() = androidGradlePluginVersion ?: error("AGP version is expected to be set")
|
||||||
@@ -1004,6 +1006,10 @@ abstract class BaseGradleIT {
|
|||||||
|
|
||||||
add("-Pkonan.data.dir=${options.konanDataDir.absolutePathString().normalize()}")
|
add("-Pkonan.data.dir=${options.konanDataDir.absolutePathString().normalize()}")
|
||||||
|
|
||||||
|
options.distributionDownloadFromMaven?.let {
|
||||||
|
add("-Pkotlin.native.distribution.downloadFromMaven=${it}")
|
||||||
|
}
|
||||||
|
|
||||||
// Workaround: override a console type set in the user machine gradle.properties (since Gradle 4.3):
|
// Workaround: override a console type set in the user machine gradle.properties (since Gradle 4.3):
|
||||||
add("--console=plain")
|
add("--console=plain")
|
||||||
//The feature of failing the build on deprecation warnings is introduced in gradle 5.6
|
//The feature of failing the build on deprecation warnings is introduced in gradle 5.6
|
||||||
|
|||||||
+18
-34
@@ -810,45 +810,29 @@ class GeneralNativeIT : KGPBaseTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DisplayName("Checks builds with changing compiler version")
|
@DisplayName("Checks builds with changing compiler version")
|
||||||
@OptIn(EnvironmentalVariablesOverride::class)
|
@GradleTestVersions
|
||||||
@GradleTestVersions(minVersion = TestVersions.Gradle.G_7_0)
|
|
||||||
@GradleTest
|
@GradleTest
|
||||||
fun testCompilerVersionChange(gradleVersion: GradleVersion) {
|
fun testCompilerVersionChange(gradleVersion: GradleVersion) {
|
||||||
if (KotlinToolingVersion(TestVersions.Kotlin.STABLE_RELEASE) < KotlinToolingVersion("1.9.20-Beta")) {
|
nativeProject("native-compiler-version", gradleVersion) {
|
||||||
val konanDataDir = defaultBuildOptions.konanDataDir?.toAbsolutePath()?.normalize()?.absolutePathString()
|
val compileTasks = ":compileKotlinHost"
|
||||||
?: error("konanDataDir must not be null in this test. Please set a custom konanDataDir property.")
|
|
||||||
|
|
||||||
nativeProject(
|
build(compileTasks) {
|
||||||
"native-compiler-version",
|
assertTasksExecuted(compileTasks)
|
||||||
gradleVersion,
|
|
||||||
environmentVariables = EnvironmentalVariables(mapOf("KONAN_DATA_DIR" to konanDataDir)),
|
|
||||||
) {
|
|
||||||
val compileTasks = ":compileKotlinHost"
|
|
||||||
|
|
||||||
build(compileTasks) {
|
|
||||||
assertTasksExecuted(compileTasks)
|
|
||||||
}
|
|
||||||
|
|
||||||
build(compileTasks) {
|
|
||||||
assertTasksUpToDate(compileTasks)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check that changing K/N version lead to tasks rerun
|
|
||||||
build(
|
|
||||||
compileTasks, buildOptions = defaultBuildOptions.copy(
|
|
||||||
nativeOptions = defaultBuildOptions.nativeOptions.copy(version = TestVersions.Kotlin.STABLE_RELEASE)
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
assertTasksExecuted(compileTasks)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
fail(
|
|
||||||
"Please remove setting KONAN_DATA_DIR environment variable," +
|
|
||||||
" because Kotlin stable release now supports konan.data.dir Gradle property."
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
build(compileTasks) {
|
||||||
|
assertTasksUpToDate(compileTasks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that changing K/N version lead to tasks rerun
|
||||||
|
build(
|
||||||
|
compileTasks, buildOptions = defaultBuildOptions.copy(
|
||||||
|
nativeOptions = defaultBuildOptions.nativeOptions.copy(version = TestVersions.Kotlin.STABLE_RELEASE)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
assertTasksExecuted(compileTasks)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@DisplayName("Assert that a project with a native target can be configure")
|
@DisplayName("Assert that a project with a native target can be configure")
|
||||||
|
|||||||
+7
-40
@@ -9,15 +9,10 @@ import org.gradle.testkit.runner.BuildResult
|
|||||||
import org.gradle.util.GradleVersion
|
import org.gradle.util.GradleVersion
|
||||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinToolingDiagnostics
|
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinToolingDiagnostics
|
||||||
import org.jetbrains.kotlin.gradle.testbase.*
|
import org.jetbrains.kotlin.gradle.testbase.*
|
||||||
import org.jetbrains.kotlin.gradle.util.replaceFirst
|
|
||||||
import org.jetbrains.kotlin.gradle.utils.NativeCompilerDownloader
|
import org.jetbrains.kotlin.gradle.utils.NativeCompilerDownloader
|
||||||
import org.jetbrains.kotlin.konan.target.HostManager
|
import org.jetbrains.kotlin.konan.target.HostManager
|
||||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||||
import org.jetbrains.kotlin.konan.target.presetName
|
import org.jetbrains.kotlin.konan.target.presetName
|
||||||
import org.jetbrains.kotlin.tooling.core.KotlinToolingVersion
|
|
||||||
import org.jetbrains.kotlin.tooling.core.KotlinToolingVersion.Maturity.*
|
|
||||||
import org.jetbrains.kotlin.tooling.core.buildNumber
|
|
||||||
import org.junit.jupiter.api.Assumptions
|
|
||||||
import org.junit.jupiter.api.DisplayName
|
import org.junit.jupiter.api.DisplayName
|
||||||
import org.junit.jupiter.api.condition.OS
|
import org.junit.jupiter.api.condition.OS
|
||||||
import org.junit.jupiter.api.io.TempDir
|
import org.junit.jupiter.api.io.TempDir
|
||||||
@@ -34,11 +29,6 @@ import kotlin.io.path.appendText
|
|||||||
@NativeGradlePluginTests
|
@NativeGradlePluginTests
|
||||||
class NativeDownloadAndPlatformLibsIT : KGPBaseTest() {
|
class NativeDownloadAndPlatformLibsIT : KGPBaseTest() {
|
||||||
|
|
||||||
companion object {
|
|
||||||
private const val KOTLIN_SPACE_DEV = "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev"
|
|
||||||
private const val MAVEN_CENTRAL = "https://cache-redirector.jetbrains.com/maven-central"
|
|
||||||
}
|
|
||||||
|
|
||||||
private val platformName: String = HostManager.platformName()
|
private val platformName: String = HostManager.platformName()
|
||||||
private val currentCompilerVersion = NativeCompilerDownloader.DEFAULT_KONAN_VERSION
|
private val currentCompilerVersion = NativeCompilerDownloader.DEFAULT_KONAN_VERSION
|
||||||
|
|
||||||
@@ -215,20 +205,15 @@ class NativeDownloadAndPlatformLibsIT : KGPBaseTest() {
|
|||||||
@DisplayName("Download prebuilt Native bundle with maven")
|
@DisplayName("Download prebuilt Native bundle with maven")
|
||||||
@GradleTest
|
@GradleTest
|
||||||
fun shouldDownloadPrebuiltNativeBundleWithMaven(gradleVersion: GradleVersion) {
|
fun shouldDownloadPrebuiltNativeBundleWithMaven(gradleVersion: GradleVersion) {
|
||||||
val maven = mavenUrl()
|
|
||||||
Assumptions.assumeTrue(
|
|
||||||
maven != MAVEN_CENTRAL,
|
|
||||||
"Don't run this test for build that are not yet published to central.\n" +
|
|
||||||
" We won't public K/N into Maven central until this task is completed: KTI-1067"
|
|
||||||
)
|
|
||||||
|
|
||||||
nativeProject("native-download-maven", gradleVersion = gradleVersion) {
|
nativeProject("native-download-maven", gradleVersion = gradleVersion) {
|
||||||
|
|
||||||
buildGradleKts.replaceFirst("// <MavenPlaceholder>", "maven(\"${maven}\")")
|
|
||||||
|
|
||||||
build(
|
build(
|
||||||
"assemble",
|
"assemble",
|
||||||
buildOptions = defaultBuildOptions.copy(nativeOptions = defaultBuildOptions.nativeOptions.copy(distributionDownloadFromMaven = true))
|
buildOptions = defaultBuildOptions.copy(
|
||||||
|
nativeOptions = defaultBuildOptions.nativeOptions.copy(
|
||||||
|
version = TestVersions.Kotlin.STABLE_RELEASE,
|
||||||
|
)
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
assertOutputContains("Unpack Kotlin/Native compiler to ")
|
assertOutputContains("Unpack Kotlin/Native compiler to ")
|
||||||
assertOutputDoesNotContain("Generate platform libraries for ")
|
assertOutputDoesNotContain("Generate platform libraries for ")
|
||||||
@@ -240,22 +225,14 @@ class NativeDownloadAndPlatformLibsIT : KGPBaseTest() {
|
|||||||
@RequiredXCodeVersion(minSupportedMajor = 14, minSupportedMinor = 1)
|
@RequiredXCodeVersion(minSupportedMajor = 14, minSupportedMinor = 1)
|
||||||
@GradleTest
|
@GradleTest
|
||||||
fun shouldDownloadLightNativeBundleWithMaven(gradleVersion: GradleVersion) {
|
fun shouldDownloadLightNativeBundleWithMaven(gradleVersion: GradleVersion) {
|
||||||
val maven = mavenUrl()
|
|
||||||
Assumptions.assumeTrue(
|
|
||||||
maven != MAVEN_CENTRAL,
|
|
||||||
"Don't run this test for build that are not yet published to central.\n" +
|
|
||||||
" We won't public K/N into Maven central until this task is completed: KTI-1067"
|
|
||||||
)
|
|
||||||
|
|
||||||
nativeProject("native-download-maven", gradleVersion = gradleVersion) {
|
nativeProject("native-download-maven", gradleVersion = gradleVersion) {
|
||||||
buildGradleKts.replaceFirst("// <MavenPlaceholder>", "maven(\"${maven}\")")
|
|
||||||
val nativeOptions = defaultBuildOptions.nativeOptions.copy(
|
val nativeOptions = defaultBuildOptions.nativeOptions.copy(
|
||||||
distributionType = "light",
|
distributionType = "light",
|
||||||
distributionDownloadFromMaven = true
|
version = TestVersions.Kotlin.STABLE_RELEASE,
|
||||||
)
|
)
|
||||||
build(
|
build(
|
||||||
"assemble",
|
"assemble",
|
||||||
buildOptions = defaultBuildOptions.copy(nativeOptions = nativeOptions)
|
buildOptions = defaultBuildOptions.copy(nativeOptions = nativeOptions),
|
||||||
) {
|
) {
|
||||||
assertOutputContains("Unpack Kotlin/Native compiler to ")
|
assertOutputContains("Unpack Kotlin/Native compiler to ")
|
||||||
assertOutputContains("Generate platform libraries for ")
|
assertOutputContains("Generate platform libraries for ")
|
||||||
@@ -370,14 +347,4 @@ class NativeDownloadAndPlatformLibsIT : KGPBaseTest() {
|
|||||||
assertions = assertions
|
assertions = assertions
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun mavenUrl(): String {
|
|
||||||
val kotlinToolingVersion = KotlinToolingVersion(currentCompilerVersion)
|
|
||||||
val maturity = kotlinToolingVersion.maturity
|
|
||||||
val buildNumber = kotlinToolingVersion.buildNumber
|
|
||||||
return when {
|
|
||||||
maturity == DEV || buildNumber != null -> KOTLIN_SPACE_DEV
|
|
||||||
else -> MAVEN_CENTRAL
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -86,7 +86,8 @@ data class BuildOptions(
|
|||||||
val cocoapodsConfiguration: String? = null,
|
val cocoapodsConfiguration: String? = null,
|
||||||
val cocoapodsArchs: String? = null,
|
val cocoapodsArchs: String? = null,
|
||||||
val distributionType: String? = null,
|
val distributionType: String? = null,
|
||||||
val distributionDownloadFromMaven: Boolean? = null,
|
// TODO(Dmitrii Krasnov): we can change false on null, when downloading konan from maven local will be possible KT-63198
|
||||||
|
val distributionDownloadFromMaven: Boolean? = false,
|
||||||
val reinstall: Boolean? = null,
|
val reinstall: Boolean? = null,
|
||||||
val restrictedDistribution: Boolean? = null,
|
val restrictedDistribution: Boolean? = null,
|
||||||
val useXcodeMessageStyle: Boolean? = null,
|
val useXcodeMessageStyle: Boolean? = null,
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ interface TestVersions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
object Kotlin {
|
object Kotlin {
|
||||||
const val STABLE_RELEASE = "1.8.22"
|
const val STABLE_RELEASE = "1.9.20"
|
||||||
|
|
||||||
// Copied from KOTLIN_VERSION.kt file
|
// Copied from KOTLIN_VERSION.kt file
|
||||||
val CURRENT
|
val CURRENT
|
||||||
|
|||||||
-1
@@ -5,7 +5,6 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
// <MavenPlaceholder>
|
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -283,7 +283,7 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
|||||||
* Makes downloader search for bundles in maven repositories specified in the project.
|
* Makes downloader search for bundles in maven repositories specified in the project.
|
||||||
*/
|
*/
|
||||||
val nativeDownloadFromMaven: Boolean
|
val nativeDownloadFromMaven: Boolean
|
||||||
get() = this.booleanProperty("kotlin.native.distribution.downloadFromMaven") ?: false
|
get() = this.booleanProperty("kotlin.native.distribution.downloadFromMaven") ?: true
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows a user to provide a local Kotlin/Native distribution instead of a downloaded one.
|
* Allows a user to provide a local Kotlin/Native distribution instead of a downloaded one.
|
||||||
|
|||||||
+2
-2
@@ -133,7 +133,7 @@ class NativeCompilerDownloader(
|
|||||||
mapOf(
|
mapOf(
|
||||||
"group" to KOTLIN_GROUP_ID,
|
"group" to KOTLIN_GROUP_ID,
|
||||||
"name" to dependencyName,
|
"name" to dependencyName,
|
||||||
"version" to compilerVersion.toString(),
|
"version" to compilerVersion,
|
||||||
"classifier" to simpleOsName,
|
"classifier" to simpleOsName,
|
||||||
"ext" to archiveExtension
|
"ext" to archiveExtension
|
||||||
)
|
)
|
||||||
@@ -142,7 +142,7 @@ class NativeCompilerDownloader(
|
|||||||
project.dependencies.create(
|
project.dependencies.create(
|
||||||
mapOf(
|
mapOf(
|
||||||
"name" to "$dependencyName-$simpleOsName",
|
"name" to "$dependencyName-$simpleOsName",
|
||||||
"version" to compilerVersion.toString(),
|
"version" to compilerVersion,
|
||||||
"ext" to archiveExtension
|
"ext" to archiveExtension
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
+2
-2
@@ -14,8 +14,7 @@ import org.gradle.api.plugins.ExtraPropertiesExtension
|
|||||||
import org.gradle.testfixtures.ProjectBuilder
|
import org.gradle.testfixtures.ProjectBuilder
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||||
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper
|
import org.jetbrains.kotlin.gradle.plugin.*
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
||||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_ENABLE_INTRANSITIVE_METADATA_CONFIGURATION
|
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_ENABLE_INTRANSITIVE_METADATA_CONFIGURATION
|
||||||
import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension
|
import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension
|
||||||
@@ -32,6 +31,7 @@ fun buildProject(
|
|||||||
.build()
|
.build()
|
||||||
//temporary solution for BuildEventsListenerRegistry
|
//temporary solution for BuildEventsListenerRegistry
|
||||||
.also { addBuildEventsListenerRegistryMock(it) }
|
.also { addBuildEventsListenerRegistryMock(it) }
|
||||||
|
.also { disableDownloadingKonanFromMavenCentral(it) }
|
||||||
.apply(configureProject)
|
.apply(configureProject)
|
||||||
.let { it as ProjectInternal }
|
.let { it as ProjectInternal }
|
||||||
|
|
||||||
|
|||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.gradle.util
|
||||||
|
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.extraProperties
|
||||||
|
|
||||||
|
// TODO(Dmitrii Krasnov): we can remove this, when downloading konan from maven local will be possible KT-63198
|
||||||
|
internal fun disableDownloadingKonanFromMavenCentral(project: Project) {
|
||||||
|
project.extraProperties.set("kotlin.native.distribution.downloadFromMaven", "false")
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ import org.gradle.api.internal.project.ProjectInternal
|
|||||||
import org.gradle.testfixtures.ProjectBuilder
|
import org.gradle.testfixtures.ProjectBuilder
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||||
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.extraProperties
|
||||||
import org.jetbrains.kotlin.gradle.utils.NativeCompilerDownloader
|
import org.jetbrains.kotlin.gradle.utils.NativeCompilerDownloader
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@@ -19,6 +20,9 @@ internal val konanHome: File by lazy {
|
|||||||
.run {
|
.run {
|
||||||
project.plugins.apply("kotlin-multiplatform")
|
project.plugins.apply("kotlin-multiplatform")
|
||||||
|
|
||||||
|
// TODO(Dmitrii Krasnov): remove this, when KT-58303 is done
|
||||||
|
project.extraProperties.set("kotlin.native.distribution.downloadFromMaven","false")
|
||||||
|
|
||||||
(project.kotlinExtension as KotlinMultiplatformExtension).apply {
|
(project.kotlinExtension as KotlinMultiplatformExtension).apply {
|
||||||
macosX64()
|
macosX64()
|
||||||
macosArm64()
|
macosArm64()
|
||||||
|
|||||||
Reference in New Issue
Block a user