<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved.

    This program and the accompanying materials are made available under the
    terms of the Eclipse Public License v. 2.0, which is available at
    http://www.eclipse.org/legal/epl-2.0.

    This Source Code may also be made available under the following Secondary
    Licenses when the conditions for such availability set forth in the
    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
    version 2 with the GNU Classpath Exception, which is available at
    https://www.gnu.org/software/classpath/license.html.

    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0

-->

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.glassfish.tyrus</groupId>
        <artifactId>tyrus-project</artifactId>
        <version>2.0.2</version>
    </parent>

    <artifactId>tyrus-documentation</artifactId>
    <packaging>pom</packaging>
    <name>Tyrus Documentation</name>

    <profiles>
        <profile>
            <id>release</id>
            <properties>
                <javanet.repository.id>releases</javanet.repository.id>
            </properties>
        </profile>
    </profiles>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <configuration>
                            <tasks>
                                <echo message="Preparing char entities" />
                                <mkdir dir="${src.dir}" />
                                <copy todir="${src.dir}">
                                    <fileset dir="src/main/docbook" />
                                </copy>
                                <replace file="${src.dir}/tyrus.ent" token="$version" value="${project.version}" />
                                <replace file="${src.dir}/tyrus.ent" token="$repository" value="${javanet.repository.id}" />
                                <replace file="${src.dir}/tyrus.ent" token="$websocket-api-version" value="${websocket-api.version}" />
                            </tasks>
                        </configuration>
                        <id>process-entities</id>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.agilejava.docbkx</groupId>
                <artifactId>docbkx-maven-plugin</artifactId>
                <version>2.0.15</version>
                <dependencies>
                    <dependency>
                        <groupId>net.sf.docbook</groupId>
                        <artifactId>docbook-xml</artifactId>
                        <version>5.0-all</version>
                        <classifier>resources</classifier>
                        <type>zip</type>
                        <scope>runtime</scope>
                    </dependency>
                </dependencies>
                <configuration>
                    <xincludeSupported>true</xincludeSupported>
                    <sourceDirectory>${src.dir}</sourceDirectory>
                    <targetDirectory>${project.build.directory}/docbook</targetDirectory>
                    <htmlStylesheet>/tyrus-project.github.io/documentation.css</htmlStylesheet>
                    <partAutolabel>true</partAutolabel>
                    <sectionAutolabel>true</sectionAutolabel>
                    <sectionLabelIncludesComponentLabel>true</sectionLabelIncludesComponentLabel>
                    <useExtensions>true</useExtensions>
                    <tablecolumnsExtension>true</tablecolumnsExtension>
                    <linenumberingExtension>true</linenumberingExtension>
                    <linenumberingEveryNth>1</linenumberingEveryNth>
                    <calloutsExtension>true</calloutsExtension>
                    <calloutGraphics>false</calloutGraphics>
                    <highlightSource>true</highlightSource>
                    <highlightDefaultLanguage />
                    <!--calloutGraphicsExtension>1</calloutGraphicsExtension-->
                </configuration>
                <executions>
                    <execution>
                        <id>Single page HTML and PDF</id>
                        <goals>
                            <goal>generate-html</goal>
                            <goal>generate-pdf</goal>
                        </goals>
                        <configuration>
                            <includes>user-guide.xml</includes>
                            <htmlCustomization>${src.dir}/cust-single.xsl</htmlCustomization>
                        </configuration>
                        <phase>package</phase>
                    </execution>
                    <execution>
                        <id>Multiple HTML pages</id>
                        <goals>
                            <goal>generate-html</goal>
                        </goals>
                        <configuration>
                            <includes>index.xml</includes>
                            <htmlCustomization>${src.dir}/cust-chunked.xsl</htmlCustomization>
                            <chunkedOutput>true</chunkedOutput>
                            <chunkSectionDepth>0</chunkSectionDepth>
                            <useIdAsFilename>true</useIdAsFilename>
                        </configuration>
                        <phase>package</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptors>
                        <descriptor>src/main/assembly/docbook.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attached</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-artifacts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <artifact>
                                    <file>${project.build.directory}/docbook/user-guide.pdf</file>
                                    <type>pdf</type>
                                    <classifier>user-guide</classifier>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <properties>
        <assembly.directory>${project.build.directory}/assembly</assembly.directory>
        <src.dir>${basedir}/target/gen-src</src.dir>
        <javanet.repository.id>snapshots</javanet.repository.id>
    </properties>


</project>
