Skip to content

Commit

Permalink
fix: Gradle task dependency graph workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
mpetuska committed Dec 30, 2024
1 parent 0fce268 commit d1e6652
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
12 changes: 10 additions & 2 deletions npm-publish-gradle-plugin/src/main/kotlin/NpmPublishPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dev.petuska.npm.publish
import dev.petuska.npm.publish.config.configure
import dev.petuska.npm.publish.config.configureNebulaNode
import dev.petuska.npm.publish.extension.NpmPublishExtension
import dev.petuska.npm.publish.task.NodeExecTask
import dev.petuska.npm.publish.task.NpmAssembleTask
import dev.petuska.npm.publish.task.NpmPackTask
import dev.petuska.npm.publish.task.NpmPublishTask
Expand Down Expand Up @@ -46,10 +47,17 @@ public class NpmPublishPlugin : Plugin<Project> {
}

afterEvaluate {
if (rootProject.tasks.names.contains("kotlinNodeJsSetup")) {
rootProject.tasks.named<NodeJsSetupTask>("kotlinNodeJsSetup").map(NodeJsSetupTask::destination)
if (tasks.names.contains("kotlinNodeJsSetup")) {
tasks.named<NodeJsSetupTask>("kotlinNodeJsSetup")
.map(NodeJsSetupTask::destination)
.let(layout::dir)
.let(extension.nodeHome::convention)
// Hack to work around all KGP kotlinNodeJsSetup tasks sharing the same output dir.
rootProject.allprojects { subProject ->
tasks.withType(NodeExecTask::class.java) {
it.mustRunAfter(subProject.tasks.withType(NodeJsSetupTask::class.java))
}
}
}
tasks.maybeCreate("assemble").apply {
group = "build"
Expand Down
14 changes: 12 additions & 2 deletions npm-publish-gradle-plugin/src/main/kotlin/config/extension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,18 @@ internal fun Project.configure(extension: NpmPublishExtension) {
default = providers.environmentVariable("NODE_HOME")
).map(layout.projectDirectory::dir)
)
extension.nodeBin.convention(extension.nodeHome.map { it.file("bin/node") })
extension.npmBin.convention(extension.nodeHome.map { it.file("bin/npm") })
extension.nodeBin.convention(
sysProjectEnvPropertyConvention(
"nodeBin",
extension.nodeHome.map { it.file("bin/node").asFile.absolutePath }
).map(layout.projectDirectory::file)
)
extension.npmBin.convention(
sysProjectEnvPropertyConvention(
"npmBin",
extension.nodeHome.map { it.file("bin/npm").asFile.absolutePath }
).map(layout.projectDirectory::file)
)
extension.readme.convention(
sysProjectEnvPropertyConvention("readme").map(layout.projectDirectory::file)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ internal fun Project.configure(target: KotlinJsTargetDsl): Unit = with(PluginLog
}

null -> null
else -> error("Unrecognised Kotlin/JS binary type: ${it::class.java.name}")
}
}
val compileKotlinTask = binary.flatMap<Kotlin2JsCompile>(JsIrBinary::linkTask)
Expand Down

0 comments on commit d1e6652

Please sign in to comment.