Search in sources :

Example 1 with ModuleComponentIdentifier

use of org.gradle.api.artifacts.component.ModuleComponentIdentifier in project gradle by gradle.

the class MavenResolver method parseMetaDataFromResource.

protected MutableMavenModuleResolveMetadata parseMetaDataFromResource(ModuleComponentIdentifier moduleComponentIdentifier, LocallyAvailableExternalResource cachedResource, DescriptorParseContext context) {
    MutableMavenModuleResolveMetadata metaData = metaDataParser.parseMetaData(context, cachedResource);
    if (moduleComponentIdentifier instanceof MavenUniqueSnapshotComponentIdentifier) {
        // Snapshot POMs use -SNAPSHOT instead of the timestamp as version, so validate against the expected id
        MavenUniqueSnapshotComponentIdentifier snapshotComponentIdentifier = (MavenUniqueSnapshotComponentIdentifier) moduleComponentIdentifier;
        checkMetadataConsistency(snapshotComponentIdentifier.getSnapshotComponent(), metaData);
        // Use the requested id. Currently we're discarding the MavenUniqueSnapshotComponentIdentifier and replacing with DefaultModuleComponentIdentifier as pretty
        // much every consumer of the meta-data is expecting a DefaultModuleComponentIdentifier.
        ModuleComponentIdentifier lossyId = DefaultModuleComponentIdentifier.newId(moduleComponentIdentifier.getGroup(), moduleComponentIdentifier.getModule(), moduleComponentIdentifier.getVersion());
        metaData.setComponentId(lossyId);
        metaData.setSnapshotTimestamp(snapshotComponentIdentifier.getTimestamp());
    } else {
        checkMetadataConsistency(moduleComponentIdentifier, metaData);
    }
    return processMetaData(metaData);
}
Also used : DefaultMutableMavenModuleResolveMetadata(org.gradle.internal.component.external.model.DefaultMutableMavenModuleResolveMetadata) MutableMavenModuleResolveMetadata(org.gradle.internal.component.external.model.MutableMavenModuleResolveMetadata) DefaultModuleComponentIdentifier(org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier)

Example 2 with ModuleComponentIdentifier

use of org.gradle.api.artifacts.component.ModuleComponentIdentifier in project gradle by gradle.

the class IvyXmlModuleDescriptorWriter method printInfoTag.

private static void printInfoTag(ModuleDescriptorState descriptor, SimpleXmlWriter writer) throws IOException {
    ModuleComponentIdentifier id = descriptor.getComponentIdentifier();
    writer.startElement("info");
    writer.attribute("organisation", id.getGroup());
    writer.attribute("module", id.getModule());
    String branch = descriptor.getBranch();
    if (branch != null) {
        writer.attribute("branch", branch);
    }
    writer.attribute("revision", id.getVersion());
    writer.attribute("status", descriptor.getStatus());
    if (descriptor.isGenerated()) {
        writer.attribute("default", "true");
    }
    printUnusedContent(descriptor, writer);
    for (Map.Entry<NamespaceId, String> entry : descriptor.getExtraInfo().entrySet()) {
        if (entry.getValue() == null || entry.getValue().length() == 0) {
            continue;
        }
        NamespaceId namespaceId = entry.getKey();
        writer.startElement("ns:" + namespaceId.getName());
        writer.attribute("xmlns:ns", namespaceId.getNamespace());
        writer.characters(entry.getValue());
        writer.endElement();
    }
    writer.endElement();
}
Also used : ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) NamespaceId(org.gradle.api.internal.artifacts.ivyservice.NamespaceId) Map(java.util.Map)

Example 3 with ModuleComponentIdentifier

use of org.gradle.api.artifacts.component.ModuleComponentIdentifier in project gradle by gradle.

the class DefaultVersionedComponentChooser method selectNewestMatchingComponent.

public void selectNewestMatchingComponent(Collection<? extends ModuleComponentResolveState> versions, BuildableComponentSelectionResult result, ModuleVersionSelector requested) {
    VersionSelector requestedVersion = versionSelectorScheme.parseSelector(requested.getVersion());
    Collection<SpecRuleAction<? super ComponentSelection>> rules = componentSelectionRules.getRules();
    for (ModuleComponentResolveState candidate : sortLatestFirst(versions)) {
        MetadataProvider metadataProvider = createMetadataProvider(candidate);
        boolean versionMatches = versionMatches(requestedVersion, candidate, metadataProvider);
        if (!metadataProvider.isUsable()) {
            applyTo(metadataProvider, result);
            return;
        }
        if (!versionMatches) {
            result.notMatched(candidate.getVersion());
            continue;
        }
        ModuleComponentIdentifier candidateIdentifier = candidate.getId();
        boolean accepted = !isRejectedByRules(candidateIdentifier, rules, metadataProvider);
        if (!metadataProvider.isUsable()) {
            applyTo(metadataProvider, result);
            return;
        }
        if (accepted) {
            result.matches(candidateIdentifier);
            return;
        }
        result.rejected(candidate.getVersion());
        if (requestedVersion.matchesUniqueVersion()) {
            // Only consider one candidate
            break;
        }
    }
    result.noMatchFound();
}
Also used : SpecRuleAction(org.gradle.internal.rules.SpecRuleAction) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) ComponentSelection(org.gradle.api.artifacts.ComponentSelection) DefaultComponentSelection(org.gradle.api.internal.artifacts.DefaultComponentSelection) VersionSelector(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.strategy.VersionSelector) ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector)

