Search in sources :

Example 1 with DefaultIvyModulePublishMetadata

use of org.gradle.internal.component.external.ivypublish.DefaultIvyModulePublishMetadata 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)

Aggregations

File (java.io.File)1 ModuleComponentIdentifier (org.gradle.api.artifacts.component.ModuleComponentIdentifier)1 ModuleVersionPublisher (org.gradle.api.internal.artifacts.ModuleVersionPublisher)1 IvyArtifact (org.gradle.api.publish.ivy.IvyArtifact)1 DefaultIvyModulePublishMetadata (org.gradle.internal.component.external.ivypublish.DefaultIvyModulePublishMetadata)1 DefaultModuleComponentIdentifier (org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier)1 DefaultIvyArtifactName (org.gradle.internal.component.model.DefaultIvyArtifactName)1 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)1