[Gradle, JS] Not resolve configuration with nodejs and yarn if it should not be downloaded
This commit is contained in:
+32
-2
@@ -1045,14 +1045,44 @@ class GeneralKotlin2JsGradlePluginIT : KGPBaseTest() {
|
|||||||
build("checkDownloadedFolder")
|
build("checkDownloadedFolder")
|
||||||
|
|
||||||
build("checkIfLastModifiedNotNow", "--rerun-tasks")
|
build("checkIfLastModifiedNotNow", "--rerun-tasks")
|
||||||
|
|
||||||
|
buildGradle.modify {
|
||||||
|
it + "\n" +
|
||||||
|
"""
|
||||||
|
rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin> {
|
||||||
|
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().nodeVersion = "unspecified"
|
||||||
|
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().download = false
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@DisplayName("Disable download should not download Node.JS and Yarn")
|
||||||
|
@GradleTest
|
||||||
|
fun testNodeJsAndYarnNotDownloaded(gradleVersion: GradleVersion) {
|
||||||
|
project("nodeJsDownload", gradleVersion) {
|
||||||
|
buildGradleKts.modify {
|
||||||
|
it + "\n" +
|
||||||
|
"""
|
||||||
|
rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin> {
|
||||||
|
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().nodeVersion = "unspecified"
|
||||||
|
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().download = false
|
||||||
|
}
|
||||||
|
rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin> {
|
||||||
|
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension>().version = "unspecified"
|
||||||
|
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension>().download = false
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
build("assemble")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@DisplayName("Yarn.lock persistence")
|
@DisplayName("Yarn.lock persistence")
|
||||||
@GradleTest
|
@GradleTest
|
||||||
fun testYarnLockStore(gradleVersion: GradleVersion) {
|
fun testYarnLockStore(gradleVersion: GradleVersion) {
|
||||||
project("cleanTask", gradleVersion) {
|
project("nodeJsDownload", gradleVersion) {
|
||||||
buildGradle.modify(::transformBuildScriptWithPluginsDsl)
|
|
||||||
build("assemble") {
|
build("assemble") {
|
||||||
assertFileExists(projectPath.resolve("kotlin-js-store").resolve("yarn.lock"))
|
assertFileExists(projectPath.resolve("kotlin-js-store").resolve("yarn.lock"))
|
||||||
assert(
|
assert(
|
||||||
|
|||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
plugins {
|
||||||
|
id("org.jetbrains.kotlin.js")
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
js {
|
||||||
|
nodejs()
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>CleanTask</title>
|
||||||
|
<script src="CleanTask.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import kotlinx.browser.document
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
document.write("Hello, world!")
|
||||||
|
}
|
||||||
+6
-2
@@ -50,7 +50,9 @@ abstract class NodeJsSetupTask : DefaultTask() {
|
|||||||
internal lateinit var configuration: Provider<Configuration>
|
internal lateinit var configuration: Provider<Configuration>
|
||||||
|
|
||||||
@get:Classpath
|
@get:Classpath
|
||||||
val nodeJsDist: File by lazy {
|
@get:Optional
|
||||||
|
val nodeJsDist: File? by lazy {
|
||||||
|
if (shouldDownload) {
|
||||||
val repo = project.repositories.ivy { repo ->
|
val repo = project.repositories.ivy { repo ->
|
||||||
repo.name = "Node Distributions at ${downloadBaseUrl}"
|
repo.name = "Node Distributions at ${downloadBaseUrl}"
|
||||||
repo.url = URI(downloadBaseUrl)
|
repo.url = URI(downloadBaseUrl)
|
||||||
@@ -70,6 +72,7 @@ abstract class NodeJsSetupTask : DefaultTask() {
|
|||||||
}
|
}
|
||||||
project.repositories.remove(repo)
|
project.repositories.remove(repo)
|
||||||
dist
|
dist
|
||||||
|
} else null
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@@ -81,6 +84,7 @@ abstract class NodeJsSetupTask : DefaultTask() {
|
|||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
@TaskAction
|
@TaskAction
|
||||||
fun exec() {
|
fun exec() {
|
||||||
|
if (!shouldDownload) return
|
||||||
logger.kotlinInfo("Using node distribution from '$nodeJsDist'")
|
logger.kotlinInfo("Using node distribution from '$nodeJsDist'")
|
||||||
|
|
||||||
var dirHash: String? = null
|
var dirHash: String? = null
|
||||||
@@ -93,7 +97,7 @@ abstract class NodeJsSetupTask : DefaultTask() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val tmpDir = temporaryDir
|
val tmpDir = temporaryDir
|
||||||
unpackNodeArchive(nodeJsDist, tmpDir)
|
unpackNodeArchive(nodeJsDist!!, tmpDir)
|
||||||
|
|
||||||
if (upToDate && fileHasher.calculateDirHash(tmpDir.resolve(destination.name))!! == dirHash) {
|
if (upToDate && fileHasher.calculateDirHash(tmpDir.resolve(destination.name))!! == dirHash) {
|
||||||
tmpDir.deleteRecursively()
|
tmpDir.deleteRecursively()
|
||||||
|
|||||||
+6
-2
@@ -62,7 +62,9 @@ open class YarnSetupTask : DefaultTask() {
|
|||||||
internal lateinit var configuration: Provider<Configuration>
|
internal lateinit var configuration: Provider<Configuration>
|
||||||
|
|
||||||
@get:Classpath
|
@get:Classpath
|
||||||
val yarnDist: File by lazy {
|
@get:Optional
|
||||||
|
val yarnDist: File? by lazy {
|
||||||
|
if (shouldDownload) {
|
||||||
val repo = project.repositories.ivy { repo ->
|
val repo = project.repositories.ivy { repo ->
|
||||||
repo.name = "Yarn Distributions at ${downloadUrl}"
|
repo.name = "Yarn Distributions at ${downloadUrl}"
|
||||||
repo.url = URI(downloadUrl)
|
repo.url = URI(downloadUrl)
|
||||||
@@ -81,6 +83,7 @@ open class YarnSetupTask : DefaultTask() {
|
|||||||
}
|
}
|
||||||
project.repositories.remove(repo)
|
project.repositories.remove(repo)
|
||||||
dist
|
dist
|
||||||
|
} else null
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@@ -91,6 +94,7 @@ open class YarnSetupTask : DefaultTask() {
|
|||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
fun setup() {
|
fun setup() {
|
||||||
|
if (!shouldDownload) return
|
||||||
logger.kotlinInfo("Using yarn distribution from '$yarnDist'")
|
logger.kotlinInfo("Using yarn distribution from '$yarnDist'")
|
||||||
|
|
||||||
var dirHash: String? = null
|
var dirHash: String? = null
|
||||||
@@ -103,7 +107,7 @@ open class YarnSetupTask : DefaultTask() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val tmpDir = temporaryDir
|
val tmpDir = temporaryDir
|
||||||
extract(yarnDist, tmpDir) // parent because archive contains name already
|
extract(yarnDist!!, tmpDir) // parent because archive contains name already
|
||||||
|
|
||||||
if (upToDate && fileHasher.calculateDirHash(tmpDir.resolve(destination.name))!! == dirHash) {
|
if (upToDate && fileHasher.calculateDirHash(tmpDir.resolve(destination.name))!! == dirHash) {
|
||||||
tmpDir.deleteRecursively()
|
tmpDir.deleteRecursively()
|
||||||
|
|||||||
Reference in New Issue
Block a user