Skip to content

Expose a way to download and list Android dependencies #154165

@HosseinYousefi

Description

@HosseinYousefi

We want a command like flutter build --config-only (or similar) to download Gradle dependencies and list the jar files. Preferably this should work even if the Flutter project is a plugin and not an application with a main function.

This is useful for jnigen where we want to generate Dart bindings for an application's gradle dependencies.

Similarly, downloading source jars and Javadocs are useful, here is a task that downloads the source artifacts. (Replacing SourcesArtifact with JavadocArtifact will do the same for Javadocs)

tasks.register("getSources") {
    doLast {
        val componentIds =
            configurations["releaseCompileClasspath"].incoming.resolutionResult.allDependencies.map { it.from.id }
        val result = dependencies.createArtifactResolutionQuery().forComponents(componentIds)
            .withArtifacts(JvmLibrary::class.java, SourcesArtifact::class.java).execute()
        val sourceArtifacts = mutableListOf<File>()
        result.resolvedComponents.forEach { component ->
            val sources = component.getArtifacts(SourcesArtifact::class.java)
            sources.forEach { artifact ->
                if (artifact is ResolvedArtifactResult) {
                    sourceArtifacts.add(artifact.file)
                }
            }
        }
        sourceArtifacts.forEach { println(it) }
    }
}

Context: dart-lang/native#628

@gmackall @reidbaker

Metadata

Metadata

Labels

a: buildBuilding flutter applications with the toolp: toolingAffects the flutter_plugin_tools packaget: gradle"flutter build" and "flutter run" on Androidteam-androidOwned by Android platform teamtoolAffects the "flutter" command-line tool. See also t: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions