I'm trying to achieve the same as <the following>,...
# gradle
c
I'm trying to achieve the same as the following, where module A is a compose-html module called "compose-web", and module B is a Ktor module called "backend". In
compose-web/build.gradle.kts
I have:
Copy code
private val webDistribution by configurations.registering {
  isCanBeConsumed = true
  isCanBeResolved = false
}

artifacts {
  add(webDistribution.name, tasks.named("jsBrowserDistribution"))
}
In
backend/build.gradle.kts
I have:
Copy code
private val webOutput by configurations.creating {
  isCanBeConsumed = false
  isCanBeResolved = true
}

dependencies {
  webOutput(project(":compose-web", configuration = "webDistribution"))
}

val copyWebOutput by tasks.registering(Copy::class) {
  from(webOutput)
  into(project.layout.buildDirectory.dir("app"))
}

sourceSets.main.configure { resources.srcDir(copyWebOutput) }
The
jsBrowserDistribution
task is triggered before
copyWebOutput
, however
copyWebOutput
isn't waiting for
jsBrowserDistribution
to finish. As a result the
compose-web/build/dist/js/productionExecutable/compose-web.js
doesn't get generated until a few seconds after the
copyWebOutput
task has already run, and hence doesn't get copied across to
backend/build/app/compose-web.js
. I see there are also static files from
compose-web/src/jsMain/resources
that get copied to
compose-web/build/dist/js/productionExecutable
by the
jsBrowserProductionExecutableDistribution
task, is that causing this problem? How can I solve it?