From 5e5b1875649e2ecfcb7f1fdd0460f05917349f57 Mon Sep 17 00:00:00 2001 From: Louis Jacomet Date: Wed, 16 Oct 2019 19:07:24 +0200 Subject: [PATCH] Fix potential NPE in Maven publication A Maven publication does not always have a main artifact. Issue #247 --- .../artifactory/task/helper/TaskHelperPublications.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build-info-extractor-gradle/src/main/groovy/org/jfrog/gradle/plugin/artifactory/task/helper/TaskHelperPublications.java b/build-info-extractor-gradle/src/main/groovy/org/jfrog/gradle/plugin/artifactory/task/helper/TaskHelperPublications.java index 73abb7da3..78376e5b4 100644 --- a/build-info-extractor-gradle/src/main/groovy/org/jfrog/gradle/plugin/artifactory/task/helper/TaskHelperPublications.java +++ b/build-info-extractor-gradle/src/main/groovy/org/jfrog/gradle/plugin/artifactory/task/helper/TaskHelperPublications.java @@ -248,8 +248,10 @@ public Set getArtifactDeployDetails() { addMavenArtifactToDeployDetails(deployDetails, publicationName, builder, artifactInfo, mavenPublication); } } - // Second adding the main artifact of the publication - createPublishArtifactInfoAndAddToDeployDetails(mavenNormalizedPublication.getMainArtifact(), deployDetails, mavenPublication, publicationName); + // Second adding the main artifact of the publication, if present + if (mavenNormalizedPublication.getMainArtifact() != null) { + createPublishArtifactInfoAndAddToDeployDetails(mavenNormalizedPublication.getMainArtifact(), deployDetails, mavenPublication, publicationName); + } // Third adding all additional artifacts - includes Gradle Module Metadata when produced Set artifacts = mavenNormalizedPublication.getAdditionalArtifacts();