Search in sources :

Example 1 with PublicationAwareRepository

use of org.gradle.api.internal.artifacts.repositories.PublicationAwareRepository 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 2 with PublicationAwareRepository

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

the class Upload method upload.

@TaskAction
protected void upload() {
    getLogger().info("Publishing configuration: {}", configuration);
    DeprecationLogger.deprecateTaskType(Upload.class, getPath()).willBeRemovedInGradle8().withUpgradeGuideSection(7, "upload_task_deprecation").nagUser();
    Module module = ((ConfigurationInternal) configuration).getModule();
    ArtifactPublisher artifactPublisher = getPublicationServices().createArtifactPublisher();
    File descriptorDestination = isUploadDescriptor() ? getDescriptorDestination() : null;
    List<PublicationAwareRepository> publishRepositories = collect(getRepositories(), Transformers.cast(PublicationAwareRepository.class));
    try {
        artifactPublisher.publish(publishRepositories, module, configuration, descriptorDestination);
    } catch (Exception e) {
        throw new PublishException(String.format("Could not publish configuration '%s'", configuration.getName()), e);
    }
}
Also used : ArtifactPublisher(org.gradle.api.internal.artifacts.ArtifactPublisher) PublicationAwareRepository(org.gradle.api.internal.artifacts.repositories.PublicationAwareRepository) PublishException(org.gradle.api.artifacts.PublishException) Module(org.gradle.api.internal.artifacts.Module) File(java.io.File) ConfigurationInternal(org.gradle.api.internal.artifacts.configurations.ConfigurationInternal) PublishException(org.gradle.api.artifacts.PublishException)

Example 3 with PublicationAwareRepository

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

ConfigurationInternal (org.gradle.api.internal.artifacts.configurations.ConfigurationInternal)3 PublicationAwareRepository (org.gradle.api.internal.artifacts.repositories.PublicationAwareRepository)3 ModuleVersionPublisher (org.gradle.api.internal.artifacts.ModuleVersionPublisher)2 DefaultIvyArtifactName (org.gradle.internal.component.model.DefaultIvyArtifactName)2 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 PublishException (org.gradle.api.artifacts.PublishException)1 ArtifactPublisher (org.gradle.api.internal.artifacts.ArtifactPublisher)1 Module (org.gradle.api.internal.artifacts.Module)1 BuildableIvyModulePublishMetadata (org.gradle.internal.component.external.model.BuildableIvyModulePublishMetadata)1 DefaultIvyModulePublishMetadata (org.gradle.internal.component.external.model.DefaultIvyModulePublishMetadata)1 IvyModulePublishMetadata (org.gradle.internal.component.external.model.IvyModulePublishMetadata)1