<?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>org.springframework.cloud.stream.app</groupId>
        <artifactId>stream-applications-release-train</artifactId>
        <version>2025.0.1-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <artifactId>stream-applications-docs</artifactId>
    <name>stream-applications-docs</name>
    <description>Stream Apps Docs</description>
    <version>2025.0.1-SNAPSHOT</version>
    <properties>
        <docs.resources.version>0.2.5</docs.resources.version>
        <rootDir>${basedir}/../..</rootDir>
    </properties>
    <repositories>
        <repository>
            <id>maven-central</id>
            <name>Maven Central</name>
            <url>https://repo.maven.apache.org/maven2</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
        </repository>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <dependencies>
        <!-- Any modules whose javadocs need to be published must be listed here.
        Modules with @ConfigurationProperties.
        -->

        <!-- Apps don't use external functions as baseline, but contain @ConfigurationProperties -->
        <dependency>
            <groupId>org.springframework.cloud.stream.app</groupId>
            <artifactId>load-generator-source</artifactId>
            <version>${apps.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud.stream.app</groupId>
            <artifactId>router-sink</artifactId>
            <version>${apps.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud.stream.app</groupId>
            <artifactId>pgcopy-sink</artifactId>
            <version>${apps.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud.stream.app</groupId>
            <artifactId>throughput-sink</artifactId>
            <version>${apps.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud.stream.app</groupId>
            <artifactId>groovy-processor</artifactId>
            <version>${apps.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud.stream.app</groupId>
            <artifactId>script-processor</artifactId>
            <version>${apps.version}</version>
        </dependency>
    </dependencies>
    <profiles>
        <profile>
            <id>full</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-deploy-plugin</artifactId>
                        <version>3.0.0</version>
                        <configuration>
                            <skip>false</skip>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>${maven-javadoc-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <phase>prepare-package</phase>
                                <configuration>
                                    <includeDependencySources>true</includeDependencySources>
                                    <dependencySourceIncludes>
                                        <dependencySourceInclude>org.springframework.cloud.stream.app:*</dependencySourceInclude>
                                    </dependencySourceIncludes>

                                    <attach>false</attach>
                                    <quiet>false</quiet>
                                    <debug>true</debug>
                                    <stylesheetfile>${basedir}/src/main/javadoc/spring-javadoc.css</stylesheetfile>
                                    <links>
                                        <link>
                                            https://docs.spring.io/spring-framework/docs/${spring.version}/javadoc-api/
                                        </link>
                                        <link>https://docs.spring.io/spring-shell/docs/current/api/</link>
                                    </links>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <version>3.3.0</version>
                        <executions>
                            <execution>
                                <id>copy-asciidoc-resources</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.build.directory}/refdocs/</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>src/main/asciidoc</directory>
                                            <filtering>false</filtering>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.asciidoctor</groupId>
                        <artifactId>asciidoctor-maven-plugin</artifactId>
                        <version>2.2.4</version>
                        <dependencies>
                            <dependency>
                                <groupId>org.asciidoctor</groupId>
                                <artifactId>asciidoctorj-pdf</artifactId>
                                <version>2.3.9</version>
                            </dependency>
                            <dependency>
                                <groupId>io.spring.asciidoctor.backends</groupId>
                                <artifactId>spring-asciidoctor-backends</artifactId>
                                <version>0.0.5</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution>
                                <id>html</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>process-asciidoc</goal>
                                </goals>
                                <configuration>
                                    <backend>spring-html</backend>
                                    <outputDirectory>${project.build.directory}/contents/reference/html
                                    </outputDirectory>
                                    <attributes>
                                        <sectids>false</sectids>
                                        <source-highlighter>highlight.js</source-highlighter>
                                        <project-version>${project.version}</project-version>
                                        <docinfo>shared</docinfo>
                                        <linkcss>true</linkcss>
                                        <icons>font</icons>
                                        <sectanchors>true</sectanchors>
                                        <stylesdir>css/</stylesdir>
                                        <stylesheet>spring.css</stylesheet>
                                        <highlightjsdir>js/highlight</highlightjsdir>
                                        <highlightjs-theme>github</highlightjs-theme>
                                        <stream-apps-folder>${rootDir}</stream-apps-folder>
                                    </attributes>
                                </configuration>
                            </execution>
                            <execution>
                                <id>pdf</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>process-asciidoc</goal>
                                </goals>
                                <configuration>
                                    <backend>pdf</backend>
                                    <outputDirectory>${project.build.directory}/contents/reference/pdf</outputDirectory>
                                    <attributes>
                                        <source-highlighter>coderay</source-highlighter>
                                        <stream-apps-folder>${rootDir}</stream-apps-folder>
                                    </attributes>
                                </configuration>
                            </execution>
                        </executions>

                        <configuration>
                            <sourceDirectory>${project.build.directory}/refdocs/</sourceDirectory>
                            <sourceDocumentName>index.adoc</sourceDocumentName>
                            <doctype>book</doctype>
                            <attributes>
                                <version>${project.version}</version>
                                <projectName>${project.name}</projectName>
                                <projectVersion>${project.version}</projectVersion>
                                <allow-uri-read>true</allow-uri-read>
                                <toclevels>4</toclevels>
                                <numbered>true</numbered>
                                <baseDir>${project.basedir}</baseDir>
                                <stream-apps-folder>${rootDir}</stream-apps-folder>
                                <scst-core-version>${spring-cloud-stream-dependencies.version}</scst-core-version>
                                <spring-core-version>${spring.version}</spring-core-version>
                            </attributes>
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.7</version>
                        <dependencies>
                            <dependency>
                                <groupId>ant-contrib</groupId>
                                <artifactId>ant-contrib</artifactId>
                                <version>1.0b3</version>
                                <exclusions>
                                    <exclusion>
                                        <groupId>ant</groupId>
                                        <artifactId>ant</artifactId>
                                    </exclusion>
                                </exclusions>
                            </dependency>
                            <dependency>
                                <groupId>org.apache.ant</groupId>
                                <artifactId>ant-nodeps</artifactId>
                                <version>1.8.1</version>
                            </dependency>
                            <dependency>
                                <groupId>org.tigris.antelope</groupId>
                                <artifactId>antelopetasks</artifactId>
                                <version>3.2.10</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution>
                                <id>package-and-attach-docs-zip</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <zip destfile="${project.build.directory}/${project.artifactId}-${project.version}.zip">
                                            <zipfileset
                                                    src="${project.build.directory}/${project.artifactId}-${project.version}-javadoc.jar"
                                                    prefix="api"/>
                                            <zipfileset dir="${project.build.directory}/contents/reference/html"
                                                        prefix="reference/html"/>
                                            <zipfileset dir="${project.build.directory}/contents/reference/pdf"
                                                        prefix="reference/pdf" includes="index.pdf"/>
                                        </zip>
                                    </target>
                                </configuration>
                            </execution>
                            <execution>
                                <id>setup-maven-properties</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <exportAntProperties>true</exportAntProperties>
                                    <target>
                                        <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
                                        <taskdef name="stringutil" classname="ise.antelope.tasks.StringUtilTask"/>
                                        <var name="version-type" value="${project.version}"/>
                                        <propertyregex property="version-type" override="true" input="${version-type}"
                                                       regexp=".*\.(.*)" replace="\1"/>
                                        <propertyregex property="version-type" override="true" input="${version-type}"
                                                       regexp="(M)\d+" replace="MILESTONE"/>
                                        <propertyregex property="version-type" override="true" input="${version-type}"
                                                       regexp="(RC)\d+" replace="MILESTONE"/>
                                        <propertyregex property="version-type" override="true" input="${version-type}"
                                                       regexp="BUILD-(.*)" replace="SNAPSHOT"/>
                                        <stringutil string="${version-type}" property="spring-boot-repo">
                                            <lowercase/>
                                        </stringutil>
                                        <var name="github-tag" value="v${project.version}"/>
                                        <propertyregex property="github-tag" override="true" input="${github-tag}"
                                                       regexp=".*SNAPSHOT" replace="master"/>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>3.4.0</version>
                        <executions>
                            <execution>
                                <id>attach-zip</id>
                                <goals>
                                    <goal>attach-artifact</goal>
                                </goals>
                                <configuration>
                                    <artifacts>
                                        <artifact>
                                            <file>
                                                ${project.build.directory}/${project.artifactId}-${project.version}.zip
                                            </file>
                                            <type>zip</type>
                                        </artifact>
                                    </artifacts>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
