I am trying to create a version of this offline dependencies caching plugin here for native projects. The plugin basically caches external project dependencies locally for offline use.
For native, however, there are multiple Maven modules per project (one each for headers, libraries and executables). I would like to group these modules (and the corresponding artifacts) under one root folder i.e the project that generated these modules.
How do I get the name and version of the source project from an instance of ResolvedDependencyResult? Here’s my attempt so far -
@Suppress("unused")
@TaskAction
fun run() {
project.configurations.forEach { configuration ->
if (configuration.isCanBeResolved) {
walk(configuration.incoming.resolutionResult.root.dependencies)
}
}
}
private fun walk(dependencies: MutableSet<out DependencyResult?>) {
dependencies.forEach { dependency ->
if (dependency is ResolvedDependencyResult && dependency.selected.id is ModuleComponentIdentifier) {
println(dependency.selected.moduleVersion)
// How do I get the project that generated this module?
// Possibly an instance of ProjectComponenIdentifier?
}
walk(dependency.selected.dependencies)
}
}
I see that the *.module version has the necessary information (under node named, “component”) . Any example of how to get to this information? Do I have to parse this file manually? If yes, what does the required instance of ArtifactResolutionQuery look like to get the module file?
Appreciate some help!!