Offline plugin for native projects

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!!

Hopefully people are back from vacation …

Could I get a comment on this from either @native-core (or @dependency-team) team please. How do I get the source project metadata (name and version) for an external module dependency? Any code snippet or plugin reference would help.

Sorry for the late reply. Gradle 6.0 should have the documentation you required for the variant aware dependencies. You can check the nightly documentation before it’s released: https://docs.gradle.org/nightly/