Search in sources :

Example 1 with ModuleVersionPublisher

use of org.gradle.api.internal.artifacts.ModuleVersionPublisher in project gradle by gradle.

the class DefaultIvyDependencyPublisher method publish.

public void publish(List<ModuleVersionPublisher> publishResolvers, IvyModulePublishMetadata publishMetaData) {
    try {
        // Make a copy of the publication and filter missing artifacts
        DefaultIvyModulePublishMetadata publication = new DefaultIvyModulePublishMetadata(publishMetaData.getId(), publishMetaData.getModuleDescriptor());
        for (IvyModuleArtifactPublishMetadata artifact : publishMetaData.getArtifacts()) {
            addPublishedArtifact(artifact, publication);
        }
        for (ModuleVersionPublisher publisher : publishResolvers) {
            LOGGER.info("Publishing to {}", publisher);
            publisher.publish(publication);
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : DefaultIvyModulePublishMetadata(org.gradle.internal.component.external.model.DefaultIvyModulePublishMetadata) IvyModuleArtifactPublishMetadata(org.gradle.internal.component.external.model.IvyModuleArtifactPublishMetadata) UncheckedIOException(org.gradle.api.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(org.gradle.api.UncheckedIOException) ModuleVersionPublisher(org.gradle.api.internal.artifacts.ModuleVersionPublisher)

Example 2 with ModuleVersionPublisher

use of org.gradle.api.internal.artifacts.ModuleVersionPublisher 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 3 with ModuleVersionPublisher

use of org.gradle.api.internal.artifacts.ModuleVersionPublisher in project gradle by gradle.

the class IvyBackedArtifactPublisher method publish.

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());
    if (descriptor != null) {
        // Convert once, in order to write the Ivy descriptor with _all_ configurations
        IvyModulePublishMetadata publishMetaData = toPublishMetaData(module, allConfigurations);
        validatePublishMetaData(publishMetaData);
        ivyModuleDescriptorWriter.write(publishMetaData, descriptor);
    }
    // Convert a second time with only the published configurations: this ensures that the correct artifacts are included
    BuildableIvyModulePublishMetadata publishMetaData = toPublishMetaData(module, configurationsToPublish);
    if (descriptor != null) {
        IvyArtifactName artifact = new DefaultIvyArtifactName("ivy", "ivy", "xml");
        publishMetaData.addArtifact(artifact, descriptor);
    }
    List<ModuleVersionPublisher> publishResolvers = new ArrayList<ModuleVersionPublisher>();
    for (PublicationAwareRepository repository : repositories) {
        ModuleVersionPublisher publisher = repository.createPublisher();
        publishResolvers.add(publisher);
    }
    dependencyPublisher.publish(publishResolvers, publishMetaData);
}
Also used : DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) ArrayList(java.util.ArrayList) BuildableIvyModulePublishMetadata(org.gradle.internal.component.external.model.BuildableIvyModulePublishMetadata) PublicationAwareRepository(org.gradle.api.internal.artifacts.repositories.PublicationAwareRepository) IvyModulePublishMetadata(org.gradle.internal.component.external.model.IvyModulePublishMetadata) BuildableIvyModulePublishMetadata(org.gradle.internal.component.external.model.BuildableIvyModulePublishMetadata) DefaultIvyModulePublishMetadata(org.gradle.internal.component.external.model.DefaultIvyModulePublishMetadata) ConfigurationInternal(org.gradle.api.internal.artifacts.configurations.ConfigurationInternal) ModuleVersionPublisher(org.gradle.api.internal.artifacts.ModuleVersionPublisher)

Example 4 with ModuleVersionPublisher

use of org.gradle.api.internal.artifacts.ModuleVersionPublisher 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)

Aggregations

ModuleVersionPublisher (org.gradle.api.internal.artifacts.ModuleVersionPublisher)4 DefaultIvyArtifactName (org.gradle.internal.component.model.DefaultIvyArtifactName)3 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)3 ConfigurationInternal (org.gradle.api.internal.artifacts.configurations.ConfigurationInternal)2 PublicationAwareRepository (org.gradle.api.internal.artifacts.repositories.PublicationAwareRepository)2 DefaultIvyModulePublishMetadata (org.gradle.internal.component.external.model.DefaultIvyModulePublishMetadata)2 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 UncheckedIOException (org.gradle.api.UncheckedIOException)1 ModuleComponentIdentifier (org.gradle.api.artifacts.component.ModuleComponentIdentifier)1 IvyArtifact (org.gradle.api.publish.ivy.IvyArtifact)1 DefaultIvyModulePublishMetadata (org.gradle.internal.component.external.ivypublish.DefaultIvyModulePublishMetadata)1 BuildableIvyModulePublishMetadata (org.gradle.internal.component.external.model.BuildableIvyModulePublishMetadata)1 DefaultModuleComponentIdentifier (org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier)1 IvyModuleArtifactPublishMetadata (org.gradle.internal.component.external.model.IvyModuleArtifactPublishMetadata)1 IvyModulePublishMetadata (org.gradle.internal.component.external.model.IvyModulePublishMetadata)1