Search in sources :

Example 1 with MavenNormalizedPublication

use of org.gradle.api.publish.maven.internal.publisher.MavenNormalizedPublication in project build-info by JFrogDev.

the class TaskHelperPublications method getArtifactDeployDetails.

public Set<GradleDeployDetails> getArtifactDeployDetails() {
    Set<GradleDeployDetails> deployDetails = Sets.newLinkedHashSet();
    if (!hasPublications()) {
        log.info("No publications to publish for project '{}'.", getProject().getPath());
        return deployDetails;
    }
    for (IvyPublication ivyPublication : ivyPublications) {
        String publicationName = ivyPublication.getName();
        if (!(ivyPublication instanceof IvyPublicationInternal)) {
            // TODO: Check how the descriptor file can be extracted without using asNormalisedPublication
            log.warn("Ivy publication name '{}' is of unsupported type '{}'!", publicationName, ivyPublication.getClass());
            continue;
        }
        IvyPublicationInternal ivyPublicationInternal = (IvyPublicationInternal) ivyPublication;
        IvyNormalizedPublication ivyNormalizedPublication = ivyPublicationInternal.asNormalisedPublication();
        IvyPublicationIdentity projectIdentity = ivyNormalizedPublication.getProjectIdentity();
        Map<QName, String> extraInfo = ivyPublication.getDescriptor().getExtraInfo().asMap();
        // First adding the Ivy descriptor (if the build is configured to add it):
        if (isPublishIvy()) {
            File file = getIvyDescriptorFile(ivyNormalizedPublication);
            DeployDetails.Builder builder = createBuilder(file, publicationName);
            if (builder != null) {
                PublishArtifactInfo artifactInfo = new PublishArtifactInfo(projectIdentity.getModule(), "xml", "ivy", null, extraInfo, file);
                addIvyArtifactToDeployDetails(deployDetails, publicationName, projectIdentity, builder, artifactInfo);
            }
        }
        IvyArtifactSet artifacts = ivyPublication.getArtifacts();
        for (IvyArtifact artifact : artifacts) {
            File file = artifact.getFile();
            DeployDetails.Builder builder = createBuilder(file, publicationName);
            if (builder == null)
                continue;
            PublishArtifactInfo artifactInfo = new PublishArtifactInfo(artifact.getName(), artifact.getExtension(), artifact.getType(), artifact.getClassifier(), extraInfo, file);
            addIvyArtifactToDeployDetails(deployDetails, publicationName, projectIdentity, builder, artifactInfo);
        }
    }
    for (MavenPublication mavenPublication : mavenPublications) {
        String publicationName = mavenPublication.getName();
        if (!(mavenPublication instanceof MavenPublicationInternal)) {
            // TODO: Check how the descriptor file can be extracted without using asNormalisedPublication
            log.warn("Maven publication name '{}' is of unsupported type '{}'!", publicationName, mavenPublication.getClass());
            continue;
        }
        MavenPublicationInternal mavenPublicationInternal = (MavenPublicationInternal) mavenPublication;
        MavenNormalizedPublication mavenNormalizedPublication = mavenPublicationInternal.asNormalisedPublication();
        MavenProjectIdentity projectIdentity = mavenNormalizedPublication.getProjectIdentity();
        // First adding the Maven descriptor (if the build is configured to add it):
        if (isPublishMaven()) {
            File file = mavenNormalizedPublication.getPomFile();
            DeployDetails.Builder builder = createBuilder(file, publicationName);
            if (builder != null) {
                PublishArtifactInfo artifactInfo = new PublishArtifactInfo(projectIdentity.getArtifactId(), "pom", "pom", null, file);
                addMavenArtifactToDeployDetails(deployDetails, publicationName, projectIdentity, builder, artifactInfo);
            }
        }
        MavenArtifactSet artifacts = mavenPublication.getArtifacts();
        for (MavenArtifact artifact : artifacts) {
            File file = artifact.getFile();
            DeployDetails.Builder builder = createBuilder(file, publicationName);
            if (builder == null)
                continue;
            PublishArtifactInfo artifactInfo = new PublishArtifactInfo(projectIdentity.getArtifactId(), artifact.getExtension(), artifact.getExtension(), artifact.getClassifier(), file);
            addMavenArtifactToDeployDetails(deployDetails, publicationName, projectIdentity, builder, artifactInfo);
        }
    }
    return deployDetails;
}
Also used : DeployDetails(org.jfrog.build.client.DeployDetails) GradleDeployDetails(org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails) PublishArtifactInfo(org.jfrog.gradle.plugin.artifactory.extractor.PublishArtifactInfo) QName(javax.xml.namespace.QName) MavenPublication(org.gradle.api.publish.maven.MavenPublication) MavenPublicationInternal(org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal) MavenProjectIdentity(org.gradle.api.publish.maven.internal.publisher.MavenProjectIdentity) IvyPublicationIdentity(org.gradle.api.publish.ivy.internal.publisher.IvyPublicationIdentity) MavenNormalizedPublication(org.gradle.api.publish.maven.internal.publisher.MavenNormalizedPublication) IvyArtifactSet(org.gradle.api.publish.ivy.IvyArtifactSet) GradleDeployDetails(org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails) IvyNormalizedPublication(org.gradle.api.publish.ivy.internal.publisher.IvyNormalizedPublication) IvyPublicationInternal(org.gradle.api.publish.ivy.internal.publication.IvyPublicationInternal) MavenArtifactSet(org.gradle.api.publish.maven.MavenArtifactSet) IvyArtifact(org.gradle.api.publish.ivy.IvyArtifact) File(java.io.File) MavenArtifact(org.gradle.api.publish.maven.MavenArtifact) IvyPublication(org.gradle.api.publish.ivy.IvyPublication)

Aggregations

File (java.io.File)1 QName (javax.xml.namespace.QName)1 IvyArtifact (org.gradle.api.publish.ivy.IvyArtifact)1 IvyArtifactSet (org.gradle.api.publish.ivy.IvyArtifactSet)1 IvyPublication (org.gradle.api.publish.ivy.IvyPublication)1 IvyPublicationInternal (org.gradle.api.publish.ivy.internal.publication.IvyPublicationInternal)1 IvyNormalizedPublication (org.gradle.api.publish.ivy.internal.publisher.IvyNormalizedPublication)1 IvyPublicationIdentity (org.gradle.api.publish.ivy.internal.publisher.IvyPublicationIdentity)1 MavenArtifact (org.gradle.api.publish.maven.MavenArtifact)1 MavenArtifactSet (org.gradle.api.publish.maven.MavenArtifactSet)1 MavenPublication (org.gradle.api.publish.maven.MavenPublication)1 MavenPublicationInternal (org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal)1 MavenNormalizedPublication (org.gradle.api.publish.maven.internal.publisher.MavenNormalizedPublication)1 MavenProjectIdentity (org.gradle.api.publish.maven.internal.publisher.MavenProjectIdentity)1 DeployDetails (org.jfrog.build.client.DeployDetails)1 GradleDeployDetails (org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails)1 PublishArtifactInfo (org.jfrog.gradle.plugin.artifactory.extractor.PublishArtifactInfo)1