Slackbot
06/29/2023, 3:42 PMVampire
06/29/2023, 3:54 PMallprojects { ... } is evil, there is no order guarantee in what you configured. That you include one project later than another does not impose any ordering constraints or guarantees. If your backend depends on artifacts from the frontend, you will have a dependency declared and that will then care about building in the correct order.Martmists
06/29/2023, 3:57 PMfrom(project(":wiki-frontend-public").tasks.named("bundle")) , it gave an error, as the task had not yet been created.Martmists
06/29/2023, 3:59 PMVampire
06/29/2023, 4:07 PMMartmists
06/29/2023, 4:10 PMVampire
06/29/2023, 6:04 PMVampire
06/29/2023, 6:05 PMfrom(theConfigurationOnTheConsumerSide)Martmists
06/30/2023, 12:11 PM// backend build.gradle.kts
val bundleArtifact by configurations.creating
dependencies {
implementation(project(":wiki-common"))
bundleArtifact(project(":wiki-frontend-admin", "bundles"))
bundleArtifact(project(":wiki-frontend-public", "bundles"))
}
tasks {
val processResources by getting(Copy::class) {
from(bundleArtifact)
}
}
// frontend-* build.gradle.kts
val bundles by configurations.creating
tasks {
val bundleResources by creating(Copy::class) {
destinationDir = buildDir.resolve("bundle")
// ...
artifacts {
add(bundles.name, destinationDir)
}
}
}
But it seems backend:processResources doesn't move any of the resources this way.Vampire
06/30/2023, 12:37 PMgetting and creating instead of existing and registering, the artifacts is misplaced within the tasks closure. And besides that, you use a plain File as artifact, that cannot bear any task dependency. Use the task itself as artifact or at least configure the builtBy as shown in the documentation, but the former is preferable.Martmists
06/30/2023, 12:38 PMVampire
06/30/2023, 12:41 PMVampire
06/30/2023, 12:42 PMgetting and creating unless you have a really good reason or are on a really ancient version of Gradle.
Otherwise always use existing and registering unless you have a really good reason not to.Vampire
06/30/2023, 12:43 PMVampire
06/30/2023, 12:45 PMCopy task, but a Sync task, as that also wipes away stale files. Copy is mainly for special cases where you copy into a directory where existing files should be preserved.Vampire
06/30/2023, 12:46 PMbuiltByVampire
06/30/2023, 12:50 PMTaskProvider<Copy> it works, so if you would use registering instead of creating it works.Vampire
06/30/2023, 12:50 PMVampire
06/30/2023, 1:01 PMCopy or Sync task, as the one output file is the directory into which the files are copied, that's why it works with the TaskProvider you get from registeringVampire
06/30/2023, 1:28 PMMartmists
06/30/2023, 2:06 PM> Task :wiki-frontend-public:bundleResources
> Task :wiki-backend:processResources UP-TO-DATE // This depends on the bundleResources artifact, and should NOT be marked up-to-date!Vampire
06/30/2023, 2:12 PMMartmists
06/30/2023, 2:15 PMartifacts {
add(bundles.name, bundleResources) // now using the TaskProvider<Sync>
}
outside of the task configurationVampire
06/30/2023, 2:18 PM