use of org.jfrog.gradle.plugin.artifactory.extractor.PublishArtifactInfo in project build-info by JFrogDev.
the class TaskHelperConfigurations method getIvyDescriptorDeployDetails.
private GradleDeployDetails getIvyDescriptorDeployDetails() {
ArtifactoryClientConfiguration.PublisherHandler publisher = ArtifactoryPluginUtil.getPublisherHandler(getProject());
DeployDetails.Builder artifactBuilder = new DeployDetails.Builder().file(artifactoryTask.ivyDescriptor);
try {
Map<String, String> checksums = FileChecksumCalculator.calculateChecksums(artifactoryTask.ivyDescriptor, "MD5", "SHA1");
artifactBuilder.md5(checksums.get("MD5")).sha1(checksums.get("SHA1"));
} catch (Exception e) {
throw new GradleException("Failed to calculate checksums for artifact: " + artifactoryTask.ivyDescriptor.getAbsolutePath(), e);
}
String gid = getProject().getGroup().toString();
if (publisher.isM2Compatible()) {
gid = gid.replace(".", "/");
}
artifactBuilder.artifactPath(IvyPatternHelper.substitute(publisher.getIvyPattern(), gid, getModuleName(), getProject().getVersion().toString(), null, "ivy", "xml"));
artifactBuilder.targetRepository(publisher.getRepoKey());
PublishArtifactInfo artifactInfo = new PublishArtifactInfo(artifactoryTask.ivyDescriptor.getName(), "xml", "ivy", null, artifactoryTask.ivyDescriptor);
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.PublishArtifactInfo 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;
}
use of org.jfrog.gradle.plugin.artifactory.extractor.PublishArtifactInfo 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.PublishArtifactInfo 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());
}
Aggregations