Search in sources :

Example 6 with GradleDeployDetails

use of org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails in project build-info by JFrogDev.

the class TaskHelperConfigurations method getMavenDeployDetails.

private GradleDeployDetails getMavenDeployDetails() {
    ArtifactoryClientConfiguration.PublisherHandler publisher = ArtifactoryPluginUtil.getPublisherHandler(getProject());
    DeployDetails.Builder artifactBuilder = new DeployDetails.Builder().file(artifactoryTask.mavenDescriptor);
    try {
        Map<String, String> checksums = FileChecksumCalculator.calculateChecksums(artifactoryTask.mavenDescriptor, "MD5", "SHA1");
        artifactBuilder.md5(checksums.get("MD5")).sha1(checksums.get("SHA1"));
    } catch (Exception e) {
        throw new GradleException("Failed to calculate checksums for artifact: " + artifactoryTask.mavenDescriptor.getAbsolutePath(), e);
    }
    // for pom files always enforce the M2 pattern
    artifactBuilder.artifactPath(IvyPatternHelper.substitute(LayoutPatterns.M2_PATTERN, getProject().getGroup().toString().replace(".", "/"), getModuleName(), getProject().getVersion().toString(), null, "pom", "pom"));
    artifactBuilder.targetRepository(publisher.getRepoKey());
    PublishArtifactInfo artifactInfo = new PublishArtifactInfo(artifactoryTask.mavenDescriptor.getName(), "pom", "pom", null, artifactoryTask.mavenDescriptor);
    Map<String, String> propsToAdd = getPropsToAdd(artifactInfo, null);
    artifactBuilder.addProperties(propsToAdd);
    return new GradleDeployDetails(artifactInfo, artifactBuilder.build(), getProject());
}
Also used : ArtifactoryClientConfiguration(org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration) DeployDetails(org.jfrog.build.client.DeployDetails) GradleDeployDetails(org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails) PublishArtifactInfo(org.jfrog.gradle.plugin.artifactory.extractor.PublishArtifactInfo) GradleException(org.gradle.api.GradleException) IOException(java.io.IOException) GradleException(org.gradle.api.GradleException) GradleDeployDetails(org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails)

Example 7 with GradleDeployDetails

use of org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails in project build-info by JFrogDev.

the class TaskHelperConfigurations method gradleDeployDetails.

private GradleDeployDetails gradleDeployDetails(PublishArtifact artifact, String configuration, @Nullable String artifactPath, @Nullable Set<String> processedFiles) {
    ArtifactoryClientConfiguration.PublisherHandler publisher = ArtifactoryPluginUtil.getPublisherHandler(getProject());
    if (publisher == null) {
        return null;
    }
    File file = artifact.getFile();
    if (processedFiles != null && processedFiles.contains(file.getAbsolutePath())) {
        return null;
    }
    if (!file.exists()) {
        throw new GradleException("File '" + file.getAbsolutePath() + "'" + " does not exists, and need to be published!");
    }
    if (processedFiles != null) {
        processedFiles.add(file.getAbsolutePath());
    }
    String revision = getProject().getVersion().toString();
    Map<String, String> extraTokens = Maps.newHashMap();
    if (StringUtils.isNotBlank(artifact.getClassifier())) {
        extraTokens.put("classifier", artifact.getClassifier());
    }
    String pattern = publisher.getIvyArtifactPattern();
    String gid = getProject().getGroup().toString();
    if (publisher.isM2Compatible()) {
        gid = gid.replace(".", "/");
    }
    DeployDetails.Builder deployDetailsBuilder = new DeployDetails.Builder().file(file);
    try {
        Map<String, String> checksums = FileChecksumCalculator.calculateChecksums(file, "MD5", "SHA1");
        deployDetailsBuilder.md5(checksums.get("MD5")).sha1(checksums.get("SHA1"));
    } catch (Exception e) {
        throw new GradleException("Failed to calculate checksums for artifact: " + file.getAbsolutePath(), e);
    }
    if (artifactPath != null) {
        deployDetailsBuilder.artifactPath(artifactPath);
    } else {
        deployDetailsBuilder.artifactPath(IvyPatternHelper.substitute(pattern, gid, getModuleName(), revision, artifact.getName(), artifact.getType(), artifact.getExtension(), configuration, extraTokens, null));
    }
    deployDetailsBuilder.targetRepository(publisher.getRepoKey());
    PublishArtifactInfo artifactInfo = new PublishArtifactInfo(artifact);
    Map<String, String> propsToAdd = getPropsToAdd(artifactInfo, configuration);
    deployDetailsBuilder.addProperties(propsToAdd);
    DeployDetails details = deployDetailsBuilder.build();
    return new GradleDeployDetails(artifactInfo, details, getProject());
}
Also used : ArtifactoryClientConfiguration(org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration) DeployDetails(org.jfrog.build.client.DeployDetails) GradleDeployDetails(org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails) PublishArtifactInfo(org.jfrog.gradle.plugin.artifactory.extractor.PublishArtifactInfo) GradleException(org.gradle.api.GradleException) File(java.io.File) IOException(java.io.IOException) GradleException(org.gradle.api.GradleException) GradleDeployDetails(org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails)

