[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 platformName: String,
|
||||||
val architectureName: String,
|
val architectureName: String,
|
||||||
val ivyDependency: String
|
val ivyDependency: String,
|
||||||
|
val downloadBaseUrl: String
|
||||||
) {
|
) {
|
||||||
val isWindows: Boolean
|
val isWindows: Boolean
|
||||||
get() = platformName == "win"
|
get() = platformName == "win"
|
||||||
|
|||||||
+2
-1
@@ -110,7 +110,8 @@ open class NodeJsRootExtension(@Transient val rootProject: Project) : Configurat
|
|||||||
nodeExecutable = getExecutable("node", nodeCommand, "exe"),
|
nodeExecutable = getExecutable("node", nodeCommand, "exe"),
|
||||||
platformName = platform,
|
platformName = platform,
|
||||||
architectureName = architecture,
|
architectureName = architecture,
|
||||||
ivyDependency = getIvyDependency()
|
ivyDependency = getIvyDependency(),
|
||||||
|
downloadBaseUrl = nodeDownloadBaseUrl
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+23
-23
@@ -28,6 +28,9 @@ abstract class NodeJsSetupTask : DefaultTask() {
|
|||||||
val ivyDependency: String
|
val ivyDependency: String
|
||||||
@Input get() = env.ivyDependency
|
@Input get() = env.ivyDependency
|
||||||
|
|
||||||
|
val downloadBaseUrl: String
|
||||||
|
@Input get() = env.downloadBaseUrl
|
||||||
|
|
||||||
val destination: File
|
val destination: File
|
||||||
@OutputDirectory get() = env.nodeDir
|
@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
|
@Suppress("unused") // as it called by Gradle before task execution and used to resolve artifact
|
||||||
@get:Classpath
|
@get:Classpath
|
||||||
val nodeJsDist: File
|
val nodeJsDist: File by lazy {
|
||||||
get() {
|
val repo = project.repositories.ivy { repo ->
|
||||||
@Suppress("UnstableApiUsage", "DEPRECATION")
|
repo.name = "Node Distributions at ${downloadBaseUrl}"
|
||||||
val repo = project.repositories.ivy { repo ->
|
repo.url = URI(downloadBaseUrl)
|
||||||
repo.name = "Node Distributions at ${settings.nodeDownloadBaseUrl}"
|
|
||||||
repo.url = URI(settings.nodeDownloadBaseUrl)
|
|
||||||
|
|
||||||
repo.patternLayout {
|
repo.patternLayout {
|
||||||
it.artifact("v[revision]/[artifact](-v[revision]-[classifier]).[ext]")
|
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") }
|
|
||||||
}
|
}
|
||||||
val startDownloadTime = System.currentTimeMillis()
|
repo.metadataSources { it.artifact() }
|
||||||
val dist = _nodeJsDist
|
repo.content { it.includeModule("org.nodejs", "node") }
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
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 {
|
init {
|
||||||
@Suppress("LeakingThis")
|
@Suppress("LeakingThis")
|
||||||
@@ -76,9 +76,9 @@ abstract class NodeJsSetupTask : DefaultTask() {
|
|||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
@TaskAction
|
@TaskAction
|
||||||
fun exec() {
|
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) {
|
if (!env.isWindows) {
|
||||||
File(env.nodeExecutable).setExecutable(true)
|
File(env.nodeExecutable).setExecutable(true)
|
||||||
|
|||||||
Reference in New Issue
Block a user