use of org.gradle.api.attributes.AttributeContainer in project gradle by gradle.
the class NodeState method getResolvedVariant.
public ResolvedVariantResult getResolvedVariant() {
if (cachedVariantResult != null) {
return cachedVariantResult;
}
DisplayName name = Describables.of(metaData.getName());
List<? extends Capability> capabilities = metaData.getCapabilities().getCapabilities();
AttributeContainer attributes = desugar(metaData.getAttributes());
List<Capability> resolvedVariantCapabilities = capabilities.isEmpty() ? Collections.singletonList(component.getImplicitCapability()) : ImmutableList.copyOf(capabilities);
cachedVariantResult = new DefaultResolvedVariantResult(component.getComponentId(), name, attributes, resolvedVariantCapabilities, findExternalVariant());
return cachedVariantResult;
}
use of org.gradle.api.attributes.AttributeContainer in project gradle by gradle.
the class Dimensions method variants.
private static void variants(Provider<String> baseName, Collection<BuildType> buildTypes, Collection<TargetMachine> targetMachines, ObjectFactory objectFactory, ImmutableAttributesFactory attributesFactory, // TODO: These should come from somewhere else, probably
Provider<String> group, Provider<String> version, Action<NativeVariantIdentity> action) {
for (BuildType buildType : buildTypes) {
for (TargetMachine targetMachine : targetMachines) {
Usage runtimeUsage = objectFactory.named(Usage.class, Usage.NATIVE_RUNTIME);
List<String> variantNameToken = Lists.newArrayList();
// FIXME: Always build type name to keep parity with previous Gradle version in tooling API
variantNameToken.add(buildType.getName());
variantNameToken.add(createDimensionSuffix(targetMachine.getOperatingSystemFamily(), targetMachinesToOperatingSystems(targetMachines)));
variantNameToken.add(createDimensionSuffix(targetMachine.getArchitecture(), targetMachinesToArchitectures(targetMachines)));
String variantName = StringUtils.uncapitalize(String.join("", variantNameToken));
AttributeContainer runtimeAttributes = attributesFactory.mutable();
runtimeAttributes.attribute(Usage.USAGE_ATTRIBUTE, runtimeUsage);
addCommonAttributes(buildType, targetMachine, runtimeAttributes);
DefaultUsageContext runtimeUsageContext = new DefaultUsageContext(variantName + "Runtime", runtimeAttributes);
DefaultUsageContext linkUsageContext = null;
NativeVariantIdentity variantIdentity = new NativeVariantIdentity(variantName, baseName, group, version, buildType.isDebuggable(), buildType.isOptimized(), targetMachine, linkUsageContext, runtimeUsageContext, null);
action.execute(variantIdentity);
}
}
}
use of org.gradle.api.attributes.AttributeContainer in project gradle by gradle.
the class Dimensions method variants.
private static void variants(Provider<String> baseName, Collection<BuildType> buildTypes, Collection<Linkage> linkages, Collection<TargetMachine> targetMachines, ObjectFactory objectFactory, ImmutableAttributesFactory attributesFactory, // TODO: These should come from somewhere else, probably
Provider<String> group, Provider<String> version, Action<NativeVariantIdentity> action) {
for (BuildType buildType : buildTypes) {
for (Linkage linkage : linkages) {
for (TargetMachine targetMachine : targetMachines) {
Usage runtimeUsage = objectFactory.named(Usage.class, Usage.NATIVE_RUNTIME);
Usage linkUsage = objectFactory.named(Usage.class, Usage.NATIVE_LINK);
List<String> variantNameToken = Lists.newArrayList();
// FIXME: Always build type name to keep parity with previous Gradle version in tooling API
variantNameToken.add(buildType.getName());
variantNameToken.add(createDimensionSuffix(linkage, linkages));
variantNameToken.add(createDimensionSuffix(targetMachine.getOperatingSystemFamily(), targetMachinesToOperatingSystems(targetMachines)));
variantNameToken.add(createDimensionSuffix(targetMachine.getArchitecture(), targetMachinesToArchitectures(targetMachines)));
String variantName = StringUtils.uncapitalize(String.join("", variantNameToken));
AttributeContainer runtimeAttributes = attributesFactory.mutable();
runtimeAttributes.attribute(Usage.USAGE_ATTRIBUTE, runtimeUsage);
addCommonAttributes(buildType, targetMachine, runtimeAttributes);
runtimeAttributes.attribute(LINKAGE_ATTRIBUTE, linkage);
DefaultUsageContext runtimeUsageContext = new DefaultUsageContext(variantName + "Runtime", runtimeAttributes);
AttributeContainer linkAttributes = attributesFactory.mutable();
linkAttributes.attribute(Usage.USAGE_ATTRIBUTE, linkUsage);
addCommonAttributes(buildType, targetMachine, linkAttributes);
linkAttributes.attribute(LINKAGE_ATTRIBUTE, linkage);
DefaultUsageContext linkUsageContext = new DefaultUsageContext(variantName + "Link", linkAttributes);
NativeVariantIdentity variantIdentity = new NativeVariantIdentity(variantName, baseName, group, version, buildType.isDebuggable(), buildType.isOptimized(), targetMachine, linkUsageContext, runtimeUsageContext, linkage);
action.execute(variantIdentity);
}
}
}
}
use of org.gradle.api.attributes.AttributeContainer in project gradle by gradle.
the class AttributeDesugaring method desugarSelector.
public ComponentSelector desugarSelector(ComponentSelector selector) {
if (selector instanceof ModuleComponentSelector) {
ModuleComponentSelector module = (ModuleComponentSelector) selector;
AttributeContainer moduleAttributes = module.getAttributes();
if (!moduleAttributes.isEmpty()) {
ImmutableAttributes attributes = ((AttributeContainerInternal) moduleAttributes).asImmutable();
return DefaultModuleComponentSelector.newSelector(module.getModuleIdentifier(), module.getVersionConstraint(), desugar(attributes), module.getRequestedCapabilities());
}
}
if (selector instanceof DefaultProjectComponentSelector) {
DefaultProjectComponentSelector project = (DefaultProjectComponentSelector) selector;
AttributeContainer projectAttributes = project.getAttributes();
if (!projectAttributes.isEmpty()) {
ImmutableAttributes attributes = ((AttributeContainerInternal) projectAttributes).asImmutable();
return new DefaultProjectComponentSelector(project.getBuildIdentifier(), project.getIdentityPath(), project.projectPath(), project.getProjectName(), desugar(attributes), project.getRequestedCapabilities());
}
}
return selector;
}
Aggregations