diff options
author | Adam <897017+aSemy@users.noreply.github.com> | 2023-05-25 23:19:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-26 00:19:27 +0200 |
commit | f182a0add34876f74c47100e604f79f46c4ddca2 (patch) | |
tree | ab13fdef2c3ae4b807aa5defbff39bb89c3ec2b0 /plugins/base/frontend/build.gradle.kts | |
parent | f55e22d5fe3f9121b7ed81d0c3f8c6a094dff45c (diff) | |
download | dokka-f182a0add34876f74c47100e604f79f46c4ddca2.tar.gz dokka-f182a0add34876f74c47100e604f79f46c4ddca2.tar.bz2 dokka-f182a0add34876f74c47100e604f79f46c4ddca2.zip |
Improve copying base-frontend files between subprojects (#2970)
Diffstat (limited to 'plugins/base/frontend/build.gradle.kts')
-rw-r--r-- | plugins/base/frontend/build.gradle.kts | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/plugins/base/frontend/build.gradle.kts b/plugins/base/frontend/build.gradle.kts index cadf3fae..2d8bbb7f 100644 --- a/plugins/base/frontend/build.gradle.kts +++ b/plugins/base/frontend/build.gradle.kts @@ -1,6 +1,10 @@ +import com.github.gradle.node.npm.task.NpmTask +import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs + +@Suppress("DSL_SCOPE_VIOLATION") // fixed in Gradle 8.1 https://github.com/gradle/gradle/pull/23639 plugins { - base - id("com.github.node-gradle.node") version "3.2.1" + id("org.jetbrains.conventions.dokka-html-frontend-files") + alias(libs.plugins.gradleNode) } node { @@ -11,19 +15,34 @@ node { distBaseUrl.set(null as String?) // Strange cast to avoid overload ambiguity } -val npmRunBuild = tasks.getByName("npm_run_build") { - inputs.dir(file("src/main")) - inputs.files(file("package.json"), file("webpack.config.js")) - outputs.dir(file("dist/")) +val distributionDirectory = layout.projectDirectory.dir("dist") + +val npmRunBuild by tasks.registering(NpmTask::class) { + dependsOn(tasks.npmInstall) + + npmCommand.set(parseSpaceSeparatedArgs("run build")) + + inputs.dir("src/main") + inputs.files( + "package.json", + "webpack.config.js", + ) + + outputs.dir(distributionDirectory) outputs.cacheIf { true } } -task("generateFrontendFiles") { - dependsOn(npmRunBuild) +configurations.dokkaHtmlFrontendFilesElements.configure { + outgoing { + artifact(distributionDirectory) { + builtBy(npmRunBuild) + } + } } -tasks { - clean { - delete(file("node_modules"), file("dist")) - } +tasks.clean { + delete( + file("node_modules"), + file("dist"), + ) } |