From a1f2da07896d5b393ced64826568c634db668315 Mon Sep 17 00:00:00 2001 From: Peter Palaga Date: Fri, 20 Sep 2024 14:32:09 +0200 Subject: [PATCH] Add quarkus.antora.image configuration parameter --- .../antora/deployment/AntoraProcessor.java | 8 +++-- .../deployment/NativeImageBuildRunner.java | 4 +-- .../ROOT/pages/includes/quarkus-antora.adoc | 32 +++++++++++++++++++ .../quarkus-antora_quarkus.antora.adoc | 32 +++++++++++++++++++ docs/modules/ROOT/pages/index.adoc | 4 +++ docs/pom.xml | 19 +++++++++++ .../io/quarkiverse/antora/FixedConfig.java | 24 ++++++++++++++ 7 files changed, 118 insertions(+), 5 deletions(-) create mode 100644 docs/modules/ROOT/pages/includes/quarkus-antora.adoc create mode 100644 docs/modules/ROOT/pages/includes/quarkus-antora_quarkus.antora.adoc create mode 100644 runtime/src/main/java/io/quarkiverse/antora/FixedConfig.java diff --git a/deployment/src/main/java/io/quarkiverse/antora/deployment/AntoraProcessor.java b/deployment/src/main/java/io/quarkiverse/antora/deployment/AntoraProcessor.java index bfb550b..83d10bb 100644 --- a/deployment/src/main/java/io/quarkiverse/antora/deployment/AntoraProcessor.java +++ b/deployment/src/main/java/io/quarkiverse/antora/deployment/AntoraProcessor.java @@ -14,6 +14,7 @@ import org.jboss.logging.Logger; import org.yaml.snakeyaml.Yaml; +import io.quarkiverse.antora.FixedConfig; import io.quarkus.deployment.IsDevelopment; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; @@ -52,6 +53,7 @@ void watchResources(BuildProducer watchedFile @BuildStep void buildAntoraSite( + FixedConfig fixedConfig, BuildSystemTargetBuildItem buildSystemTarget, BuildProducer staticResourceProducer) { @@ -78,7 +80,7 @@ void buildAntoraSite( } } - buildWithContainer(gitRepoRoot, antoraPlaybookPath); + buildWithContainer(fixedConfig.image(), gitRepoRoot, antoraPlaybookPath); try (Stream files = Files.walk(pbInfo.outDir)) { files.forEach(absP -> { @@ -125,9 +127,9 @@ void buildAntoraSite( } - private void buildWithContainer(final Path gitRepoRoot, final Path antoraPlaybookPath) { + private void buildWithContainer(String antoraImageName, final Path gitRepoRoot, final Path antoraPlaybookPath) { try { - new NativeImageBuildRunner().build(gitRepoRoot, antoraPlaybookPath); + new NativeImageBuildRunner().build(antoraImageName, gitRepoRoot, antoraPlaybookPath); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (IOException e) { diff --git a/deployment/src/main/java/io/quarkiverse/antora/deployment/NativeImageBuildRunner.java b/deployment/src/main/java/io/quarkiverse/antora/deployment/NativeImageBuildRunner.java index 20ba454..00b4442 100644 --- a/deployment/src/main/java/io/quarkiverse/antora/deployment/NativeImageBuildRunner.java +++ b/deployment/src/main/java/io/quarkiverse/antora/deployment/NativeImageBuildRunner.java @@ -43,7 +43,7 @@ public NativeImageBuildRunner() { containerName = "antora-" + RandomStringUtils.random(5, true, false); } - public void build(Path outputDir, Path antoraPlaybookPath) + public void build(String antoraImageName, Path outputDir, Path antoraPlaybookPath) throws InterruptedException, IOException { final List cmd = new ArrayList<>(); @@ -88,7 +88,7 @@ public void build(Path outputDir, Path antoraPlaybookPath) cmd.add("--name"); cmd.add(containerName); - cmd.add("docker.io/antora/antora:3.0.1"); + cmd.add(antoraImageName); cmd.add("--cache-dir=./antora-cache"); cmd.add(antoraPlaybookPath.toString()); diff --git a/docs/modules/ROOT/pages/includes/quarkus-antora.adoc b/docs/modules/ROOT/pages/includes/quarkus-antora.adoc new file mode 100644 index 0000000..0e151ca --- /dev/null +++ b/docs/modules/ROOT/pages/includes/quarkus-antora.adoc @@ -0,0 +1,32 @@ +:summaryTableId: quarkus-antora_quarkus-antora +[.configuration-legend] +icon:lock[title=Fixed at build time] Configuration property fixed at build time - All other configuration properties are overridable at runtime +[.configuration-reference.searchable, cols="80,.^10,.^10"] +|=== + +h|[.header-title]##Configuration property## +h|Type +h|Default + +a|icon:lock[title=Fixed at build time] [[quarkus-antora_quarkus-antora-image]] [.property-path]##`quarkus.antora.image`## + +[.description] +-- +The fully qualified name of the Antora container image to use for generating the documentation site. +Example: `docker.io/antora/antora:3.0.1` + + +ifdef::add-copy-button-to-env-var[] +Environment variable: env_var_with_copy_button:+++QUARKUS_ANTORA_IMAGE+++[] +endif::add-copy-button-to-env-var[] +ifndef::add-copy-button-to-env-var[] +Environment variable: `+++QUARKUS_ANTORA_IMAGE+++` +endif::add-copy-button-to-env-var[] +-- +|string +|`docker.io/antora/antora:3.0.1` + +|=== + + +:!summaryTableId: \ No newline at end of file diff --git a/docs/modules/ROOT/pages/includes/quarkus-antora_quarkus.antora.adoc b/docs/modules/ROOT/pages/includes/quarkus-antora_quarkus.antora.adoc new file mode 100644 index 0000000..0e151ca --- /dev/null +++ b/docs/modules/ROOT/pages/includes/quarkus-antora_quarkus.antora.adoc @@ -0,0 +1,32 @@ +:summaryTableId: quarkus-antora_quarkus-antora +[.configuration-legend] +icon:lock[title=Fixed at build time] Configuration property fixed at build time - All other configuration properties are overridable at runtime +[.configuration-reference.searchable, cols="80,.^10,.^10"] +|=== + +h|[.header-title]##Configuration property## +h|Type +h|Default + +a|icon:lock[title=Fixed at build time] [[quarkus-antora_quarkus-antora-image]] [.property-path]##`quarkus.antora.image`## + +[.description] +-- +The fully qualified name of the Antora container image to use for generating the documentation site. +Example: `docker.io/antora/antora:3.0.1` + + +ifdef::add-copy-button-to-env-var[] +Environment variable: env_var_with_copy_button:+++QUARKUS_ANTORA_IMAGE+++[] +endif::add-copy-button-to-env-var[] +ifndef::add-copy-button-to-env-var[] +Environment variable: `+++QUARKUS_ANTORA_IMAGE+++` +endif::add-copy-button-to-env-var[] +-- +|string +|`docker.io/antora/antora:3.0.1` + +|=== + + +:!summaryTableId: \ No newline at end of file diff --git a/docs/modules/ROOT/pages/index.adoc b/docs/modules/ROOT/pages/index.adoc index 707124f..36d70c8 100644 --- a/docs/modules/ROOT/pages/index.adoc +++ b/docs/modules/ROOT/pages/index.adoc @@ -78,3 +78,7 @@ Then the page should get loaded with the new title "I love Antora". image::live-edit.png[optional attribute,optional attribute] Once you are done with editing, hit `Q` or `CRTL+C` to exit the dev mode. + +== Configuration + +include::./includes/quarkus-antora.adoc[] diff --git a/docs/pom.xml b/docs/pom.xml index e7cb5e4..ba532ac 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -125,6 +125,25 @@ + + io.quarkus + quarkus-config-doc-maven-plugin + ${quarkus.version} + + + generate-config-doc + process-resources + + generate-asciidoc + + + ${skipDocs} + true + ${project.basedir}/modules/ROOT/pages/includes + + + + diff --git a/runtime/src/main/java/io/quarkiverse/antora/FixedConfig.java b/runtime/src/main/java/io/quarkiverse/antora/FixedConfig.java new file mode 100644 index 0000000..cff6310 --- /dev/null +++ b/runtime/src/main/java/io/quarkiverse/antora/FixedConfig.java @@ -0,0 +1,24 @@ +package io.quarkiverse.antora; + +import io.quarkus.runtime.annotations.ConfigPhase; +import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; + +/** + * Quarkus Antora build time configuration options that are also available at runtime but only in read-only mode. + */ +@ConfigMapping(prefix = "quarkus.antora") +@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) +public interface FixedConfig { + + /** + * The fully qualified name of the Antora container image to use for generating the documentation site. + * Example: `docker.io/antora/antora:3.0.1` + * + * @asciidoclet + * @since 0.0.5 + */ + @WithDefault("docker.io/antora/antora:3.0.1") + String image(); +}