I’m working on a number of applications and frameworks that use an internally hosted Maven instance to store and retrieve required artifacts. Specifically, for Android builds, we need to retrieve a fair number of AARs with transitive dependencies, which may be referenced by dynamic versions.
While there is the possibility of running ./gradlew :app:dependencies
to see the output, I would like to know if there’s a way, at runtime (within a task defined by a plugin), to get the same data. I’d like to identify in-house artifacts (by Artifact name prefix) and the resolved version, to write a manifest JSON file into an APK, which has a view that reads/displays frameworks getting utilized, which can be observed by QA/Devs. I’m not interested in knowing the entire tree, but rather, the result of dependency resolution as it applies to in-house artifacts.
We had some success with the following snippet, but we have found that dependencies using “implementation” are not reported.
def dependencies = [:]
Object json = new File("${project.rootDir}/${project.name}/Manifest.json")
project.configurations.compile.incoming.getResolutionResult().getAllDependencies().each { depResult ->
def (group,moduleName,moduleVersion) = depResult.getRequested().toString().split(':')
dependencies[moduleName] = moduleVersion
}
json.write(new JsonBuilder(dependencies).toPrettyString())
I’ve seen reference to the following task, but I’m not sure what to do with it -
https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/diagnostics/AbstractDependencyReportTask.html
Any assistance would be appreciated,
Thank you -
Rex Hardin