[Gradle, JS] Check if resourcesDir exists and resourceDir is input directory

This commit is contained in:
Ilya Goncharov
2019-12-02 13:14:51 +03:00
parent 053469dcec
commit fe9ddd9f22
2 changed files with 18 additions and 5 deletions
@@ -182,13 +182,16 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
} }
it.doLast { _ -> it.doLast { _ ->
compilation.output.resourcesDir val resourcesDir = compilation.output.resourcesDir
if (resourcesDir.exists()) {
resourcesDir
.copyRecursively( .copyRecursively(
target = it.destinationDirectory!!, target = it.destinationDirectory!!,
overwrite = true overwrite = true
) )
} }
} }
}
if (kind == BuildVariantKind.PRODUCTION) { if (kind == BuildVariantKind.PRODUCTION) {
project.tasks.getByName(LifecycleBasePlugin.ASSEMBLE_TASK_NAME).dependsOn(webpackTask) project.tasks.getByName(LifecycleBasePlugin.ASSEMBLE_TASK_NAME).dependsOn(webpackTask)
@@ -101,6 +101,16 @@ open class KotlinWebpack : DefaultTask(), RequiresNpmDependencies {
open val evaluatedConfigFile: File open val evaluatedConfigFile: File
@OutputFile get() = reportDir.resolve("webpack.config.evaluated.js") @OutputFile get() = reportDir.resolve("webpack.config.evaluated.js")
val resourcesDir: File?
@Optional
@InputDirectory
get() {
val resourcesDir = compilation.output.resourcesDir
return if (resourcesDir.exists()) {
resourcesDir
} else null
}
@Input @Input
var bin: String = "webpack/bin/webpack.js" var bin: String = "webpack/bin/webpack.js"