|
|
|
@ -17,9 +17,16 @@ |
|
|
|
package org.springframework.boot.gradle.plugin; |
|
|
|
package org.springframework.boot.gradle.plugin; |
|
|
|
|
|
|
|
|
|
|
|
import org.gradle.api.Buildable; |
|
|
|
import org.gradle.api.Buildable; |
|
|
|
|
|
|
|
import org.gradle.api.artifacts.Configuration; |
|
|
|
import org.gradle.api.artifacts.PublishArtifact; |
|
|
|
import org.gradle.api.artifacts.PublishArtifact; |
|
|
|
import org.gradle.api.artifacts.PublishArtifactSet; |
|
|
|
import org.gradle.api.artifacts.PublishArtifactSet; |
|
|
|
|
|
|
|
import org.gradle.api.artifacts.dsl.ArtifactHandler; |
|
|
|
import org.gradle.api.tasks.TaskDependency; |
|
|
|
import org.gradle.api.tasks.TaskDependency; |
|
|
|
|
|
|
|
import org.gradle.api.tasks.TaskProvider; |
|
|
|
|
|
|
|
import org.gradle.api.tasks.bundling.Jar; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.gradle.tasks.bundling.BootJar; |
|
|
|
|
|
|
|
import org.springframework.boot.gradle.tasks.bundling.BootWar; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* A wrapper for a {@link PublishArtifactSet} that ensures that only a single artifact is |
|
|
|
* A wrapper for a {@link PublishArtifactSet} that ensures that only a single artifact is |
|
|
|
@ -30,33 +37,35 @@ import org.gradle.api.tasks.TaskDependency; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
final class SinglePublishedArtifact implements Buildable { |
|
|
|
final class SinglePublishedArtifact implements Buildable { |
|
|
|
|
|
|
|
|
|
|
|
private final PublishArtifactSet artifacts; |
|
|
|
private final Configuration configuration; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final ArtifactHandler handler; |
|
|
|
|
|
|
|
|
|
|
|
private PublishArtifact currentArtifact; |
|
|
|
private PublishArtifact currentArtifact; |
|
|
|
|
|
|
|
|
|
|
|
SinglePublishedArtifact(PublishArtifactSet artifacts) { |
|
|
|
SinglePublishedArtifact(Configuration configuration, ArtifactHandler handler) { |
|
|
|
this.artifacts = artifacts; |
|
|
|
this.configuration = configuration; |
|
|
|
|
|
|
|
this.handler = handler; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void addWarCandidate(PublishArtifact candidate) { |
|
|
|
void addWarCandidate(TaskProvider<BootWar> candidate) { |
|
|
|
add(candidate); |
|
|
|
add(candidate); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void addJarCandidate(PublishArtifact candidate) { |
|
|
|
void addJarCandidate(TaskProvider<BootJar> candidate) { |
|
|
|
if (this.currentArtifact == null) { |
|
|
|
if (this.currentArtifact == null) { |
|
|
|
add(candidate); |
|
|
|
add(candidate); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void add(PublishArtifact artifact) { |
|
|
|
private void add(TaskProvider<? extends Jar> artifact) { |
|
|
|
this.artifacts.remove(this.currentArtifact); |
|
|
|
this.configuration.getArtifacts().remove(this.currentArtifact); |
|
|
|
this.artifacts.add(artifact); |
|
|
|
this.currentArtifact = this.handler.add(this.configuration.getName(), artifact); |
|
|
|
this.currentArtifact = artifact; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public TaskDependency getBuildDependencies() { |
|
|
|
public TaskDependency getBuildDependencies() { |
|
|
|
return this.artifacts.getBuildDependencies(); |
|
|
|
return this.configuration.getArtifacts().getBuildDependencies(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|