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());
}
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());
}
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()));
}
}
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);
}
}
Aggregations