Search in sources :

Example 16 with DefaultIvyArtifactName

use of org.gradle.internal.component.model.DefaultIvyArtifactName in project gradle by gradle.

the class AbstractIvyDependencyDescriptorFactory method convertArtifacts.

protected List<IvyArtifactName> convertArtifacts(Set<DependencyArtifact> dependencyArtifacts) {
    if (dependencyArtifacts.isEmpty()) {
        return Collections.emptyList();
    }
    ImmutableList.Builder<IvyArtifactName> names = ImmutableList.builder();
    for (DependencyArtifact dependencyArtifact : dependencyArtifacts) {
        DefaultIvyArtifactName name = new DefaultIvyArtifactName(dependencyArtifact.getName(), dependencyArtifact.getType(), getExtension(dependencyArtifact), dependencyArtifact.getClassifier());
        names.add(name);
    }
    return names.build();
}
Also used : DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) DependencyArtifact(org.gradle.api.artifacts.DependencyArtifact) ImmutableList(com.google.common.collect.ImmutableList) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName)

Example 17 with DefaultIvyArtifactName

use of org.gradle.internal.component.model.DefaultIvyArtifactName in project gradle by gradle.

the class ComponentArtifactMetadataSerializer method read.

@Override
public ComponentArtifactMetadata read(Decoder decoder) throws Exception {
    ModuleComponentIdentifier componentIdentifier = (ModuleComponentIdentifier) componentIdentifierSerializer.read(decoder);
    String artifactName = decoder.readString();
    String type = decoder.readString();
    String extension = decoder.readNullableString();
    String classifier = decoder.readNullableString();
    return new DefaultModuleComponentArtifactMetadata(componentIdentifier, new DefaultIvyArtifactName(artifactName, type, extension, classifier));
}
Also used : DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) DefaultModuleComponentArtifactMetadata(org.gradle.internal.component.external.model.DefaultModuleComponentArtifactMetadata)

Example 18 with DefaultIvyArtifactName

use of org.gradle.internal.component.model.DefaultIvyArtifactName in project gradle by gradle.

the class DefaultGradleModuleMetadataSource method create.

@Override
public MutableModuleComponentResolveMetadata create(String repositoryName, ComponentResolvers componentResolvers, ModuleComponentIdentifier moduleComponentIdentifier, ComponentOverrideMetadata prescribedMetaData, ExternalResourceArtifactResolver artifactResolver, BuildableModuleComponentMetaDataResolveResult result) {
    DefaultIvyArtifactName moduleMetadataArtifact = new DefaultIvyArtifactName(moduleComponentIdentifier.getModule(), "module", "module");
    DefaultModuleComponentArtifactMetadata artifactId = new DefaultModuleComponentArtifactMetadata(moduleComponentIdentifier, moduleMetadataArtifact);
    LocallyAvailableExternalResource gradleMetadataArtifact = artifactResolver.resolveArtifact(artifactId, result);
    if (gradleMetadataArtifact != null) {
        MutableModuleComponentResolveMetadata metaDataFromResource = mutableModuleMetadataFactory.createForGradleModuleMetadata(moduleComponentIdentifier);
        metadataParser.parse(gradleMetadataArtifact, metaDataFromResource);
        validateGradleMetadata(metaDataFromResource);
        createModuleSources(artifactId, gradleMetadataArtifact, metaDataFromResource);
        metadataCompatibilityConverter.process(metaDataFromResource);
        return metaDataFromResource;
    }
    return null;
}
Also used : DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) MutableModuleComponentResolveMetadata(org.gradle.internal.component.external.model.MutableModuleComponentResolveMetadata) DefaultModuleComponentArtifactMetadata(org.gradle.internal.component.external.model.DefaultModuleComponentArtifactMetadata) LocallyAvailableExternalResource(org.gradle.internal.resource.local.LocallyAvailableExternalResource)

Example 19 with DefaultIvyArtifactName

use of org.gradle.internal.component.model.DefaultIvyArtifactName in project gradle by gradle.

the class DefaultArtifactPublisher method publish.

@Override
public void publish(final Iterable<? extends PublicationAwareRepository> repositories, final Module module, final Configuration configuration, final File descriptor) throws PublishException {
    Set<ConfigurationInternal> allConfigurations = Cast.uncheckedCast(configuration.getAll());
    Set<ConfigurationInternal> configurationsToPublish = Cast.uncheckedCast(configuration.getHierarchy());
    // Will create `ivy.xml` even for Maven publishing! (as long as `Upload.uploadDescriptor == true`)
    if (descriptor != null) {
        // Convert once, in order to write the Ivy descriptor with _all_ configurations
        DefaultIvyModulePublishMetadata publishMetaData = toPublishMetaData(module, allConfigurations, false);
        ivyModuleDescriptorWriter.write(publishMetaData, descriptor);
    }
    // Convert a second time with only the published configurations: this ensures that the correct artifacts are included
    DefaultIvyModulePublishMetadata publishMetaData = toPublishMetaData(module, configurationsToPublish, true);
    if (descriptor != null) {
        IvyArtifactName artifact = new DefaultIvyArtifactName("ivy", "ivy", "xml");
        publishMetaData.addArtifact(artifact, descriptor);
    }
    for (PublicationAwareRepository repository : repositories) {
        ModuleVersionPublisher publisher = repository.createPublisher();
        LOGGER.info("Publishing to {}", publisher);
        publisher.publish(publishMetaData);
    }
}
Also used : DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) PublicationAwareRepository(org.gradle.api.internal.artifacts.repositories.PublicationAwareRepository) ConfigurationInternal(org.gradle.api.internal.artifacts.configurations.ConfigurationInternal) ModuleVersionPublisher(org.gradle.api.internal.artifacts.ModuleVersionPublisher)

