-
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generates dependency graph for local (project) dependencies.
- Loading branch information
1 parent
fbdcba0
commit 731bef1
Showing
7 changed files
with
134 additions
and
10 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/functionalTest/groovy/com/autonomousapps/jvm/ProjectGraphSpec.groovy
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,30 @@ | ||
package com.autonomousapps.jvm | ||
|
||
import com.autonomousapps.jvm.projects.AbiAnnotationsProject | ||
|
||
import static com.autonomousapps.utils.Runner.build | ||
import static com.google.common.truth.Truth.assertThat | ||
|
||
final class ProjectGraphSpec extends AbstractJvmSpec { | ||
|
||
def "can generate project graph (#gradleVersion)"() { | ||
given: | ||
def project = new AbiAnnotationsProject(AbiAnnotationsProject.Target.CLASS) | ||
gradleProject = project.gradleProject | ||
when: | ||
build(gradleVersion, gradleProject.rootDir, ':proj:generateProjectGraphMain') | ||
then: | ||
def compileGraph = gradleProject | ||
.singleArtifact('proj', 'reports/dependency-analysis/main/graph/project/project-compile-classpath.gv') | ||
def runtimeGraph = gradleProject | ||
.singleArtifact('proj', 'reports/dependency-analysis/main/graph/project/project-runtime-classpath.gv') | ||
assertThat(compileGraph.exists()).isTrue() | ||
assertThat(runtimeGraph.exists()).isTrue() | ||
where: | ||
gradleVersion << gradleVersions() | ||
} | ||
} |
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
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
52 changes: 52 additions & 0 deletions
52
src/main/kotlin/com/autonomousapps/tasks/ProjectGraphTask.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,52 @@ | ||
package com.autonomousapps.tasks | ||
|
||
import com.autonomousapps.TASK_GROUP_DEP | ||
import com.autonomousapps.internal.graph.GraphViewBuilder | ||
import com.autonomousapps.internal.graph.GraphWriter | ||
import com.autonomousapps.internal.utils.getAndDelete | ||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.artifacts.result.ResolvedComponentResult | ||
import org.gradle.api.file.DirectoryProperty | ||
import org.gradle.api.provider.Property | ||
import org.gradle.api.tasks.CacheableTask | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.OutputDirectory | ||
import org.gradle.api.tasks.TaskAction | ||
|
||
@CacheableTask | ||
abstract class ProjectGraphTask : DefaultTask() { | ||
|
||
init { | ||
group = TASK_GROUP_DEP | ||
description = "Generates a graph view of this project's local dependency graph" | ||
} | ||
|
||
@get:Input | ||
abstract val compileClasspath: Property<ResolvedComponentResult> | ||
|
||
@get:Input | ||
abstract val runtimeClasspath: Property<ResolvedComponentResult> | ||
|
||
@get:OutputDirectory | ||
abstract val output: DirectoryProperty | ||
|
||
@TaskAction fun action() { | ||
val compileOutput = output.file("project-compile-classpath.gv").getAndDelete() | ||
val runtimeOutput = output.file("project-runtime-classpath.gv").getAndDelete() | ||
|
||
val compileGraph = GraphViewBuilder( | ||
root = compileClasspath.get(), | ||
fileCoordinates = emptySet(), | ||
localOnly = true, | ||
).graph | ||
|
||
val runtimeGraph = GraphViewBuilder( | ||
root = runtimeClasspath.get(), | ||
fileCoordinates = emptySet(), | ||
localOnly = true, | ||
).graph | ||
|
||
compileOutput.writeText(GraphWriter.toDot(compileGraph)) | ||
runtimeOutput.writeText(GraphWriter.toDot(runtimeGraph)) | ||
} | ||
} |