Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
146 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 0 additions & 18 deletions
18
buildSrc/src/main/java/com/jraska/github/client/GenerateModulesGraphTask.kt
This file was deleted.
Oops, something went wrong.
11 changes: 3 additions & 8 deletions
11
...ka/github/client/DependencyTreeFactory.kt → ...ub/client/GradleDependencyGraphFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...m/jraska/github/client/GraphStatistics.kt → ...ka/github/client/graph/GraphStatistics.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...jraska/github/client/GraphvizGenerator.kt → ...ska/github/client/graph/GraphvizWriter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...a/com/jraska/github/client/LongestPath.kt → ...jraska/github/client/graph/LongestPath.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
buildSrc/src/main/java/com/jraska/github/client/tasks/GenerateModulesGraphTask.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.jraska.github.client.tasks | ||
|
||
import com.jraska.github.client.GradleDependencyGraphFactory | ||
import com.jraska.github.client.graph.GraphvizWriter | ||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.TaskAction | ||
|
||
open class GenerateModulesGraphTask : DefaultTask() { | ||
@Input | ||
var layers: Array<String> = emptyArray() | ||
|
||
@TaskAction | ||
fun run() { | ||
val allModulesTree = GradleDependencyGraphFactory.create(project) | ||
|
||
println(allModulesTree.statistics()) | ||
println(GraphvizWriter.toGraphviz(allModulesTree, layers.toSet())) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 0 additions & 81 deletions
81
buildSrc/src/test/java/com/jraska/github/client/DependencyGraphTest.kt
This file was deleted.
Oops, something went wrong.
87 changes: 87 additions & 0 deletions
87
buildSrc/src/test/java/com/jraska/github/client/graph/DependencyGraphTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package com.jraska.github.client.graph | ||
|
||
import org.junit.Test | ||
|
||
class DependencyGraphTest { | ||
@Test | ||
fun correctHeightIsMaintained() { | ||
val dependencyTree = DependencyGraph.create( | ||
listOf( | ||
"app" to "feature", | ||
"app" to "lib", | ||
"feature" to "lib", | ||
"lib" to "core" | ||
) | ||
) | ||
|
||
assert(dependencyTree.heightOf("app") == 3) | ||
} | ||
|
||
@Test | ||
fun findsProperLongestPath() { | ||
val dependencyTree = DependencyGraph.create( | ||
listOf( | ||
"app" to "feature", | ||
"app" to "lib", | ||
"app" to "core", | ||
"feature" to "lib", | ||
"lib" to "core" | ||
) | ||
) | ||
|
||
assert(dependencyTree.longestPath("app").nodeNames == listOf("app", "feature", "lib", "core")) | ||
} | ||
|
||
@Test | ||
fun findsProperRoot() { | ||
val dependencyTree = DependencyGraph.create( | ||
listOf( | ||
"feature" to "lib", | ||
"lib" to "core", | ||
"app" to "feature", | ||
"app" to "lib", | ||
"app" to "core" | ||
) | ||
) | ||
|
||
assert(dependencyTree.findRoot().key == "app") | ||
} | ||
|
||
@Test | ||
fun createSubtreeProperly() { | ||
val dependencyTree = DependencyGraph.create( | ||
listOf( | ||
"feature" to "lib", | ||
"lib" to "core", | ||
"app" to "feature", | ||
"feature" to "core", | ||
"app" to "core" | ||
) | ||
) | ||
|
||
val subTree = dependencyTree.subTree("feature") | ||
|
||
assert(subTree.findRoot().key == "feature") | ||
assert(subTree.heightOf("feature") == 2) | ||
assert(subTree.longestPath("feature").nodeNames == listOf("feature", "lib", "core")) | ||
} | ||
|
||
@Test | ||
fun createCountStatisticsWell() { | ||
val dependencyTree = DependencyGraph.create( | ||
listOf( | ||
"feature" to "lib", | ||
"lib" to "core", | ||
"app" to "feature", | ||
"feature" to "core", | ||
"app" to "core" | ||
) | ||
) | ||
|
||
val statistics = dependencyTree.statistics() | ||
|
||
assert(statistics.height == 3) | ||
assert(statistics.modulesCount == 4) | ||
assert(statistics.edgesCount == 5) | ||
} | ||
} |