commit
6289104190
|
@ -48,6 +48,8 @@ public class AntoraContributorPlugin implements Plugin<Project> {
|
|||
|
||||
private final Project project;
|
||||
|
||||
private boolean publish;
|
||||
|
||||
@Inject
|
||||
public Contribution(String name, Project project) {
|
||||
this.name = name;
|
||||
|
@ -58,6 +60,10 @@ public class AntoraContributorPlugin implements Plugin<Project> {
|
|||
return this.name;
|
||||
}
|
||||
|
||||
public void publish() {
|
||||
this.publish = true;
|
||||
}
|
||||
|
||||
public void source() {
|
||||
new SourceContribution(this.project, this.name).produce();
|
||||
}
|
||||
|
@ -65,13 +71,13 @@ public class AntoraContributorPlugin implements Plugin<Project> {
|
|||
public void catalogContent(Action<CopySpec> action) {
|
||||
CopySpec copySpec = this.project.copySpec();
|
||||
action.execute(copySpec);
|
||||
new CatalogContentContribution(this.project, this.name).produceFrom(copySpec);
|
||||
new CatalogContentContribution(this.project, this.name).produceFrom(copySpec, this.publish);
|
||||
}
|
||||
|
||||
public void aggregateContent(Action<CopySpec> action) {
|
||||
CopySpec copySpec = this.project.copySpec();
|
||||
action.execute(copySpec);
|
||||
new AggregateContentContribution(this.project, this.name).produceFrom(copySpec);
|
||||
new AggregateContentContribution(this.project, this.name).produceFrom(copySpec, this.publish);
|
||||
}
|
||||
|
||||
public void localAggregateContent(Action<CopySpec> action) {
|
||||
|
|
|
@ -42,7 +42,14 @@ class ConsumableContentContribution extends ContentContribution {
|
|||
|
||||
@Override
|
||||
void produceFrom(CopySpec copySpec) {
|
||||
this.produceFrom(copySpec, false);
|
||||
}
|
||||
|
||||
void produceFrom(CopySpec copySpec, boolean publish) {
|
||||
TaskProvider<? extends Task> producer = super.configureProduction(copySpec);
|
||||
if (publish) {
|
||||
publish(producer);
|
||||
}
|
||||
Configuration configuration = createConfiguration(getName(),
|
||||
"Configuration for %s Antora %s content artifacts.");
|
||||
configuration.setCanBeConsumed(true);
|
||||
|
@ -63,11 +70,15 @@ class ConsumableContentContribution extends ContentContribution {
|
|||
CopyAntoraContent.class, (task) -> configureCopyContent(task, path, configuration, outputDirectory));
|
||||
configureAntora(addInputFrom(copyAntoraContent, configuration.getName()));
|
||||
configurePlaybookGeneration(this::addToZipContentsCollectorDependencies);
|
||||
publish(copyAntoraContent);
|
||||
}
|
||||
|
||||
void publish(TaskProvider<? extends Task> producer) {
|
||||
getProject().getExtensions()
|
||||
.getByType(PublishingExtension.class)
|
||||
.getPublications()
|
||||
.withType(MavenPublication.class)
|
||||
.configureEach((mavenPublication) -> addPublishedMavenArtifact(mavenPublication, copyAntoraContent));
|
||||
.configureEach((mavenPublication) -> addPublishedMavenArtifact(mavenPublication, producer));
|
||||
}
|
||||
|
||||
private void configureCopyContent(CopyAntoraContent task, String path, Configuration configuration,
|
||||
|
@ -82,10 +93,10 @@ class ConsumableContentContribution extends ContentContribution {
|
|||
task.getAntoraExtensions().getZipContentsCollector().getDependencies().add(getName());
|
||||
}
|
||||
|
||||
private void addPublishedMavenArtifact(MavenPublication mavenPublication, TaskProvider<?> copyAntoraContent) {
|
||||
private void addPublishedMavenArtifact(MavenPublication mavenPublication, TaskProvider<?> producer) {
|
||||
if ("maven".equals(mavenPublication.getName())) {
|
||||
String classifier = "%s-%s-content".formatted(getName(), getType());
|
||||
mavenPublication.artifact(copyAntoraContent, (mavenArtifact) -> mavenArtifact.setClassifier(classifier));
|
||||
mavenPublication.artifact(producer, (mavenArtifact) -> mavenArtifact.setClassifier(classifier));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -328,6 +328,7 @@ antoraDependencies {
|
|||
|
||||
antoraContributions {
|
||||
'api' {
|
||||
publish()
|
||||
catalogContent {
|
||||
from(aggregatedJavadoc) {
|
||||
into "java"
|
||||
|
@ -338,6 +339,7 @@ antoraContributions {
|
|||
}
|
||||
}
|
||||
'root' {
|
||||
publish()
|
||||
aggregateContent {
|
||||
from("src/main") {
|
||||
into "modules/ROOT/examples"
|
||||
|
|
Loading…
Reference in New Issue