Search in sources :

Example 1 with MavenUniqueSnapshotComponentIdentifier

use of org.gradle.api.internal.artifacts.repositories.resolver.MavenUniqueSnapshotComponentIdentifier in project gradle by gradle.

the class ComponentIdentifierSerializer method write.

public void write(Encoder encoder, ComponentIdentifier value) throws IOException {
    if (value == null) {
        throw new IllegalArgumentException("Provided component identifier may not be null");
    }
    Implementation implementation = resolveImplementation(value);
    encoder.writeByte(implementation.getId());
    if (implementation == Implementation.MODULE) {
        ModuleComponentIdentifier moduleComponentIdentifier = (ModuleComponentIdentifier) value;
        encoder.writeString(moduleComponentIdentifier.getGroup());
        encoder.writeString(moduleComponentIdentifier.getModule());
        encoder.writeString(moduleComponentIdentifier.getVersion());
    } else if (implementation == Implementation.SNAPSHOT) {
        MavenUniqueSnapshotComponentIdentifier snapshotIdentifier = (MavenUniqueSnapshotComponentIdentifier) value;
        encoder.writeString(snapshotIdentifier.getGroup());
        encoder.writeString(snapshotIdentifier.getModule());
        encoder.writeString(snapshotIdentifier.getVersion());
        encoder.writeString(snapshotIdentifier.getTimestamp());
    } else if (implementation == Implementation.BUILD) {
        ProjectComponentIdentifier projectComponentIdentifier = (ProjectComponentIdentifier) value;
        BuildIdentifier build = projectComponentIdentifier.getBuild();
        buildIdentifierSerializer.write(encoder, build);
        encoder.writeString(projectComponentIdentifier.getProjectPath());
    } else if (implementation == Implementation.LIBRARY) {
        LibraryBinaryIdentifier libraryIdentifier = (LibraryBinaryIdentifier) value;
        encoder.writeString(libraryIdentifier.getProjectPath());
        encoder.writeString(libraryIdentifier.getLibraryName());
        encoder.writeString(libraryIdentifier.getVariant());
    } else {
        throw new IllegalStateException("Unsupported implementation type: " + implementation);
    }
}
Also used : MavenUniqueSnapshotComponentIdentifier(org.gradle.api.internal.artifacts.repositories.resolver.MavenUniqueSnapshotComponentIdentifier) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) DefaultModuleComponentIdentifier(org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier) BuildIdentifier(org.gradle.api.artifacts.component.BuildIdentifier) LibraryBinaryIdentifier(org.gradle.api.artifacts.component.LibraryBinaryIdentifier) DefaultLibraryBinaryIdentifier(org.gradle.internal.component.local.model.DefaultLibraryBinaryIdentifier) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier) DefaultProjectComponentIdentifier(org.gradle.internal.component.local.model.DefaultProjectComponentIdentifier)

Example 2 with MavenUniqueSnapshotComponentIdentifier

use of org.gradle.api.internal.artifacts.repositories.resolver.MavenUniqueSnapshotComponentIdentifier in project gradle by gradle.

the class DefaultMavenPomMetadataSource method parseMetaDataFromResource.

protected MutableMavenModuleResolveMetadata parseMetaDataFromResource(ModuleComponentIdentifier moduleComponentIdentifier, LocallyAvailableExternalResource cachedResource, ExternalResourceArtifactResolver artifactResolver, DescriptorParseContext context, String repoName) {
    MutableMavenModuleResolveMetadata metaData = pomParser.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);
        metaData.setId(snapshotComponentIdentifier);
        metaData.setSnapshotTimestamp(snapshotComponentIdentifier.getTimestamp());
    } else {
        checkMetadataConsistency(moduleComponentIdentifier, metaData);
    }
    MutableMavenModuleResolveMetadata result = MavenResolver.processMetaData(metaData);
    if (validator.isUsableModule(repoName, result, artifactResolver)) {
        return result;
    }
    return null;
}
Also used : MutableMavenModuleResolveMetadata(org.gradle.internal.component.external.model.MutableMavenModuleResolveMetadata) MavenUniqueSnapshotComponentIdentifier(org.gradle.api.internal.artifacts.repositories.resolver.MavenUniqueSnapshotComponentIdentifier)

Aggregations

MavenUniqueSnapshotComponentIdentifier (org.gradle.api.internal.artifacts.repositories.resolver.MavenUniqueSnapshotComponentIdentifier)2 BuildIdentifier (org.gradle.api.artifacts.component.BuildIdentifier)1 LibraryBinaryIdentifier (org.gradle.api.artifacts.component.LibraryBinaryIdentifier)1 ModuleComponentIdentifier (org.gradle.api.artifacts.component.ModuleComponentIdentifier)1 ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)1 DefaultModuleComponentIdentifier (org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier)1 MutableMavenModuleResolveMetadata (org.gradle.internal.component.external.model.MutableMavenModuleResolveMetadata)1 DefaultLibraryBinaryIdentifier (org.gradle.internal.component.local.model.DefaultLibraryBinaryIdentifier)1 DefaultProjectComponentIdentifier (org.gradle.internal.component.local.model.DefaultProjectComponentIdentifier)1