<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.infinispan</groupId>
        <artifactId>infinispan-parent</artifactId>
        <version>9.4.19.Final-redhat-00001</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>infinispan-docs</artifactId>

    <name>Infinispan Documentation</name>
    <description>The Infinispan Documentation</description>

    <properties>
        <javadoc.root>https://docs.jboss.org/infinispan/${infinispan.base.version}/apidocs</javadoc.root>
        <configdoc.root>https://docs.jboss.org/infinispan/${infinispan.base.version}/configdocs/</configdoc.root>
        <wildfly.docroot>https://docs.jboss.org/author/display/WFLY11</wildfly.docroot>
        <jdk.root>https://docs.oracle.com/javase/8/docs</jdk.root>
        <jdk.docroot>${jdk.root}/api</jdk.docroot>
        <javaee.docroot>https://docs.oracle.com/javaee/7/api</javaee.docroot>
        <skipTests>true</skipTests>
        <defaults.file>${project.build.directory}/default-attributes.adoc</defaults.file>
        <asciidoctor.version>1.6.2</asciidoctor.version>
        <asciidoctor.maven.plugin.version>1.5.7.1</asciidoctor.maven.plugin.version>
        <asciidoctorj.pdf.version>1.5.0-alpha.16</asciidoctorj.pdf.version>
        <jruby.version>9.2.6.0</jruby.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-commons</artifactId>
        </dependency>
        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-cachestore-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-cachestore-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-cachestore-leveldb</artifactId>
        </dependency>
        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-cachestore-remote</artifactId>
        </dependency>
        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-cachestore-rest</artifactId>
        </dependency>
        <dependency>
            <groupId>org.infinispan.server</groupId>
            <artifactId>infinispan-server-commons</artifactId>
        </dependency>
        <dependency>
            <groupId>org.infinispan.server</groupId>
            <artifactId>infinispan-server-jgroups</artifactId>
        </dependency>
        <dependency>
            <groupId>org.infinispan.server</groupId>
            <artifactId>infinispan-server-endpoints</artifactId>
        </dependency>
        <dependency>
            <groupId>org.infinispan.server</groupId>
            <artifactId>infinispan-server-infinispan</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>extract-slot</id>
                        <goals>
                            <goal>parse-version</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.infinispan</groupId>
                <artifactId>infinispan-defaults-maven-plugin</artifactId>
                <version>${project.version}</version>
                <executions>
                    <execution>
                        <id>extract-defaults</id>
                        <goals>
                            <goal>extract-defaults</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <attributeDefType>ALL</attributeDefType>
                            <defaultsFile>${defaults.file}</defaultsFile>
                            <outputAscii>true</outputAscii>
                            <filterXsd>false</filterXsd>
                            <jars>
                                <jar>infinispan-core</jar>
                                <jar>infinispan-cachestore-jdbc</jar>
                                <jar>infinispan-cachestore-jpa</jar>
                                <jar>infinispan-cachestore-leveldb</jar>
                                <jar>infinispan-cachestore-rocksdb</jar>
                                <jar>infinispan-cachestore-remote</jar>
                                <jar>infinispan-cachestore-rest</jar>
                                <jar>infinispan-server-endpoints</jar>
                                <jar>infinispan-server-jgroups</jar>
                                <jar>infinispan-server-infinispan</jar>
                            </jars>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.asciidoctor</groupId>
                <artifactId>asciidoctor-maven-plugin</artifactId>
                <version>${asciidoctor.maven.plugin.version}</version>
                <dependencies>
                    <dependency>
                        <groupId>org.asciidoctor</groupId>
                        <artifactId>asciidoctorj</artifactId>
                        <version>${asciidoctor.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.asciidoctor</groupId>
                        <artifactId>asciidoctorj-pdf</artifactId>
                        <version>${asciidoctorj.pdf.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.jruby</groupId>
                        <artifactId>jruby-complete</artifactId>
                        <version>${jruby.version}</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>html</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>process-asciidoc</goal>
                        </goals>
                        <configuration>
                            <backend>html5</backend>
                            <doctype>book</doctype>
                            <outputDirectory>${project.build.directory}/generated/${infinispan.base.version}/html</outputDirectory>
                            <imagesDir>.</imagesDir>
                            <preserveDirectories>true</preserveDirectories>
                            <relativeBaseDir>true</relativeBaseDir>
                            <sourceDocumentExtensions>
                                <sourceDocumentExtension>asciidoc</sourceDocumentExtension>
                            </sourceDocumentExtensions>
                            <sourceHighlighter>coderay</sourceHighlighter>
                            <attributes>
                                <idprefix></idprefix>
                                <sectanchors>true</sectanchors>
                                <toclevels>5</toclevels>
                                <numbered>true</numbered>
                                <icons>font</icons>
                                <docinfo>true</docinfo>
                                <experimental>true</experimental>
                                <infinispanversion>${infinispan.base.version}</infinispanversion>
                                <brandname>${infinispan.brand.name}</brandname>
                                <wildflybrandname>${wildfly.brand.name}</wildflybrandname>
                                <moduleprefix>${infinispan.module.slot.prefix}</moduleprefix>
                                <infinispanslot>${infinispan.module.slot.prefix}-${parsedVersion.majorVersion}.${parsedVersion.minorVersion}</infinispanslot>
                                <defaults>${defaults.file}</defaults>
                                <javadocroot>${javadoc.root}</javadocroot>
                                <configdocroot>${configdoc.root}</configdocroot>
                                <wildflydocroot>${wildfly.docroot}</wildflydocroot>
                                <jdkdocroot>${jdk.docroot}</jdkdocroot>
                                <javaeedocroot>${javaee.docroot}</javaeedocroot>
                                <brandcli>${infinispan.brand.cli}</brandcli>
                            </attributes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>

    <profiles>
        <profile>
            <id>distribution</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.asciidoctor</groupId>
                        <artifactId>asciidoctor-maven-plugin</artifactId>
                        <version>${asciidoctor.maven.plugin.version}</version>
                        <dependencies>
                            <dependency>
                                <groupId>org.asciidoctor</groupId>
                                <artifactId>asciidoctorj</artifactId>
                                <version>${asciidoctor.version}</version>
                            </dependency>
                            <dependency>
                                <groupId>org.asciidoctor</groupId>
                                <artifactId>asciidoctorj-pdf</artifactId>
                                <version>${asciidoctorj.pdf.version}</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution>
                                <id>pdf</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>process-asciidoc</goal>
                                </goals>
                                <configuration>
                                    <backend>pdf</backend>
                                    <doctype>book</doctype>
                                    <outputDirectory>${project.build.directory}/generated/${infinispan.base.version}/pdf</outputDirectory>
                                    <imagesDir>.</imagesDir>
                                    <preserveDirectories>false</preserveDirectories>
                                    <relativeBaseDir>true</relativeBaseDir>
                                    <sourceDocumentExtensions>
                                        <sourceDocumentExtension>asciidoc</sourceDocumentExtension>
                                    </sourceDocumentExtensions>
                                    <sourceHighlighter>coderay</sourceHighlighter>
                                    <attributes>
                                        <idprefix></idprefix>
                                        <sectanchors>true</sectanchors>
                                        <toclevels>3</toclevels>
                                        <numbered>true</numbered>
                                        <icons>font</icons>
                                        <docinfo>true</docinfo>
                                        <experimental>true</experimental>
                                        <infinispanversion>${infinispan.base.version}</infinispanversion>
                                        <defaults>${defaults.file}</defaults>
                                        <infinispanslot>${infinispan.module.slot.prefix}-${parsedVersion.majorVersion}.${parsedVersion.minorVersion}</infinispanslot>
                                        <javadocroot>${javadoc.root}</javadocroot>
                                        <configdocroot>${configdoc.root}</configdocroot>
                                        <wildflydocroot>${wildfly.docroot}</wildflydocroot>
                                        <jdkdocroot>${jdk.docroot}</jdkdocroot>
                                        <javaeedocroot>${javaee.docroot}</javaeedocroot>
                                        <brandcli>${infinispan.brand.cli}</brandcli>
                                    </attributes>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>optimize-pdf</id>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <phase>package</phase>
                                <configuration>
                                    <target>
                                        <ant antfile="optimize-pdf.xml" inheritRefs="true">
                                            <target name="optimize-pdf"></target>
                                        </ant>
                                    </target>
                                </configuration>
                            </execution>
                            <execution>
                                <id>upload-pdf</id>
                                <phase>deploy</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <skip>${skipArtifactUpload}</skip>
                                    <target>
                                        <echo message="Uploading PDF docs"></echo>
                                        <exec dir="${project.build.directory}/generated/${infinispan.base.version}" executable="rsync">
                                            <arg value="-rvm"></arg>
                                            <arg line="--protocol=29"></arg>
                                            <arg line="-e &quot;ssh -i ${upload.keyFile}&quot;"></arg>
                                            <arg line="--exclude='*.png'"></arg>
                                            <arg line="--exclude='*.svg'"></arg>
                                            <arg line="--include='*.pdf'"></arg>
                                            <arg value="pdf"></arg>
                                            <arg value="${upload.docsDir}"></arg>
                                        </exec>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>assemble-html</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <configuration>
                                    <descriptors>
                                        <descriptor>src/main/assemblies/html.xml</descriptor>
                                        <descriptor>src/main/assemblies/pdf.xml</descriptor>
                                    </descriptors>
                                    <attach>true</attach>
                                    <recompressZippedFiles>true</recompressZippedFiles>
                                    <finalName>${project.artifactId}-${project.version}</finalName>
                                    <appendAssemblyId>true</appendAssemblyId>
                                    <outputDirectory>${project.build.directory}</outputDirectory>
                                    <workDirectory>${project.build.directory}/assembly/work</workDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
