-
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.
[Gradle, JS] Add test on valid of webpack config
^KT-48273 fixed
- Loading branch information
Showing
4 changed files
with
110 additions
and
0 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
58 changes: 58 additions & 0 deletions
58
...ation-tests/src/test/resources/testProject/kotlin-js-test-webpack-config/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,58 @@ | ||
import org.jetbrains.kotlin.gradle.targets.js.npm.npmProject | ||
|
||
plugins { | ||
kotlin("js") version "<pluginMarkerVersion>" | ||
} | ||
|
||
dependencies { | ||
implementation(kotlin("stdlib-js")) | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
kotlin { | ||
js { | ||
val compilation = compilations.getByName("main") | ||
org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsExec.create(compilation, "checkConfigDevelopmentWebpack") { | ||
inputFileProperty.set(provider { compilation.npmProject.require("webpack/bin/webpack.js") }.map { RegularFile { File(it) } }) | ||
dependsOn("browserDevelopmentWebpack") | ||
val configFile = tasks.named<org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack>("browserDevelopmentWebpack").map { it.configFile }.get() | ||
configFile.parentFile.listFiles().forEach { println(it)} | ||
args("configtest") | ||
args(configFile.absolutePath) | ||
} | ||
org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsExec.create(compilation, "checkConfigProductionWebpack") { | ||
inputFileProperty.set(provider { compilation.npmProject.require("webpack/bin/webpack.js") }.map { RegularFile { File(it) } }) | ||
dependsOn("browserProductionWebpack") | ||
val configFile = tasks.named<org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack>("browserProductionWebpack").map { it.configFile }.get() | ||
args("configtest") | ||
args(configFile.absolutePath) | ||
} | ||
org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsExec.create(compilation, "checkConfigDevelopmentRun") { | ||
inputFileProperty.set(provider { compilation.npmProject.require("webpack/bin/webpack.js") }.map { RegularFile { File(it) } }) | ||
dependsOn("browserDevelopmentRun") | ||
val configFile = tasks.named<org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack>("browserDevelopmentRun").map { it.configFile }.get() | ||
args("configtest") | ||
args(configFile.absolutePath) | ||
} | ||
org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsExec.create(compilation, "checkConfigProductionRun") { | ||
inputFileProperty.set(provider { compilation.npmProject.require("webpack/bin/webpack.js") }.map { RegularFile { File(it) } }) | ||
dependsOn("browserProductionRun") | ||
val configFile = tasks.named<org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack>("browserProductionRun").map { it.configFile }.get() | ||
args("configtest") | ||
args(configFile.absolutePath) | ||
} | ||
binaries.executable() | ||
browser { | ||
webpackTask { | ||
generateConfigOnly = true | ||
} | ||
runTask { | ||
generateConfigOnly = true | ||
} | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...on-tests/src/test/resources/testProject/kotlin-js-test-webpack-config/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,8 @@ | ||
pluginManagement { | ||
repositories { | ||
mavenLocal() | ||
gradlePluginPortal() | ||
} | ||
} | ||
|
||
rootProject.name = "kotlin-js-test-webpack-config" |
6 changes: 6 additions & 0 deletions
6
...ts/src/test/resources/testProject/kotlin-js-test-webpack-config/src/main/kotlin/Simple.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,6 @@ | ||
|
||
fun main() { | ||
console.log("Hello, ${greet()}") | ||
} | ||
|
||
fun greet() = "world" |