Skip to content

Commit 7d9d1b4

Browse files
authored
Gradle - skip uploading JAR if no jar produced in build (#538)
1 parent 48f7dcd commit 7d9d1b4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

build-info-extractor-gradle/src/main/groovy/org/jfrog/gradle/plugin/artifactory/task/helper/TaskHelperPublications.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,18 @@ public Set<GradleDeployDetails> getArtifactDeployDetails() {
255255
}
256256

257257
boolean legacy = false;
258-
Set<MavenArtifact> artifacts;
258+
Set<MavenArtifact> artifacts = new HashSet<>();
259259
try {
260260
// Gradle 5.0 and above:
261261
artifacts = mavenNormalizedPublication.getAdditionalArtifacts();
262262
// Second adding the main artifact of the publication, if present
263263
if (mavenNormalizedPublication.getMainArtifact() != null) {
264264
createPublishArtifactInfoAndAddToDeployDetails(mavenNormalizedPublication.getMainArtifact(), deployDetails, mavenPublication, publicationName);
265265
}
266+
} catch (IllegalStateException exception) {
267+
// The Jar task is disabled, and therefore getMainArtifact() threw an exception:
268+
// "Artifact api.jar wasn't produced by this build."
269+
log.warn("Illegal state detected at Maven publication '{}', {}: {}", publicationName, getProject(), exception.getMessage());
266270
} catch (NoSuchMethodError error) {
267271
// Compatibility with older versions of Gradle:
268272
artifacts = mavenNormalizedPublication.getAllArtifacts();

0 commit comments

Comments
 (0)