Example 20 with DefaultIvyArtifactName

use of org.gradle.internal.component.model.DefaultIvyArtifactName in project gradle by gradle.

the class AbstractRealisedModuleResolveMetadataSerializationHelper method readFiles.

protected ImmutableList<? extends ModuleComponentArtifactMetadata> readFiles(Decoder decoder, ModuleComponentIdentifier componentIdentifier) throws IOException {
    ImmutableList.Builder<ModuleComponentArtifactMetadata> artifacts = new ImmutableList.Builder<>();
    int artifactsCount = decoder.readSmallInt();
    for (int i = 0; i < artifactsCount; i++) {
        String name = decoder.readString();
        String type = decoder.readString();
        String extension = decoder.readNullableString();
        String classifier = decoder.readNullableString();
        String timestamp = decoder.readNullableString();
        String version;
        ModuleComponentIdentifier cid = componentIdentifier;
        if (timestamp != null) {
            version = decoder.readString();
            cid = new MavenUniqueSnapshotComponentIdentifier(componentIdentifier.getModuleIdentifier(), version, timestamp);
        }
        boolean alternativeArtifact = decoder.readBoolean();
        DefaultIvyArtifactName alternative = null;
        if (alternativeArtifact) {
            String altName = decoder.readString();
            String altType = decoder.readString();
            String altExtension = decoder.readNullableString();
            String altClassifier = decoder.readNullableString();
            alternative = new DefaultIvyArtifactName(altName, altType, altExtension, altClassifier);
        }
        boolean optional = decoder.readBoolean();
        if (optional) {
            artifacts.add(new ModuleComponentOptionalArtifactMetadata(cid, new DefaultIvyArtifactName(name, type, extension, classifier)));
        } else {
            if (alternativeArtifact) {
                artifacts.add(new DefaultModuleComponentArtifactMetadata(cid, new DefaultIvyArtifactName(name, type, extension, classifier), new DefaultModuleComponentArtifactMetadata(cid, alternative)));
            } else {
                artifacts.add(new DefaultModuleComponentArtifactMetadata(cid, new DefaultIvyArtifactName(name, type, extension, classifier)));
            }
        }
    }
    int filesCount = decoder.readSmallInt();
    for (int i = 0; i < filesCount; i++) {
        String fileName = decoder.readString();
        String uri = decoder.readString();
        artifacts.add(new UrlBackedArtifactMetadata(componentIdentifier, fileName, uri));
    }
    return artifacts.build();
}
Also used : DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) ImmutableList(com.google.common.collect.ImmutableList) MavenUniqueSnapshotComponentIdentifier(org.gradle.api.internal.artifacts.repositories.resolver.MavenUniqueSnapshotComponentIdentifier) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier)

Aggregations

DefaultIvyArtifactName (org.gradle.internal.component.model.DefaultIvyArtifactName)20 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)13 DefaultExclude (org.gradle.internal.component.external.descriptor.DefaultExclude)4 ModuleComponentIdentifier (org.gradle.api.artifacts.component.ModuleComponentIdentifier)3 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)3 ModuleVersionPublisher (org.gradle.api.internal.artifacts.ModuleVersionPublisher)3 DefaultImmutableVersionConstraint (org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint)3 Artifact (org.gradle.internal.component.external.descriptor.Artifact)3 DefaultModuleComponentArtifactMetadata (org.gradle.internal.component.external.model.DefaultModuleComponentArtifactMetadata)3 DefaultModuleComponentSelector (org.gradle.internal.component.external.model.DefaultModuleComponentSelector)3 ImmutableList (com.google.common.collect.ImmutableList)2 List (java.util.List)2 Map (java.util.Map)2 DependencyArtifactDescriptor (org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor)2 ExcludeRule (org.apache.ivy.core.module.descriptor.ExcludeRule)2 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)2 ModuleIdentifier (org.gradle.api.artifacts.ModuleIdentifier)2 ConfigurationInternal (org.gradle.api.internal.artifacts.configurations.ConfigurationInternal)2 PublicationAwareRepository (org.gradle.api.internal.artifacts.repositories.PublicationAwareRepository)2 MavenScope (org.gradle.internal.component.external.descriptor.MavenScope)2