<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ JBoss, Home of Professional Open Source.
  ~
  ~ Copyright 2015 Red Hat, Inc., and individual contributors
  ~ as indicated by the @author tags.
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
<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.jboss.logging</groupId>
        <artifactId>jboss-logging-tools-parent</artifactId>
        <version>2.1.0.Final</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>jboss-logging-tools-docs</artifactId>
    <packaging>jar</packaging>

    <name>JBoss Logging I18n Documentation</name>

    <licenses>
        <license>
            <name>Apache License, version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <properties>
        <version.asciidoctor>1.5.5</version.asciidoctor>
        <java.docs.dir>apidocs</java.docs.dir>
        <java.docs.output.directory>${project.build.directory}/site/${java.docs.dir}</java.docs.output.directory>
    </properties>

    <dependencies>
        <!-- Logging dependencies used for the examples -->
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging-annotations</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging-processor</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>generate-site</id>
            <activation>
                <property>
                    <name>generate-site</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-clean-plugin</artifactId>
                        <configuration>
                            <filesets>
                                <fileset>
                                    <directory>${java.docs.dir}/</directory>
                                </fileset>
                                <fileset>
                                    <directory>examples/</directory>
                                </fileset>
                                <fileset>
                                    <directory>${project.basedir}</directory>
                                    <includes>
                                        <include>*.html</include>
                                    </includes>
                                </fileset>
                            </filesets>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <compilerArgs>
                                <arg>-Aorg.jboss.logging.tools.report.type=adoc</arg>
                                <arg>-Aorg.jboss.logging.tools.report.path=${project.reporting.outputDirectory}/adoc</arg>
                                <arg>-Aorg.jboss.logging.tools.report.title=Example Messages</arg>
                            </compilerArgs>
                        </configuration>
                    </plugin>
                    <plugin>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>create-javadoc</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>javadoc</goal>
                                </goals>
                                <configuration>
                                    <failOnError>true</failOnError>
                                    <reportOutputDirectory>${project.reporting.outputDirectory}/${java.docs.dir}</reportOutputDirectory>
                                    <excludePackageNames>*.examples.*</excludePackageNames>
                                    <includeDependencySources>true</includeDependencySources>
                                    <dependencySourceIncludes>
                                        <dependencySourceInclude>org.jboss.logging:jboss-logging-annotations:*</dependencySourceInclude>
                                    </dependencySourceIncludes>
                                    <notimestamp>true</notimestamp>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- Copy the generated JavaDoc's -->
                    <plugin>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-javadoc</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.basedir}/${java.docs.dir}</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>${project.reporting.outputDirectory}/${java.docs.dir}</directory>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.asciidoctor</groupId>
                        <artifactId>asciidoctor-maven-plugin</artifactId>
                        <version>${version.asciidoctor}</version>
                        <configuration>
                            <backend>html5</backend>
                            <sourceHighlighter>coderay</sourceHighlighter>
                            <attributes>
                                <icons>font</icons>
                                <sectanchors>true</sectanchors>
                                <!-- set the idprefix to blank -->
                                <idprefix/>
                                <idseparator>-</idseparator>
                                <docinfo1>true</docinfo1>
                                <javadocsdir>${java.docs.dir}</javadocsdir>
                                <version>${project.version}</version>
                                <nofooter/>
                                <revnumber>${project.version}</revnumber>
                                <organization>${project.organization.name}</organization>
                            </attributes>
                            <outputDirectory>${project.basedir}</outputDirectory>
                        </configuration>
                        <executions>
                            <execution>
                                <id>output-html</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>process-asciidoc</goal>
                                </goals>
                                <configuration>
                                    <preserveDirectories>true</preserveDirectories>
                                </configuration>
                            </execution>
                            <execution>
                                <id>output-report-html</id>
                                <phase>process-classes</phase>
                                <goals>
                                    <goal>process-asciidoc</goal>
                                </goals>
                                <configuration>
                                    <sourceDirectory>${project.reporting.outputDirectory}/adoc/</sourceDirectory>
                                    <outputDirectory>${project.basedir}/examples/</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
