Skip to content

Commit

Permalink
Merge pull request #3 from klee0kai/release/0.0.3
Browse files Browse the repository at this point in the history
Release/0.0.3
  • Loading branch information
klee0kai authored Aug 5, 2023
2 parents 49fc387 + 8d01454 commit 5424839
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion jitpack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ jdk:
- openjdk11
install:
- echo "publish crosscompile plugin"
- ./gradlew :klee0kai-crosscompile:publishPluginMavenPublicationToMavenLocal
- ./gradlew :tasktree:publishPluginMavenPublicationToMavenLocal
8 changes: 4 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## TaskTree

[![](https://img.shields.io/badge/license-GNU_GPLv3-blue.svg?style=flat-square)](./LICENSE)
[![](https://jitpack.io/v/klee0kai/tasktree.svg)](https://jitpack.io/#klee0kai/tasktree)

Print gradle build dependencies graph

Expand All @@ -14,7 +15,7 @@ buildscript {
maven(url = "https://jitpack.io")
}
dependencies {
classpath("com.github.klee0kai:tasktree:0.0.1")
classpath("com.github.klee0kai:tasktree:0.0.3")
}
}
```
Expand Down Expand Up @@ -42,17 +43,16 @@ Report your build graph

## Configure Init Script

Configure your init script `$USER_HOME/.gradle/init.gradle.kts`
Configure your init script `$HOME/.gradle/init.gradle.kts`
[HowIt'sWork](https://docs.gradle.org/current/userguide/init_scripts.html).

```kotlin
initscript {
repositories {
mavenLocal()
maven(url = "https://jitpack.io")
}
dependencies {
classpath("com.github.klee0kai:tasktree:0.0.1")
classpath("com.github.klee0kai:tasktree:0.0.3")
}
}

Expand Down
2 changes: 1 addition & 1 deletion tasktree/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ gradlePlugin {
plugins.register("tasktree") {
id = "tasktree"
group = "com.github.klee0kai"
version = "0.0.1"
version = "0.0.3"
implementationClass = "com.github.klee0kai.tasktree.TaskTreePlugin"
displayName = "Task Tree"
description = "Print gradle build dependencies graph"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ open class TaskTreeExtension {

var printClassName: Boolean = false

var printDoubles: Boolean = false


}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ open class TaskTreeTask @Inject constructor(

}, lastChild)

if (task in renderedTasks || ext.maxDepth in 0..depth) {
if ((!ext.printDoubles && task in renderedTasks) || ext.maxDepth in 0..depth) {
graphRenderer?.startChildren()
graphRenderer?.visit({
withStyle(Normal)
Expand All @@ -64,24 +64,25 @@ open class TaskTreeTask @Inject constructor(
graphRenderer?.completeChildren()
return
}
renderedTasks.add(task)

graphRenderer?.startChildren()

val deps = project.taskGraph.getDependencies(task)
val depsSize = deps.size
deps.forEachIndexed { indx, it ->
val lastChild = indx >= depsSize - 1
render(it, lastChild = lastChild, depth = depth + 1)
try {
val deps = project.taskGraph.getDependencies(task)
val depsSize = deps.size
deps.forEachIndexed { indx, it ->
val lastChild = indx >= depsSize - 1
render(it, lastChild = lastChild, depth = depth + 1)
}
} catch (ignore: Exception) {
//ignore non available info
}

graphRenderer?.completeChildren()

}

private val Task.isIncludedBuild get() = this@TaskTreeTask.project.gradle != project.gradle



}


Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ package com.github.klee0kai.tasktree.utils
import org.gradle.execution.plan.ExecutionPlan
import org.gradle.execution.taskgraph.DefaultTaskExecutionGraph

inline fun <reified T, R> T.fieldValue(name: String): R? {
val field = T::class.java.getDeclaredField(name)
field.isAccessible = true
return field.get(this) as? R?
inline fun <reified T, reified R> T.fieldValue(name: String): R? {
return runCatching {
val field = T::class.java.getDeclaredField(name)
field.isAccessible = true
val value = field.get(this)
return value as? R?
}.getOrNull()
}

val DefaultTaskExecutionGraph.executionPlan: ExecutionPlan? get() = fieldValue("executionPlan")

0 comments on commit 5424839

Please sign in to comment.