Search in sources :

Example 1 with IvyArtifactName

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());
}
Also used : LinkedHashSet(java.util.LinkedHashSet) VariantMetadata(org.gradle.internal.component.model.VariantMetadata) DefaultResolvedArtifact(org.gradle.api.internal.artifacts.DefaultResolvedArtifact) ResolvedArtifact(org.gradle.api.artifacts.ResolvedArtifact) AttributeContainerInternal(org.gradle.api.internal.attributes.AttributeContainerInternal) ImmutableSet(com.google.common.collect.ImmutableSet) ComponentArtifactMetadata(org.gradle.internal.component.model.ComponentArtifactMetadata) DefaultResolvedArtifact(org.gradle.api.internal.artifacts.DefaultResolvedArtifact) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) File(java.io.File)

Example 2 with IvyArtifactName

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);
    }
}
Also used : IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier)

Example 3 with IvyArtifactName

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);
            }
        }
    };
}
Also used : ExternalResourceName(org.gradle.internal.resource.ExternalResourceName) HashSet(java.util.HashSet) Set(java.util.Set) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName)

Example 4 with IvyArtifactName

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();
}
Also used : ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName)

Example 5 with IvyArtifactName

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);
}
Also used : DefaultModuleDescriptorArtifactMetadata(org.gradle.internal.component.model.DefaultModuleDescriptorArtifactMetadata) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) DefaultModuleComponentArtifactMetadata(org.gradle.internal.component.external.model.DefaultModuleComponentArtifactMetadata)

Aggregations

IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)52 DefaultIvyArtifactName (org.gradle.internal.component.model.DefaultIvyArtifactName)28 DefaultExclude (org.gradle.internal.component.external.descriptor.DefaultExclude)7 ExcludeMetadata (org.gradle.internal.component.model.ExcludeMetadata)7 File (java.io.File)6 Artifact (org.gradle.internal.component.external.descriptor.Artifact)6 ModuleIdentifier (org.gradle.api.artifacts.ModuleIdentifier)5 ComponentArtifactIdentifier (org.gradle.api.artifacts.component.ComponentArtifactIdentifier)5 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)5 ImmutableList (com.google.common.collect.ImmutableList)4 DefaultImmutableVersionConstraint (org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint)4 ComponentArtifactMetadata (org.gradle.internal.component.model.ComponentArtifactMetadata)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 List (java.util.List)3 Map (java.util.Map)3 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)3 ModuleVersionSelector (org.gradle.api.artifacts.ModuleVersionSelector)3 DefaultResolvedArtifact (org.gradle.api.internal.artifacts.DefaultResolvedArtifact)3 ImmutableAttributes (org.gradle.api.internal.attributes.ImmutableAttributes)3 MavenScope (org.gradle.internal.component.external.descriptor.MavenScope)3