From d735fa6567a3af93256b4272a6769f887aeda91d Mon Sep 17 00:00:00 2001 From: Pavel Punegov Date: Fri, 30 Sep 2022 18:21:59 +0200 Subject: [PATCH] [K/N][gradle] Remove download url property. --- .../native/NativeDownloadAndPlatformLibsIT.kt | 55 +++---------------- .../gradle/plugin/PropertiesProvider.kt | 11 +--- .../native/NativeCompilerDownloader.kt | 35 ++++-------- 3 files changed, 19 insertions(+), 82 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/NativeDownloadAndPlatformLibsIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/NativeDownloadAndPlatformLibsIT.kt index de4a42c1eb8..92490ac2e4f 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/NativeDownloadAndPlatformLibsIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/NativeDownloadAndPlatformLibsIT.kt @@ -313,11 +313,12 @@ class NativeDownloadAndPlatformLibsIT : BaseGradleIT() { fun `download prebuilt Native bundle with maven`() { with(transformNativeTestProjectWithPluginDsl("native-download-maven")) { gradleProperties().appendText( - """ - kotlin.native.distribution.mavenDownloadUrl=${mavenUrl()} - kotlin.native.distribution.downloadFromMaven=true - """.trimIndent() + "kotlin.native.distribution.downloadFromMaven=true" ) + gradleBuildScript().let { + val text = it.readText().replaceFirst("// ", "maven(\"${mavenUrl()}\")") + it.writeText(text) + } build("assemble") { assertSuccessful() assertContains("Unpack Kotlin/Native compiler to ") @@ -330,35 +331,16 @@ class NativeDownloadAndPlatformLibsIT : BaseGradleIT() { fun `download light Native bundle with maven`() { with(transformNativeTestProjectWithPluginDsl("native-download-maven")) { gradleProperties().appendText( - """ - kotlin.native.distribution.mavenDownloadUrl=${mavenUrl()} - kotlin.native.distribution.downloadFromMaven=true - """.trimIndent() - ) - build("assemble", "-Pkotlin.native.distribution.type=light") { - assertSuccessful() - assertContains("Unpack Kotlin/Native compiler to ") - assertContains("Generate platform libraries for ") - } - } - } - - @Test - fun `download from maven specified in the build`() { - with(transformNativeTestProjectWithPluginDsl("native-download-maven")) { - gradleProperties().appendText( - """ - kotlin.native.distribution.downloadFromMaven=true - """.trimIndent() + "kotlin.native.distribution.downloadFromMaven=true" ) gradleBuildScript().let { val text = it.readText().replaceFirst("// ", "maven(\"${mavenUrl()}\")") it.writeText(text) } - - build("assemble") { + build("assemble", "-Pkotlin.native.distribution.type=light") { assertSuccessful() assertContains("Unpack Kotlin/Native compiler to ") + assertContains("Generate platform libraries for ") } } } @@ -378,25 +360,4 @@ class NativeDownloadAndPlatformLibsIT : BaseGradleIT() { } } } - - @Test - fun `download from maven specified in the build and with parameter`() { - with(transformNativeTestProjectWithPluginDsl("native-download-maven")) { - gradleProperties().appendText( - """ - kotlin.native.distribution.mavenDownloadUrl=${mavenUrl()} - kotlin.native.distribution.downloadFromMaven=true - """.trimIndent() - ) - gradleBuildScript().let { - val text = it.readText().replaceFirst("// ", "maven(\"${mavenUrl()}\")") - it.writeText(text) - } - - build("assemble") { - assertSuccessful() - assertContains("Unpack Kotlin/Native compiler to ") - } - } - } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/PropertiesProvider.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/PropertiesProvider.kt index e7678a4a0a6..7b5ac532452 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/PropertiesProvider.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/PropertiesProvider.kt @@ -277,19 +277,10 @@ internal class PropertiesProvider private constructor(private val project: Proje val nativeBaseDownloadUrl: String get() = this.property("kotlin.native.distribution.baseDownloadUrl") ?: NativeCompilerDownloader.BASE_DOWNLOAD_URL - /** - * Allows setting Kotlin/Native maven url to download bundles from. - * - * This path will be added as a maven repository to the project. - */ - val nativeMavenDownloadUrl: String? - get() = this.property("kotlin.native.distribution.mavenDownloadUrl") - /** * Allows downloading Kotlin/Native distribution with maven. * - * Makes downloader search for bundles in maven repositories. - * Property `kotlin.native.distribution.mavenDownloadUrl` allows to specify custom maven url. + * Makes downloader search for bundles in maven repositories specified in the project. */ val nativeDownloadFromMaven: Boolean get() = this.booleanProperty("kotlin.native.distribution.downloadFromMaven") ?: false diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeCompilerDownloader.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeCompilerDownloader.kt index 5eda2dd75e4..29082b08466 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeCompilerDownloader.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeCompilerDownloader.kt @@ -108,37 +108,22 @@ class NativeCompilerDownloader( } } - private fun setupMavenRepo(repoUrl: String): ArtifactRepository { - return project.repositories.maven { repo -> - repo.setUrl(repoUrl) - repo.metadataSources { - it.artifact() - } - } - } - private fun removeRepo(repo: ArtifactRepository) { project.repositories.remove(repo) } - private fun downloadAndExtract() { - val repoUrl = if (kotlinProperties.nativeDownloadFromMaven) { - kotlinProperties.nativeMavenDownloadUrl - } else { - buildString { - append("${kotlinProperties.nativeBaseDownloadUrl}/") - append(if (compilerVersion.meta == MetaVersion.DEV) "dev/" else "releases/") - append("$compilerVersion/") - append(simpleOsName) - } + private val repoUrl by lazy { + buildString { + append("${kotlinProperties.nativeBaseDownloadUrl}/") + append(if (compilerVersion.meta == MetaVersion.DEV) "dev/" else "releases/") + append("$compilerVersion/") + append(simpleOsName) } + } - val repo = if (repoUrl != null) { - if (kotlinProperties.nativeDownloadFromMaven) { - setupMavenRepo(repoUrl) - } else { - setupRepo(repoUrl) - } + private fun downloadAndExtract() { + val repo = if (!kotlinProperties.nativeDownloadFromMaven) { + setupRepo(repoUrl) } else null val compilerDependency = if (kotlinProperties.nativeDownloadFromMaven) {