-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Wasm] Move nodejs setup task to project-scoped plugin NodeJsPlugin
To solve problem that users cannot set Node.JS version per sub-project, new plugin NodeJsPlugin is introduced and it now registers setup task per-project NodeJsRootExtension has deprecated properties to configure Node.JS version, But it influences only rootProject's NodeJs Added new kind of extensions to configure tools (Binaryen, D8, Node.js, Yarn) with Provider API. In the future old extensions should be deprecated and removed, and new "EnvSpec" should be the only way to configure ^KT-69628 fixed Co-authored-by: Adam Semenenko <[email protected]>
- Loading branch information
1 parent
4ce13c9
commit bc02ee8
Showing
63 changed files
with
1,442 additions
and
673 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...gin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/NodeJsGradlePluginIT.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Copyright 2010-2020 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. | ||
*/ | ||
|
||
package org.jetbrains.kotlin.gradle | ||
|
||
import org.gradle.api.Action | ||
import org.gradle.util.GradleVersion | ||
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension | ||
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin | ||
import org.jetbrains.kotlin.gradle.testbase.* | ||
import org.jetbrains.kotlin.test.TestMetadata | ||
import org.junit.jupiter.api.DisplayName | ||
|
||
|
||
@MppGradlePluginTests | ||
class NodeJsGradlePluginIT : KGPBaseTest() { | ||
@DisplayName("Set different Node.js versions in different subprojects") | ||
@GradleTest | ||
@TestMetadata("subprojects-nodejs-setup") | ||
fun testDifferentVersionInSubprojects(gradleVersion: GradleVersion) { | ||
project( | ||
"subprojects-nodejs-setup", | ||
gradleVersion | ||
) { | ||
build(":app1:jsNodeDevelopmentRun") { | ||
assertOutputContains("Hello with version: v22.2.0") | ||
} | ||
|
||
build(":app2:jsNodeDevelopmentRun") { | ||
assertOutputContains("Hello with version: v22.1.0") | ||
} | ||
} | ||
} | ||
|
||
@DisplayName("Set different Node.js versions in different subprojects configured with previous API") | ||
@GradleTest | ||
@TestMetadata("subprojects-nodejs-setup") | ||
fun testDifferentVersionInSubprojectsWithPreviousApi(gradleVersion: GradleVersion) { | ||
project( | ||
"subprojects-nodejs-setup", | ||
gradleVersion | ||
) { | ||
listOf("app1", "app2").forEach { subProjectName -> | ||
subProject(subProjectName).buildGradleKts.modify { | ||
it.replace("plugins.", "rootProject.plugins.") | ||
.replace("the", "rootProject.the") | ||
.replace("NodeJsPlugin", "NodeJsRootPlugin") | ||
.replace("NodeJsEnvSpec", "NodeJsRootExtension") | ||
.replace("""version\.set\(("\d+\.\d+.\d+")\)""".toRegex(), "version = \"22.3.0\"") | ||
} | ||
} | ||
|
||
build(":app1:jsNodeDevelopmentRun") { | ||
assertOutputContains("Hello with version: v22.3.0") | ||
} | ||
|
||
build(":app2:jsNodeDevelopmentRun") { | ||
assertOutputContains("Hello with version: v22.3.0") | ||
} | ||
} | ||
} | ||
|
||
@DisplayName("Set different Node.js versions in root project and subprojects") | ||
@GradleTest | ||
@TestMetadata("subprojects-nodejs-setup") | ||
fun testDifferentVersionInRootProjectAndSubprojects(gradleVersion: GradleVersion) { | ||
project( | ||
"subprojects-nodejs-setup", | ||
gradleVersion | ||
) { | ||
buildScriptInjection { | ||
project.rootProject.plugins.withType(NodeJsRootPlugin::class.java, Action { | ||
project.rootProject.extensions.getByType(NodeJsRootExtension::class.java).version = "22.3.0" | ||
}) | ||
} | ||
|
||
build(":app1:jsNodeDevelopmentRun") { | ||
assertOutputContains("Hello with version: v22.2.0") | ||
} | ||
|
||
build(":app2:jsNodeDevelopmentRun") { | ||
assertOutputContains("Hello with version: v22.1.0") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...ation-tests/src/test/resources/testProject/subprojects-nodejs-setup/app1/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
plugins { | ||
id("org.jetbrains.kotlin.multiplatform") | ||
} | ||
|
||
kotlin { | ||
js { | ||
binaries.executable() | ||
nodejs() | ||
} | ||
} | ||
|
||
plugins.withType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsPlugin> { | ||
the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsEnvSpec>().version.set("22.2.0") | ||
} |
10 changes: 10 additions & 0 deletions
10
...ts/src/test/resources/testProject/subprojects-nodejs-setup/app1/src/jsMain/kotlin/main.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright 2010-2024 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. | ||
*/ | ||
|
||
fun main() { | ||
println("Hello with version: " + process.version) | ||
} | ||
|
||
external val process: dynamic |
14 changes: 14 additions & 0 deletions
14
...ation-tests/src/test/resources/testProject/subprojects-nodejs-setup/app2/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
plugins { | ||
id("org.jetbrains.kotlin.multiplatform") | ||
} | ||
|
||
kotlin { | ||
js { | ||
binaries.executable() | ||
nodejs() | ||
} | ||
} | ||
|
||
plugins.withType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsPlugin> { | ||
the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsEnvSpec>().version.set("22.1.0") | ||
} |
10 changes: 10 additions & 0 deletions
10
...sts/src/test/resources/testProject/subprojects-nodejs-setup/app2/src/jsMain/kotlin/foo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright 2010-2024 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. | ||
*/ | ||
|
||
fun main() { | ||
println("Hello with version: " + process.version) | ||
} | ||
|
||
external val process: dynamic |
3 changes: 3 additions & 0 deletions
3
...ntegration-tests/src/test/resources/testProject/subprojects-nodejs-setup/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
plugins { | ||
id("org.jetbrains.kotlin.multiplatform") apply false | ||
} |
2 changes: 2 additions & 0 deletions
2
...gration-tests/src/test/resources/testProject/subprojects-nodejs-setup/settings.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
include("app1") | ||
include("app2") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.