Add 'kotlin.native.distribution.baseDownloadUrl' property
This property will allow customizing Kotlin/Native compiler download url. For example, useful when company does not allow contacting internet directly and requires using proxy. ^KT-47746 Fixed
This commit is contained in:
+17
@@ -1219,6 +1219,23 @@ class GeneralNativeIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun allowToOverrideDownloadUrl() {
|
||||
with(transformNativeTestProjectWithPluginDsl("native-parallel")) {
|
||||
gradleProperties().appendText(
|
||||
"""
|
||||
|
||||
kotlin.native.reinstall=true
|
||||
kotlin.native.distribution.baseDownloadUrl=https://non-existent.net
|
||||
""".trimIndent()
|
||||
)
|
||||
build("build") {
|
||||
assertFailed()
|
||||
assertContains("Could not HEAD 'https://non-existent.net")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun List<String>.containsSequentially(vararg elements: String): Boolean {
|
||||
check(elements.isNotEmpty())
|
||||
|
||||
+9
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrOutputGranularity
|
||||
import org.jetbrains.kotlin.gradle.targets.js.webpack.WebpackMajorVersion
|
||||
import org.jetbrains.kotlin.gradle.targets.native.DisabledNativeTargetsReporter
|
||||
import org.jetbrains.kotlin.gradle.tasks.*
|
||||
import org.jetbrains.kotlin.gradle.utils.NativeCompilerDownloader
|
||||
import org.jetbrains.kotlin.gradle.utils.SingleWarningPerBuild
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.konan.target.presetName
|
||||
@@ -255,6 +256,14 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
||||
val nativeDistributionType: String?
|
||||
get() = property("kotlin.native.distribution.type")
|
||||
|
||||
/**
|
||||
* Allows overriding Kotlin/Native base download url.
|
||||
*
|
||||
* When Kotlin/native will try to download native compiler, it will append compiler version and os type to this url.
|
||||
*/
|
||||
val nativeBaseDownloadUrl: String
|
||||
get() = property("kotlin.native.distribution.baseDownloadUrl") ?: NativeCompilerDownloader.BASE_DOWNLOAD_URL
|
||||
|
||||
/**
|
||||
* A property that was used to choose a restricted distribution in 1.3.
|
||||
*/
|
||||
|
||||
+5
-2
@@ -13,6 +13,7 @@ import org.gradle.api.logging.Logger
|
||||
import org.jetbrains.kotlin.compilerRunner.KotlinNativeCompilerRunner
|
||||
import org.jetbrains.kotlin.compilerRunner.konanVersion
|
||||
import org.jetbrains.kotlin.gradle.logging.kotlinInfo
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
||||
import org.jetbrains.kotlin.gradle.targets.native.internal.NativeDistributionType
|
||||
import org.jetbrains.kotlin.gradle.targets.native.internal.NativeDistributionTypeProvider
|
||||
import org.jetbrains.kotlin.konan.CompilerVersion
|
||||
@@ -33,7 +34,7 @@ class NativeCompilerDownloader(
|
||||
CompilerVersion.fromString(loadPropertyFromResources("project.properties", "kotlin.native.version"))
|
||||
}
|
||||
|
||||
private const val BASE_DOWNLOAD_URL = "https://download.jetbrains.com/kotlin/native/builds"
|
||||
internal const val BASE_DOWNLOAD_URL = "https://download.jetbrains.com/kotlin/native/builds"
|
||||
}
|
||||
|
||||
val compilerDirectory: File
|
||||
@@ -42,6 +43,8 @@ class NativeCompilerDownloader(
|
||||
private val logger: Logger
|
||||
get() = project.logger
|
||||
|
||||
private val kotlinProperties get() = PropertiesProvider(project)
|
||||
|
||||
private val distributionType: NativeDistributionType
|
||||
get() = NativeDistributionTypeProvider(project).getDistributionType(compilerVersion)
|
||||
|
||||
@@ -112,7 +115,7 @@ class NativeCompilerDownloader(
|
||||
|
||||
private fun downloadAndExtract() {
|
||||
val repoUrl = buildString {
|
||||
append("$BASE_DOWNLOAD_URL/")
|
||||
append("${kotlinProperties.nativeBaseDownloadUrl}/")
|
||||
append(if (compilerVersion.meta == MetaVersion.DEV) "dev/" else "releases/")
|
||||
append("$compilerVersion/")
|
||||
append(simpleOsName)
|
||||
|
||||
Reference in New Issue
Block a user