0

I want to run a small collection of tasks at the same time under a new task name like mylocaldevflow.

What is the best way to do this?

I can make a custom task like:

task localflow {
    description 'Task to ease local development.'
}

localflow.dependsOn snapshot
localflow.dependsOn javadoc
localflow.dependsOn build
localflow.dependsOn publishToMavenLocal

But this seems to suffer from being up to date when the dependent tasks are not.

In addition to not being up to date aware it only runs the top level 'build' task and ignores the sub module build tasks in the build.

I don't want to use the default tasks list for this if possible.

Ben McNiel
  • 8,661
  • 10
  • 36
  • 38

2 Answers2

0

You are going to want to try playing around with the up-to-date property.

Take a look at this: Resetting the UP-TO-DATE property of gradle tasks?

The above link shows you how to always run the task. If all of your dependent tasks are up to date, it should be a cheap run through, so setting it to always run might be a quick, simple solution. If you need a bit more complex of logic, you might be able to dig through the gradle docs to find what you need: https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:up_to_date_checks

Community
  • 1
  • 1
Adam
  • 2,214
  • 1
  • 15
  • 26
0

To make this composite task work in multi module builds and not block execute by being up to date I did:

task localflow {
    description 'Task to ease local development.'
    outputs.upToDateWhen { false }
}
subprojects {
    localflow.dependsOn snapshot
    localflow.dependsOn javadoc
    localflow.dependsOn build
    localflow.dependsOn publishToMavenLocal
}
Ben McNiel
  • 8,661
  • 10
  • 36
  • 38