Example 4 with ModuleComponentIdentifier

use of org.gradle.api.artifacts.component.ModuleComponentIdentifier in project gradle by gradle.

the class DependencyResolverIvyPublisher method publish.

public void publish(IvyNormalizedPublication publication, PublicationAwareRepository repository) {
    ModuleVersionPublisher publisher = repository.createPublisher();
    IvyPublicationIdentity projectIdentity = publication.getProjectIdentity();
    ModuleComponentIdentifier moduleVersionIdentifier = DefaultModuleComponentIdentifier.newId(projectIdentity.getOrganisation(), projectIdentity.getModule(), projectIdentity.getRevision());
    // Use the legacy metadata type so that we can leverage `ModuleVersionPublisher.publish()`
    DefaultIvyModulePublishMetadata publishMetaData = new DefaultIvyModulePublishMetadata(moduleVersionIdentifier, "");
    for (IvyArtifact publishArtifact : publication.getArtifacts()) {
        publishMetaData.addArtifact(createIvyArtifact(publishArtifact), publishArtifact.getFile());
    }
    IvyArtifactName ivyDescriptor = new DefaultIvyArtifactName("ivy", "ivy", "xml");
    publishMetaData.addArtifact(ivyDescriptor, publication.getIvyDescriptorFile());
    File gradleModuleDescriptorFile = publication.getGradleModuleDescriptorFile();
    if (gradleModuleDescriptorFile != null && gradleModuleDescriptorFile.exists()) {
        // may not exist if experimental features are disabled
        IvyArtifactName gradleDescriptor = new DefaultIvyArtifactName(projectIdentity.getModule(), "json", "module");
        publishMetaData.addArtifact(gradleDescriptor, gradleModuleDescriptorFile);
    }
    publisher.publish(publishMetaData);
}
Also used : DefaultIvyModulePublishMetadata(org.gradle.internal.component.external.ivypublish.DefaultIvyModulePublishMetadata) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) DefaultModuleComponentIdentifier(org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) IvyArtifact(org.gradle.api.publish.ivy.IvyArtifact) File(java.io.File) ModuleVersionPublisher(org.gradle.api.internal.artifacts.ModuleVersionPublisher)

Example 5 with ModuleComponentIdentifier

use of org.gradle.api.artifacts.component.ModuleComponentIdentifier in project spring-security by spring-projects.

the class DependencyExcludesTests method currentVersionAndCandidateVersion.

private ComponentSelectionWithCurrent currentVersionAndCandidateVersion(ComponentSelection componentSelection, String currentVersion, String candidateVersion) {
    ModuleComponentIdentifier candidate = mock(ModuleComponentIdentifier.class);
    given(componentSelection.getCandidate()).willReturn(candidate);
    ComponentSelectionWithCurrent selection = new ComponentSelectionWithCurrent(currentVersion, componentSelection);
    given(candidate.getVersion()).willReturn(candidateVersion);
    given(componentSelection.getCandidate()).willReturn(candidate);
    return selection;
}
Also used : ComponentSelectionWithCurrent(com.github.benmanes.gradle.versions.updates.resolutionstrategy.ComponentSelectionWithCurrent) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier)

Aggregations

ModuleComponentIdentifier (org.gradle.api.artifacts.component.ModuleComponentIdentifier)47 DefaultModuleComponentIdentifier (org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier)13 ComponentIdentifier (org.gradle.api.artifacts.component.ComponentIdentifier)4 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)4 MavenUniqueSnapshotComponentIdentifier (org.gradle.api.internal.artifacts.repositories.resolver.MavenUniqueSnapshotComponentIdentifier)4 File (java.io.File)3 IOException (java.io.IOException)3 Map (java.util.Map)3 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)3 ComponentSelectionWithCurrent (com.github.benmanes.gradle.versions.updates.resolutionstrategy.ComponentSelectionWithCurrent)2 InputStream (java.io.InputStream)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)2 ComponentSelection (org.gradle.api.artifacts.ComponentSelection)2 ComponentSelector (org.gradle.api.artifacts.component.ComponentSelector)2 LibraryBinaryIdentifier (org.gradle.api.artifacts.component.LibraryBinaryIdentifier)2 DefaultComponentSelection (org.gradle.api.internal.artifacts.DefaultComponentSelection)2 DefaultProjectComponentIdentifier (org.gradle.api.internal.artifacts.DefaultProjectComponentIdentifier)2 NamespaceId (org.gradle.api.internal.artifacts.ivyservice.NamespaceId)2