Slackbot
09/08/2023, 2:17 PMFabio Berta
09/08/2023, 2:19 PMenabled flag in Task A but that also seems fishy.Fabio Berta
09/08/2023, 2:27 PMdependsOn in the the configuration of Task B. Another episode of me writing things down and through that finding a solution 🙂 Thanks for listening 😉Vampire
09/08/2023, 2:38 PMcalling task B directly with execute()This was never supported and always highly problematic and risky and should never be done. If you actually can do this, you should upgrade anyway, as this method is loooong gone for good reasons. The main question is, why would you do a string comparison as a task action? If you really would want to set some state in one task to get it in another one, a shared build service would be the proper way. But task A per-se sounds like it is not really idiomatic to exist at all. 🙂 Unless of course you oversimplified the situation in your description. :-)
Fabio Berta
09/08/2023, 9:56 PMFabio Berta
09/08/2023, 9:56 PMtasks.register("publishAll") {
val version = Version.parse(providers.gradleProperty("version").get())
val latest = Version.parse(changelog.getLatest().version)
if (version > latest) {
println("Found new version $version that is greater than the latest published one $latest, publishing projects.")
dependsOn(patchChangelog)
dependsOn(subprojects.map { ":${it.name}:publish" })
} else {
println("No new version found, not publishing anything.")
}
}Fabio Berta
09/08/2023, 9:57 PMorg.jetbrains.changelogFabio Berta
09/08/2023, 9:57 PMexecute just read about it when looking for solutions for this thing)Vampire
09/08/2023, 10:01 PMFabio Berta
09/08/2023, 10:04 PMgradle.properties and push it. The CI pipeline then executes this publishAll task, compares the version and if it detects a new one, edits the changelog, publishes the packages and does a git tag (missing).Vampire
09/08/2023, 10:05 PMFabio Berta
09/08/2023, 10:06 PMVampire
09/08/2023, 10:07 PMVampire
09/08/2023, 10:08 PMPublishToMavenRepository tasks with an onlyIf that does the version checkFabio Berta
09/08/2023, 10:11 PMFabio Berta
09/08/2023, 10:13 PMtasks.register("publishAll") {
dependsOn(patchChangelog)
dependsOn(subprojects.map { ":${it.name}:publish" })
onlyIf {
val version = Version.parse(providers.gradleProperty("version").get())
val latest = Version.parse(changelog.getLatest().version)
version > latest
}
}Fabio Berta
09/08/2023, 10:13 PMFabio Berta
09/08/2023, 10:14 PMVampire
09/08/2023, 10:14 PMpublishAll that does not have any tasks anyway so is skipped always anyway. That does not skip the dependency tasks.Vampire
09/08/2023, 10:15 PMpublishAll task alltogether and just execute ./gradlew patchChangelog publish.Fabio Berta
09/08/2023, 10:16 PMVampire
09/08/2023, 10:16 PMVampire
09/08/2023, 10:17 PMFabio Berta
09/08/2023, 10:18 PMFabio Berta
09/08/2023, 10:18 PMdependsOn ? 🙂Fabio Berta
09/08/2023, 10:23 PMVampire
09/08/2023, 10:45 PMdependsOn is fine.
I don't like too much direct dependencies between tasks of different projects if they can be avoided. 🙂Vampire
09/08/2023, 10:46 PM