Skip to content

Dependencies

Roman edited this page Aug 23, 2022 · 5 revisions

Dependencies

Tasks can have other tasks as dependencies. So if a dependency is defined, this dependency is run before the actual task. gotaskr makes sure that each task is only run once, even if it is defined in multiple other tasks. To define a depencency, use the DependsOn while registering a task.

A simple example would be Build -> Test -> Deploy

To define this in gotaskr, this would look like:

gotaskr.Task("Build", buildFunc)
gotaskr.Task("Test", testFunc).DependsOn("Build")
gotaskr.Task("Deploy", deployFunc).DependsOn("Test")

A task can also have multiple dependencies. In that case, they are executed in the order they are added as dependency.

The following example will run all tasks in that order.
Sidenote1: If each task has dependencies defined as above, then Deploy would be enough but I'm sure you get the point.
Sidenote2: goext.Noop is a special constant which represends a no-operation function that can be used for tasks without own logic.

gotaskr.Task("Full-Build", goext.Noop).DependsOn("Build", "Test", "Deploy")

Reverse Dependencies

A reverse dependency can be defined with the DependeeOf method while registering a task.

Example:

gotaskr.Task("Build", buildFunc).DependeeOf("Test")
gotaskr.Task("Test", testFunc)
Clone this wiki locally