[Gradle, JS] Fix node.js repository declaration
^KT-47557 fixed
This commit is contained in:
+2
-1
@@ -11,7 +11,8 @@ data class NodeJsEnv(
|
||||
|
||||
val platformName: String,
|
||||
val architectureName: String,
|
||||
val ivyDependency: String
|
||||
val ivyDependency: String,
|
||||
val downloadBaseUrl: String
|
||||
) {
|
||||
val isWindows: Boolean
|
||||
get() = platformName == "win"
|
||||
|
||||
+2
-1
@@ -110,7 +110,8 @@ open class NodeJsRootExtension(@Transient val rootProject: Project) : Configurat
|
||||
nodeExecutable = getExecutable("node", nodeCommand, "exe"),
|
||||
platformName = platform,
|
||||
architectureName = architecture,
|
||||
ivyDependency = getIvyDependency()
|
||||
ivyDependency = getIvyDependency(),
|
||||
downloadBaseUrl = nodeDownloadBaseUrl
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+23
-23
@@ -28,6 +28,9 @@ abstract class NodeJsSetupTask : DefaultTask() {
|
||||
val ivyDependency: String
|
||||
@Input get() = env.ivyDependency
|
||||
|
||||
val downloadBaseUrl: String
|
||||
@Input get() = env.downloadBaseUrl
|
||||
|
||||
val destination: File
|
||||
@OutputDirectory get() = env.nodeDir
|
||||
|
||||
@@ -41,30 +44,27 @@ abstract class NodeJsSetupTask : DefaultTask() {
|
||||
|
||||
@Suppress("unused") // as it called by Gradle before task execution and used to resolve artifact
|
||||
@get:Classpath
|
||||
val nodeJsDist: File
|
||||
get() {
|
||||
@Suppress("UnstableApiUsage", "DEPRECATION")
|
||||
val repo = project.repositories.ivy { repo ->
|
||||
repo.name = "Node Distributions at ${settings.nodeDownloadBaseUrl}"
|
||||
repo.url = URI(settings.nodeDownloadBaseUrl)
|
||||
val nodeJsDist: File by lazy {
|
||||
val repo = project.repositories.ivy { repo ->
|
||||
repo.name = "Node Distributions at ${downloadBaseUrl}"
|
||||
repo.url = URI(downloadBaseUrl)
|
||||
|
||||
repo.patternLayout {
|
||||
it.artifact("v[revision]/[artifact](-v[revision]-[classifier]).[ext]")
|
||||
it.ivy("v[revision]/ivy.xml")
|
||||
}
|
||||
repo.metadataSources { it.artifact() }
|
||||
repo.content { it.includeModule("org.nodejs", "node") }
|
||||
repo.patternLayout {
|
||||
it.artifact("v[revision]/[artifact](-v[revision]-[classifier]).[ext]")
|
||||
}
|
||||
val startDownloadTime = System.currentTimeMillis()
|
||||
val dist = _nodeJsDist
|
||||
val downloadDuration = System.currentTimeMillis() - startDownloadTime
|
||||
if (downloadDuration > 0) {
|
||||
KotlinBuildStatsService.getInstance()
|
||||
?.report(NumericalMetrics.ARTIFACTS_DOWNLOAD_SPEED, dist.length() * 1000 / downloadDuration)
|
||||
}
|
||||
project.repositories.remove(repo)
|
||||
return dist
|
||||
repo.metadataSources { it.artifact() }
|
||||
repo.content { it.includeModule("org.nodejs", "node") }
|
||||
}
|
||||
val startDownloadTime = System.currentTimeMillis()
|
||||
val dist = _nodeJsDist
|
||||
val downloadDuration = System.currentTimeMillis() - startDownloadTime
|
||||
if (downloadDuration > 0) {
|
||||
KotlinBuildStatsService.getInstance()
|
||||
?.report(NumericalMetrics.ARTIFACTS_DOWNLOAD_SPEED, dist.length() * 1000 / downloadDuration)
|
||||
}
|
||||
project.repositories.remove(repo)
|
||||
dist
|
||||
}
|
||||
|
||||
init {
|
||||
@Suppress("LeakingThis")
|
||||
@@ -76,9 +76,9 @@ abstract class NodeJsSetupTask : DefaultTask() {
|
||||
@Suppress("unused")
|
||||
@TaskAction
|
||||
fun exec() {
|
||||
logger.kotlinInfo("Using node distribution from '$_nodeJsDist'")
|
||||
logger.kotlinInfo("Using node distribution from '$nodeJsDist'")
|
||||
|
||||
unpackNodeArchive(_nodeJsDist, destination.parentFile) // parent because archive contains name already
|
||||
unpackNodeArchive(nodeJsDist, destination.parentFile) // parent because archive contains name already
|
||||
|
||||
if (!env.isWindows) {
|
||||
File(env.nodeExecutable).setExecutable(true)
|
||||
|
||||
Reference in New Issue
Block a user