Skip to content

Commit

Permalink
Merge branch 'fork/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
dorongold committed Mar 29, 2024
2 parents 51f44f8 + ebaa17f commit 8586289
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ No task dependencies
### Configuration
To limit the depth of the printed tree, add the command-line option: `--depth <number>`
To print task inputs for each task in the tree, add the command-line option: `--with-inputs`
To print task outputs for each task in the tree, add the command-line option: `--with-outputs`
To print task outputs for each task in the tree, add the command-line option: `--with-outputs`
To print task description in the tree, add the command-line option: `--with-description`
To allow a sub-tree of the same task to be repeated more than once, add the command-line option: `--repeat`

For a more static custom configuration, you can put the following in `build.gradle` (or, in case you take the [init script approach](#init-script-snippet), in `init.gradle`).
Expand All @@ -119,7 +120,8 @@ tasks.named('taskTree').configure {
depth = 3 // limit tree depth to 3. Equivalent to the --depth CLI task option.
withInputs = true // prints task inputs in red just below the task in the tree. Equivalent to the --with-inputs CLI task option.
withOutputs = true // prints task outputs in green just below the task in the tree. Equivalent to the --with-outputs CLI task option.
repeat = true // allows printing a sub-tree in the task-tree more than once. Equivalent to the --repeat CLI task option
withDescription = true // prints task description in orange just below the task in the tree. Equivalent to the --with-description CLI task option.
repeat = true // allows printing a sub-tree in the task-tree more than once. Equivalent to the --repeat CLI task option.
impliesSubProjects = true // disables printing task-tree for child projects in a multi-project
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ interface TaskTreePluginExtension {

Property<Boolean> getWithOutputs()

Property<Boolean> getWithDescription()

Property<Integer> getDepth()
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ class TaskTreeTask extends TaskTreeTaskBase {
super.withOutputs = withOutputs
}

@Option(option = "with-description", description = "print task description in orange just below task in graph")
void setWithDescription(boolean withDescription) {
super.withDescription = withDescription
}

@Option(option = "depth", description = "descend at most <depth> levels into each task dependency")
void setDepth(String depth) {
super.depth = depth.toInteger()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ abstract class TaskTreeTaskBase extends ProjectBasedReportTask {
@Internal
boolean withOutputs = false

@Internal
boolean withDescription = false

@Internal
int depth = Integer.MAX_VALUE

Expand Down Expand Up @@ -126,6 +129,10 @@ abstract class TaskTreeTaskBase extends ProjectBasedReportTask {
printTaskFiles(graphRenderer, taskNode.task.outputs.files, "-> ", SuccessHeader, Success)
}

if (withDescription) {
printTaskDescription(graphRenderer, taskNode.task.description, "-> ", Description, Description)
}

}, lastChild)

if (skippingChildren) {
Expand All @@ -140,6 +147,21 @@ abstract class TaskTreeTaskBase extends ProjectBasedReportTask {
}
}

static void printTaskDescription(GraphRenderer graphRenderer, String description, String prefix, StyledTextOutput.Style prefixStyle, StyledTextOutput.Style textStyle) {
graphRenderer.startChildren()
graphRenderer.output.println()
graphRenderer.output
.withStyle(Info)
.text(graphRenderer.prefix)
graphRenderer.output
.withStyle(prefixStyle)
.text(" " * 5 + "${prefix} ")
graphRenderer.output
.withStyle(textStyle)
.text(description)
graphRenderer.completeChildren()
}

static void printTaskFiles(GraphRenderer graphRenderer, FileCollection files, String prefix, StyledTextOutput.Style prefixStyle, StyledTextOutput.Style textStyle) {
graphRenderer.startChildren()
files.eachWithIndex { File file, int i ->
Expand Down Expand Up @@ -185,12 +207,17 @@ abstract class TaskTreeTaskBase extends ProjectBasedReportTask {
textOutput.withStyle(SuccessHeader).println(" ->")
}

if (withInputs || withOutputs) {
if (withDescription) {
textOutput.text("Task description is shown in green and prefixed with")
textOutput.withStyle(SuccessHeader).println(" ->")
}

if (withInputs || withOutputs || withDescription) {
textOutput.println()
}

textOutput.text("To see task dependency tree for a specific task, run ")
metaData.describeCommand(textOutput.withStyle(UserInput), String.format("<project-path>:<task> <project-path>:taskTree [--depth <depth>] [--with-inputs] [--with-outputs] [--repeat]"))
metaData.describeCommand(textOutput.withStyle(UserInput), String.format("<project-path>:<task> <project-path>:taskTree [--depth <depth>] [--with-inputs] [--with-outputs] [--with-description] [--repeat]"))
textOutput.println()

textOutput.text("Executions of all tasks except for ")
Expand Down

0 comments on commit 8586289

Please sign in to comment.