Merge branch '2.5.x' into 2.6.x

Closes gh-30213
This commit is contained in:
Andy Wilkinson
2022-03-15 15:30:06 +00:00
12 changed files with 164 additions and 12 deletions

View File

@@ -133,7 +133,7 @@ final class JavaPluginAction implements PluginApplicationAction {
private void configureArtifactPublication(TaskProvider<BootJar> bootJar) {
LazyPublishArtifact artifact = new LazyPublishArtifact(bootJar);
this.singlePublishedArtifact.addCandidate(artifact);
this.singlePublishedArtifact.addJarCandidate(artifact);
}
private void configureBootRunTask(Project project) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,14 +38,22 @@ final class SinglePublishedArtifact implements Buildable {
this.artifacts = artifacts;
}
void addCandidate(PublishArtifact candidate) {
if (this.currentArtifact == null || "war".equals(candidate.getExtension())) {
this.artifacts.remove(this.currentArtifact);
this.artifacts.add(candidate);
this.currentArtifact = candidate;
void addWarCandidate(PublishArtifact candidate) {
add(candidate);
}
void addJarCandidate(PublishArtifact candidate) {
if (this.currentArtifact == null) {
add(candidate);
}
}
private void add(PublishArtifact artifact) {
this.artifacts.remove(this.currentArtifact);
this.artifacts.add(artifact);
this.currentArtifact = artifact;
}
@Override
public TaskDependency getBuildDependencies() {
return this.artifacts.getBuildDependencies();

View File

@@ -108,7 +108,7 @@ class WarPluginAction implements PluginApplicationAction {
private void configureArtifactPublication(TaskProvider<BootWar> bootWar) {
LazyPublishArtifact artifact = new LazyPublishArtifact(bootWar);
this.singlePublishedArtifact.addCandidate(artifact);
this.singlePublishedArtifact.addWarCandidate(artifact);
}
}