use of org.gradle.internal.component.model.IvyArtifactName in project gradle by gradle.
the class DefaultArtifactSet method snapshot.
@Override
public ArtifactSet snapshot() {
ImmutableSet.Builder<ResolvedVariant> result = ImmutableSet.builder();
for (VariantMetadata variant : variants) {
Set<? extends ComponentArtifactMetadata> artifacts = variant.getArtifacts();
Set<ResolvedArtifact> resolvedArtifacts = new LinkedHashSet<ResolvedArtifact>(artifacts.size());
// Add artifact format as an implicit attribute when all artifacts have the same format
AttributeContainerInternal attributes = variant.getAttributes();
if (!attributes.contains(ArtifactAttributes.ARTIFACT_FORMAT)) {
String format = null;
for (ComponentArtifactMetadata artifact : artifacts) {
String candidateFormat = artifact.getName().getType();
if (format == null) {
format = candidateFormat;
} else if (!format.equals(candidateFormat)) {
format = null;
break;
}
}
if (format != null) {
attributes = attributesFactory.concat(attributes.asImmutable(), ArtifactAttributes.ARTIFACT_FORMAT, format);
}
}
for (ComponentArtifactMetadata artifact : artifacts) {
IvyArtifactName artifactName = artifact.getName();
if (exclusions.excludeArtifact(moduleVersionIdentifier.getModule(), artifactName)) {
continue;
}
ResolvedArtifact resolvedArtifact = allResolvedArtifacts.get(artifact.getId());
if (resolvedArtifact == null) {
Factory<File> artifactSource = new BuildOperationArtifactSource(buildOperationExecutor, artifact.getId(), new LazyArtifactSource(artifact, moduleSource, artifactResolver));
resolvedArtifact = new DefaultResolvedArtifact(moduleVersionIdentifier, artifactName, artifact.getId(), artifact.getBuildDependencies(), artifactSource);
allResolvedArtifacts.put(artifact.getId(), resolvedArtifact);
}
resolvedArtifacts.add(resolvedArtifact);
}
result.add(ArtifactBackedResolvedVariant.create(attributes, resolvedArtifacts));
}
return new ArtifactSetSnapshot(id, componentIdentifier, result.build());
}
use of org.gradle.internal.component.model.IvyArtifactName in project gradle by gradle.
the class ModuleExclusions method forExclude.
private static AbstractModuleExclusion forExclude(Exclude rule) {
// For custom ivy pattern matchers, don't inspect the rule any more deeply: this prevents us from doing smart merging later
if (!PatternMatchers.isExactMatcher(rule.getMatcher())) {
return new IvyPatternMatcherExcludeRuleSpec(rule);
}
ModuleIdentifier moduleId = rule.getModuleId();
IvyArtifactName artifact = rule.getArtifact();
boolean anyOrganisation = isWildcard(moduleId.getGroup());
boolean anyModule = isWildcard(moduleId.getName());
boolean anyArtifact = isWildcard(artifact.getName()) && isWildcard(artifact.getType()) && isWildcard(artifact.getExtension());
// Build a strongly typed (mergeable) exclude spec for each supplied rule
if (anyArtifact) {
if (!anyOrganisation && !anyModule) {
return new ModuleIdExcludeSpec(moduleId);
} else if (!anyModule) {
return new ModuleNameExcludeSpec(moduleId.getName());
} else if (!anyOrganisation) {
return new GroupNameExcludeSpec(moduleId.getGroup());
} else {
return EXCLUDE_ALL_MODULES_SPEC;
}
} else {
return new ArtifactExcludeSpec(moduleId, artifact);
}
}
use of org.gradle.internal.component.model.IvyArtifactName in project gradle by gradle.
the class MavenVersionLister method newVisitor.
public VersionPatternVisitor newVisitor(final ModuleIdentifier module, final Collection<String> dest, final ResourceAwareResolveResult result) {
return new VersionPatternVisitor() {
final Set<ExternalResourceName> searched = new HashSet<ExternalResourceName>();
public void visit(ResourcePattern pattern, IvyArtifactName artifact) throws ResourceException {
ExternalResourceName metadataLocation = pattern.toModulePath(module).resolve("maven-metadata.xml");
if (!searched.add(metadataLocation)) {
return;
}
result.attempted(metadataLocation);
MavenMetadata mavenMetaData = mavenMetadataLoader.load(metadataLocation.getUri());
for (String version : mavenMetaData.versions) {
dest.add(version);
}
}
};
}
use of org.gradle.internal.component.model.IvyArtifactName in project gradle by gradle.
the class IvyXmlModuleDescriptorWriter method printDependency.
protected void printDependency(IvyModulePublishMetadata metadata, LocalOriginDependencyMetadata dep, SimpleXmlWriter writer) throws IOException {
writer.startElement("dependency");
ModuleVersionSelector requested = dep.getRequested();
writer.attribute("org", requested.getGroup());
writer.attribute("name", requested.getName());
writer.attribute("rev", requested.getVersion());
if (dep.getDynamicConstraintVersion() != null && !dep.getDynamicConstraintVersion().equals(requested.getVersion())) {
writer.attribute("revConstraint", dep.getDynamicConstraintVersion());
}
if (dep.isForce()) {
writer.attribute("force", "true");
}
if (dep.isChanging()) {
writer.attribute("changing", "true");
}
if (!dep.isTransitive()) {
writer.attribute("transitive", "false");
}
writer.attribute("conf", getConfMapping(dep));
for (IvyArtifactName dependencyArtifact : dep.getArtifacts()) {
printDependencyArtifact(writer, dependencyArtifact, dep.getModuleConfiguration());
}
printDependencyExcludeRules(metadata, writer, dep.getExcludes());
writer.endElement();
}
use of org.gradle.internal.component.model.IvyArtifactName in project gradle by gradle.
the class ExternalResourceResolver method getMetaDataArtifactFor.
private ModuleDescriptorArtifactMetadata getMetaDataArtifactFor(ModuleComponentIdentifier moduleComponentIdentifier) {
IvyArtifactName ivyArtifactName = getMetaDataArtifactName(moduleComponentIdentifier.getModule());
DefaultModuleComponentArtifactMetadata defaultModuleComponentArtifactMetadata = new DefaultModuleComponentArtifactMetadata(moduleComponentIdentifier, ivyArtifactName);
return new DefaultModuleDescriptorArtifactMetadata(defaultModuleComponentArtifactMetadata);
}
Aggregations