Skip to content

Commit

Permalink
Make sure that generateAntoraYml runs when attributes have changed
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsona committed Sep 13, 2024
1 parent 5666c98 commit 988e083
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.gradle.api.Project;
import org.gradle.api.logging.LogLevel;
import org.gradle.api.plugins.JavaBasePlugin;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.Copy;
import org.gradle.api.tasks.TaskContainer;

Expand Down Expand Up @@ -118,8 +119,7 @@ private void configureGenerateAntoraYmlTask(Project project, GenerateAntoraYmlTa
generateAntoraYmlTask.setProperty("outputFile",
new File(project.getBuildDir(), "generated/docs/antora-yml/antora.yml"));
generateAntoraYmlTask.setProperty("yml", getDefaultYml(project));
generateAntoraYmlTask.doFirst((task) -> generateAntoraYmlTask.getAsciidocAttributes()
.putAll(project.provider(() -> getAsciidocAttributes(project, dependencyVersionsTask))));
generateAntoraYmlTask.getAsciidocAttributes().putAll(getAsciidocAttributes(project, dependencyVersionsTask));
}

private Map<String, ?> getDefaultYml(Project project) {
Expand All @@ -138,12 +138,14 @@ private void configureGenerateAntoraYmlTask(Project project, GenerateAntoraYmlTa
return defaultYml;
}

private Map<String, String> getAsciidocAttributes(Project project,
private Provider<Map<String, String>> getAsciidocAttributes(Project project,
ExtractVersionConstraints dependencyVersionsTask) {
BomExtension bom = (BomExtension) project.project(DEPENDENCIES_PATH).getExtensions().getByName("bom");
Map<String, String> dependencyVersions = dependencyVersionsTask.getVersionConstraints();
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes(project, bom, dependencyVersions);
return attributes.get();
return project.provider(() -> {
BomExtension bom = (BomExtension) project.project(DEPENDENCIES_PATH).getExtensions().getByName("bom");
Map<String, String> dependencyVersions = dependencyVersionsTask.getVersionConstraints();
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes(project, bom, dependencyVersions);
return attributes.get();
});
}

private void configureAntoraTask(Project project, AntoraTask antoraTask, NpmInstallTask npmInstallTask,
Expand Down

0 comments on commit 988e083

Please sign in to comment.