<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>io.quarkiverse.idempotency</groupId>
        <artifactId>quarkus-http-idempotency-parent</artifactId>
        <version>0.1.0</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>quarkus-http-idempotency-docs</artifactId>
    <packaging>pom</packaging>
    <name>Quarkus HTTP Idempotency - Documentation</name>

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>quarkus-http-idempotency-deployment</artifactId>
            <version>${project.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>io.quarkus</groupId>
                <artifactId>quarkus-config-doc-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <targetDirectory>${project.build.directory}/generated-docs/</targetDirectory>
                </configuration>
            </plugin>

            <!-- Expose release.current-version (from .github/project.yml) for attribute filtering. -->
            <plugin>
                <groupId>it.ozimov</groupId>
                <artifactId>yaml-properties-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>initialize</phase>
                        <goals>
                            <goal>read-project-properties</goal>
                        </goals>
                        <configuration>
                            <files>
                                <file>${project.basedir}/../.github/project.yml</file>
                            </files>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!--
              Copy the generated config reference and the filtered attributes into pages/includes/
              so Antora (which builds from Git, not Maven) and the local Asciidoctor preview both
              resolve the includes. Runs after generate-resources (config-doc) and before
              prepare-package (asciidoctor).
            -->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-includes</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.basedir}/modules/ROOT/pages/includes/</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${project.build.directory}/generated-docs/</directory>
                                    <include>quarkus-http-idempotency.adoc</include>
                                    <filtering>false</filtering>
                                </resource>
                                <resource>
                                    <directory>${project.basedir}/templates/includes</directory>
                                    <include>attributes.adoc</include>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.asciidoctor</groupId>
                <artifactId>asciidoctor-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>
