[K/N][gradle] Add kotlin.native.distribution.mavenDownloadUrl property
Add a separate property to specify maven repository to download K/N
This commit is contained in:
committed by
Space Team
parent
82d28b6dbf
commit
afeeba51ec
+2
-2
@@ -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()
|
||||
)
|
||||
|
||||
-1
@@ -6,7 +6,6 @@ plugins {
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
|
||||
+9
-1
@@ -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
|
||||
|
||||
+5
-5
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user