Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to access Gradle module metadata files from dependency resolution #11449

Closed
ljacomet opened this issue Nov 22, 2019 · 1 comment
Assignees
Labels
a:feature A new functionality in:dependency-management DO NOT USE

Comments

@ljacomet
Copy link
Member

There is currently a way, through ArtifactResolutionQuery, to get at the POM files for a dependency resolution result.
Gradle should offer a similar access to the Gradle Module Metadata file.

While it might make sense to offer access to metadata through the ResolvableDependencies in the future, this does not mean a more direct / custom access is not needed for specific use cases.

@jjohannes
Copy link
Contributor

Closing this as the use case can be addressed with component metadata rules:

class DirectMetadataAccessVariantRule implements ComponentMetadataRule {
@javax.inject.Inject
ObjectFactory getObjects() { }
void execute(ComponentMetadataContext context) {
def id = context.details.id
context.details.maybeAddVariant("apiElementsWithMetadata", "api") {
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.DOCUMENTATION))
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType, "all-files"))
}
withFiles {
addFile("\${id.name}-\${id.version}.pom")
addFile("\${id.name}-\${id.version}.module")
}
}
context.details.maybeAddVariant("compileWithMetadata", "compile") {
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.DOCUMENTATION))
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType, "all-files"))
}
withFiles {
addFile("\${id.name}-\${id.version}.pom")
}
}
}
}

(improved by #11565 in 6.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:feature A new functionality in:dependency-management DO NOT USE
Projects
None yet
Development

No branches or pull requests

2 participants