Example 8 with GradleDeployDetails

use of org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails in project build-info by JFrogDev.

the class TaskHelperPublications method addArtifactInfoToDeployDetails.

private void addArtifactInfoToDeployDetails(Set<GradleDeployDetails> deployDetails, String publicationName, DeployDetails.Builder builder, PublishArtifactInfo artifactInfo) {
    ArtifactoryClientConfiguration.PublisherHandler publisher = ArtifactoryPluginUtil.getPublisherHandler(getProject());
    if (publisher != null) {
        builder.targetRepository(publisher.getRepoKey());
        Map<String, String> propsToAdd = getPropsToAdd(artifactInfo, publicationName);
        builder.addProperties(propsToAdd);
        DeployDetails details = builder.build();
        deployDetails.add(new GradleDeployDetails(artifactInfo, details, getProject()));
    }
}
Also used : ArtifactoryClientConfiguration(org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration) DeployDetails(org.jfrog.build.client.DeployDetails) GradleDeployDetails(org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails) GradleDeployDetails(org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails)

Example 9 with GradleDeployDetails

use of org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails in project build-info by JFrogDev.

the class DeployTask method deployArtifacts.

private void deployArtifacts(Set<GradleDeployDetails> allDeployDetails, ArtifactoryBuildInfoClient client, IncludeExcludePatterns patterns) throws IOException {
    for (GradleDeployDetails detail : allDeployDetails) {
        DeployDetails deployDetails = detail.getDeployDetails();
        String artifactPath = deployDetails.getArtifactPath();
        if (PatternMatcher.pathConflicts(artifactPath, patterns)) {
            log.log(LogLevel.LIFECYCLE, "Skipping the deployment of '" + artifactPath + "' due to the defined include-exclude patterns.");
            continue;
        }
        client.deployArtifact(deployDetails);
    }
}
Also used : DeployDetails(org.jfrog.build.client.DeployDetails) GradleDeployDetails(org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails) GradleDeployDetails(org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails)

Aggregations

GradleDeployDetails (org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails)9 DeployDetails (org.jfrog.build.client.DeployDetails)7 ArtifactoryClientConfiguration (org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration)6 IOException (java.io.IOException)4 PublishArtifactInfo (org.jfrog.gradle.plugin.artifactory.extractor.PublishArtifactInfo)4 File (java.io.File)3 GradleException (org.gradle.api.GradleException)3 QName (javax.xml.namespace.QName)1 Configuration (org.gradle.api.artifacts.Configuration)1 PublishArtifact (org.gradle.api.artifacts.PublishArtifact)1 PublishArtifactSet (org.gradle.api.artifacts.PublishArtifactSet)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