Search in sources :

Example 1 with MavenImmutableAttributesFactory

use of org.gradle.api.internal.artifacts.repositories.metadata.MavenImmutableAttributesFactory in project gradle by gradle.

the class JavaEcosystemVariantDerivationStrategy method derive.

@Override
public ImmutableList<? extends ConfigurationMetadata> derive(ModuleComponentResolveMetadata metadata) {
    if (metadata instanceof DefaultMavenModuleResolveMetadata) {
        DefaultMavenModuleResolveMetadata md = (DefaultMavenModuleResolveMetadata) metadata;
        ImmutableAttributes attributes = md.getAttributes();
        MavenImmutableAttributesFactory attributesFactory = (MavenImmutableAttributesFactory) md.getAttributesFactory();
        DefaultConfigurationMetadata compileConfiguration = (DefaultConfigurationMetadata) md.getConfiguration("compile");
        DefaultConfigurationMetadata runtimeConfiguration = (DefaultConfigurationMetadata) md.getConfiguration("runtime");
        ModuleComponentIdentifier componentId = md.getId();
        ImmutableCapabilities shadowedPlatformCapability = buildShadowPlatformCapability(componentId, false);
        ImmutableCapabilities shadowedEnforcedPlatformCapability = buildShadowPlatformCapability(componentId, true);
        return ImmutableList.of(// component we cannot mix precise usages with more generic ones)
        libraryWithUsageAttribute(compileConfiguration, attributes, attributesFactory, Usage.JAVA_API), libraryWithUsageAttribute(runtimeConfiguration, attributes, attributesFactory, Usage.JAVA_RUNTIME), libraryWithSourcesVariant(runtimeConfiguration, attributes, attributesFactory, metadata), libraryWithJavadocVariant(runtimeConfiguration, attributes, attributesFactory, metadata), platformWithUsageAttribute(compileConfiguration, attributes, attributesFactory, Usage.JAVA_API, false, shadowedPlatformCapability), platformWithUsageAttribute(runtimeConfiguration, attributes, attributesFactory, Usage.JAVA_RUNTIME, false, shadowedPlatformCapability), platformWithUsageAttribute(compileConfiguration, attributes, attributesFactory, Usage.JAVA_API, true, shadowedEnforcedPlatformCapability), platformWithUsageAttribute(runtimeConfiguration, attributes, attributesFactory, Usage.JAVA_RUNTIME, true, shadowedEnforcedPlatformCapability));
    }
    return null;
}
Also used : ImmutableAttributes(org.gradle.api.internal.attributes.ImmutableAttributes) DefaultMavenModuleResolveMetadata(org.gradle.internal.component.external.model.maven.DefaultMavenModuleResolveMetadata) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) MavenImmutableAttributesFactory(org.gradle.api.internal.artifacts.repositories.metadata.MavenImmutableAttributesFactory)

Aggregations

ModuleComponentIdentifier (org.gradle.api.artifacts.component.ModuleComponentIdentifier)1 MavenImmutableAttributesFactory (org.gradle.api.internal.artifacts.repositories.metadata.MavenImmutableAttributesFactory)1 ImmutableAttributes (org.gradle.api.internal.attributes.ImmutableAttributes)1 DefaultMavenModuleResolveMetadata (org.gradle.internal.component.external.model.maven.DefaultMavenModuleResolveMetadata)1