use of org.gradle.api.internal.attributes.ImmutableAttributes in project gradle by gradle.
the class ModuleMetadataFileGenerator method collectCoordinates.
private void collectCoordinates(Collection<? extends PublicationInternal> publications, Map<SoftwareComponent, ComponentData> coordinates) {
for (PublicationInternal publication : publications) {
if (publication.getComponent() != null) {
ModuleVersionIdentifier moduleVersionIdentifier = publication.getCoordinates();
ImmutableAttributes attributes = publication.getAttributes();
coordinates.put(publication.getComponent(), new ComponentData(moduleVersionIdentifier, attributes));
}
}
}
use of org.gradle.api.internal.attributes.ImmutableAttributes in project gradle by gradle.
the class DefaultVersionMappingStrategy method createDefaultMappingStrategy.
private DefaultVariantVersionMappingStrategy createDefaultMappingStrategy(ImmutableAttributes variantAttributes) {
DefaultVariantVersionMappingStrategy strategy = new DefaultVariantVersionMappingStrategy(configurations, projectResolver, projectRegistry);
if (!defaultConfigurations.isEmpty()) {
// First need to populate the default variant version mapping strategy with the default values
// provided by plugins
AttributeMatcher matcher = schema.matcher();
Set<ImmutableAttributes> candidates = defaultConfigurations.keySet();
List<ImmutableAttributes> matches = matcher.matches(candidates, variantAttributes, AttributeMatchingExplanationBuilder.NO_OP);
for (ImmutableAttributes match : matches) {
strategy.setTargetConfiguration(configurations.getByName(defaultConfigurations.get(match)));
}
}
return strategy;
}
use of org.gradle.api.internal.attributes.ImmutableAttributes in project gradle by gradle.
the class MavenPomFileGenerator method addDependencyManagement.
private void addDependencyManagement(MavenDependencyInternal dependency, String scope) {
Dependency mavenDependency = new Dependency();
String groupId = dependency.getGroupId();
String artifactId = dependency.getArtifactId();
String projectPath = dependency.getProjectPath();
ImmutableAttributes attributes = attributesForScope(scope);
ModuleVersionIdentifier resolvedVersion = versionMappingStrategy.findStrategyForVariant(attributes).maybeResolveVersion(groupId, artifactId, projectPath);
mavenDependency.setGroupId(resolvedVersion != null ? resolvedVersion.getGroup() : groupId);
mavenDependency.setArtifactId(resolvedVersion != null ? resolvedVersion.getName() : artifactId);
mavenDependency.setVersion(resolvedVersion == null ? mapToMavenSyntax(dependency.getVersion()) : resolvedVersion.getVersion());
String type = dependency.getType();
if (type != null) {
mavenDependency.setType(type);
}
// Only publish the import scope, others have too different meanings than what Gradle expresses
if ("import".equals(scope)) {
mavenDependency.setScope(scope);
}
DependencyManagement dependencyManagement = model.getDependencyManagement();
if (dependencyManagement == null) {
dependencyManagement = new DependencyManagement();
model.setDependencyManagement(dependencyManagement);
}
dependencyManagement.addDependency(mavenDependency);
}
use of org.gradle.api.internal.attributes.ImmutableAttributes in project gradle by gradle.
the class DefaultVersionMappingStrategy method createDefaultMappingStrategy.
private DefaultVariantVersionMappingStrategy createDefaultMappingStrategy(ImmutableAttributes variantAttributes) {
DefaultVariantVersionMappingStrategy strategy = new DefaultVariantVersionMappingStrategy(configurations, projectResolver, projectRegistry);
if (!defaultConfigurations.isEmpty()) {
// First need to populate the default variant version mapping strategy with the default values
// provided by plugins
AttributeMatcher matcher = schema.matcher();
Set<ImmutableAttributes> candidates = defaultConfigurations.keySet();
List<ImmutableAttributes> matches = matcher.matches(candidates, variantAttributes, AttributeMatchingExplanationBuilder.NO_OP);
for (ImmutableAttributes match : matches) {
strategy.setTargetConfiguration(configurations.getByName(defaultConfigurations.get(match)));
}
}
return strategy;
}
use of org.gradle.api.internal.attributes.ImmutableAttributes in project gradle by gradle.
the class DefaultConfiguration method artifactCollection.
private ConfigurationArtifactCollection artifactCollection(AttributeContainerInternal attributes, Spec<? super ComponentIdentifier> componentFilter, boolean lenient, boolean allowNoMatchingVariants) {
ImmutableAttributes viewAttributes = attributes.asImmutable();
DefaultResolutionHost failureHandler = new DefaultResolutionHost();
ConfigurationFileCollection files = new ConfigurationFileCollection(new SelectedArtifactsProvider(), Specs.satisfyAll(), viewAttributes, componentFilter, lenient, allowNoMatchingVariants, failureHandler);
return new ConfigurationArtifactCollection(files, lenient, failureHandler, calculatedValueContainerFactory);
}
Aggregations