diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/NativeDownloadIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/NativeDownloadIT.kt index beee8575d21..06192769b6a 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/NativeDownloadIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/NativeDownloadIT.kt @@ -49,7 +49,7 @@ class NativeDownloadIT : BaseGradleIT() { with(transformNativeTestProjectWithPluginDsl("native-download-maven")) { gradleProperties().appendText( """ - kotlin.native.distribution.baseDownloadUrl=${mavenUrl()} + kotlin.native.distribution.mavenDownloadUrl=${mavenUrl()} kotlin.native.distribution.downloadFromMaven=true """.trimIndent() ) @@ -66,7 +66,7 @@ class NativeDownloadIT : BaseGradleIT() { with(transformNativeTestProjectWithPluginDsl("native-download-maven")) { gradleProperties().appendText( """ - kotlin.native.distribution.baseDownloadUrl=${mavenUrl()} + kotlin.native.distribution.mavenDownloadUrl=${mavenUrl()} kotlin.native.distribution.downloadFromMaven=true """.trimIndent() ) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-download-maven/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-download-maven/build.gradle.kts index 0a0d7f04710..c42733437c0 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-download-maven/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-download-maven/build.gradle.kts @@ -6,7 +6,6 @@ plugins { repositories { mavenLocal() - mavenCentral() } kotlin { 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 20de426083a..e7678a4a0a6 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,11 +277,19 @@ 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.baseDownloadUrl` allows to specify custom maven url. + * Property `kotlin.native.distribution.mavenDownloadUrl` allows to specify custom maven url. */ 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 547a0d9a54f..5eda2dd75e4 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 @@ -123,7 +123,7 @@ class NativeCompilerDownloader( private fun downloadAndExtract() { val repoUrl = if (kotlinProperties.nativeDownloadFromMaven) { - kotlinProperties.nativeBaseDownloadUrl.takeIf { it != BASE_DOWNLOAD_URL } + kotlinProperties.nativeMavenDownloadUrl } else { buildString { append("${kotlinProperties.nativeBaseDownloadUrl}/") @@ -132,7 +132,6 @@ class NativeCompilerDownloader( append(simpleOsName) } } - val dependencyUrl = if (repoUrl != null) "$repoUrl/$dependencyFileName" else "maven://$dependencyFileName" val repo = if (repoUrl != null) { if (kotlinProperties.nativeDownloadFromMaven) { @@ -166,12 +165,13 @@ class NativeCompilerDownloader( logger.lifecycle("\nPlease wait while Kotlin/Native compiler $compilerVersion is being installed.") if (!kotlinProperties.nativeDownloadFromMaven) { - val suffix = project.probeRemoteFileLength(dependencyUrl, probingTimeoutMs = 200) + val dependencyUrl = "$repoUrl/$dependencyFileName" + val lengthSuffix = project.probeRemoteFileLength(dependencyUrl, probingTimeoutMs = 200) ?.let { " (${formatContentLength(it)})" } .orEmpty() - logger.lifecycle("Download $dependencyUrl$suffix") + logger.lifecycle("Download $dependencyUrl$lengthSuffix") } - val archive = logger.lifecycleWithDuration("Download $dependencyUrl finished,") { + val archive = logger.lifecycleWithDuration("Download $dependencyFileName finished,") { configuration.files.single() }