Skip to content

Commit

Permalink
Refactor Maven artifact processing
Browse files Browse the repository at this point in the history
This now leverages the APIs on MavenNormalizedPublication to make sure
all artifacts are published.
This fixes for example the publication of Gradle Module Metadata,
stable since Gradle 5.3 and produced by default with Gradle 6.0.

Fixes jfrog#247
  • Loading branch information
ljacomet committed Oct 9, 2019
1 parent c1a1e5a commit 04e8afd
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.gradle.api.publish.ivy.internal.publisher.IvyNormalizedPublication;
import org.gradle.api.publish.ivy.internal.publisher.IvyPublicationIdentity;
import org.gradle.api.publish.maven.MavenArtifact;
import org.gradle.api.publish.maven.MavenArtifactSet;
import org.gradle.api.publish.maven.MavenPublication;
import org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal;
import org.gradle.api.publish.maven.internal.publisher.MavenNormalizedPublication;
Expand Down Expand Up @@ -249,22 +248,29 @@ public Set<GradleDeployDetails> getArtifactDeployDetails() {
addMavenArtifactToDeployDetails(deployDetails, publicationName, builder, artifactInfo, mavenPublication);
}
}
// Second adding the main artifact of the publication
createPublishArtifactInfoAndAddToDeployDetails(mavenNormalizedPublication.getMainArtifact(), deployDetails, mavenPublication, publicationName);

MavenArtifactSet artifacts = mavenPublication.getArtifacts();
// Third adding all additional artifacts - includes Gradle Module Metadata when produced
Set<MavenArtifact> artifacts = mavenNormalizedPublication.getAdditionalArtifacts();
for (MavenArtifact artifact : artifacts) {
File file = artifact.getFile();
DeployDetails.Builder builder = createBuilder(file, publicationName);
if (builder == null) continue;
PublishArtifactInfo artifactInfo = new PublishArtifactInfo(
mavenPublication.getArtifactId(), artifact.getExtension(),
artifact.getExtension(), artifact.getClassifier(),
file);
addMavenArtifactToDeployDetails(deployDetails, publicationName, builder, artifactInfo, mavenPublication);
createPublishArtifactInfoAndAddToDeployDetails(artifact, deployDetails, mavenPublication, publicationName);
}
}
return deployDetails;
}

private void createPublishArtifactInfoAndAddToDeployDetails(MavenArtifact artifact, Set<GradleDeployDetails> deployDetails, MavenPublication mavenPublication, String publicationName) {
File file = artifact.getFile();
DeployDetails.Builder builder = createBuilder(file, publicationName);
if (builder == null) return;
PublishArtifactInfo artifactInfo = new PublishArtifactInfo(
mavenPublication.getArtifactId(), artifact.getExtension(),
artifact.getExtension(), artifact.getClassifier(),
file);
addMavenArtifactToDeployDetails(deployDetails, publicationName, builder, artifactInfo, mavenPublication);
}

private File getIvyDescriptorFile(IvyNormalizedPublication ivy) {
try {
return ivy.getIvyDescriptorFile();
Expand Down

0 comments on commit 04e8afd

Please sign in to comment.