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

    Copyright (c) 2019 Red Hat, Inc.
    This program and the accompanying materials are made
    available under the terms of the Eclipse Public License 2.0
    which is available at:

        https://www.eclipse.org/legal/epl-2.0/

    SPDX-License-Identifier: EPL-2.0

    Contributors:
      Red Hat, Inc. - initial API and implementation

-->
<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.eclipse.jkube</groupId>
    <artifactId>oc-maven-plugin-build</artifactId>
    <version>0.1.0</version>
    <relativePath>../pom.xml</relativePath>
  </parent>

  <artifactId>openshift-maven-plugin-doc</artifactId>
  <version>0.1.0</version>
  <packaging>jar</packaging>

  <name>OpenShift Maven :: Documentation</name>

  <properties>
    <maven-resources-plugin.version>3.0.0</maven-resources-plugin.version>
    <asciidoctor-maven-plugin.version>1.6.0</asciidoctor-maven-plugin.version>
    <asciidoctorj.version>2.1.0</asciidoctorj.version>
    <asciidoctorj-pdf.version>1.5.0-alpha.18</asciidoctorj-pdf.version>
  </properties>

  <dependencies>

    <!-- == asciidoctor ================================= -->

    <dependency>
      <groupId>org.asciidoctor</groupId>
      <artifactId>asciidoctorj</artifactId>
      <version>${asciidoctorj.version}</version>
    </dependency>

  </dependencies>


  <build>
    <plugins>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>${maven-resources-plugin.version}</version>
        <executions>
          <execution>
            <id>copy-asciidoc</id>
            <phase>process-resources</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.outputDirectory}/META-INF/doc/fmp</outputDirectory>
              <resources>
                <resource>
                  <directory>src/main/asciidoc</directory>
                  <filtering>false</filtering>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>

    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.asciidoctor</groupId>
          <artifactId>asciidoctor-maven-plugin</artifactId>
          <version>${asciidoctor-maven-plugin.version}</version>
          <configuration>
            <sourceDirectory>src/main/asciidoc</sourceDirectory>
            <attributes>
              <icons>font</icons>
              <pagenums/>
              <version>${project.version}</version>
              <plugindir>${project.basedir}/../plugin</plugindir>
              <idprefix/>
              <idseparator>-</idseparator>
              <allow-uri-read>true</allow-uri-read>
            </attributes>
          </configuration>
          <dependencies>
            <dependency>
              <groupId>org.eclipse.jkube</groupId>
              <artifactId>openshift-maven-plugin-doc</artifactId>
              <version>${project.version}</version>
            </dependency>
          </dependencies>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <!-- ==== HTML documentation ====================== -->
  <profiles>
    <profile>
      <id>html</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.asciidoctor</groupId>
            <artifactId>asciidoctor-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>output-html</id>
                <phase>package</phase>
                <goals>
                  <goal>process-asciidoc</goal>
                </goals>
                <configuration>
                  <sourceHighlighter>coderay</sourceHighlighter>
                  <backend>html</backend>
                  <sourceHighlighter>coderay</sourceHighlighter>
                  <attributes>
                    <toc>left</toc>
                    <linkcss>false</linkcss>
                  </attributes>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      <activation><activeByDefault>true</activeByDefault></activation>
    </profile>

    <!-- ==== PDF documentation ====================== -->

    <profile>
      <id>pdf</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.asciidoctor</groupId>
            <artifactId>asciidoctor-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>output-pdf</id>
                <phase>package</phase>
                <goals>
                  <goal>process-asciidoc</goal>
                </goals>
                <configuration>
                  <backend>pdf</backend>
                  <sourceHighlighter>rouge</sourceHighlighter>
                  <attributes>
                    <toc/>
                  </attributes>
                </configuration>
              </execution>
            </executions>
            <dependencies>
              <dependency>
                <groupId>org.asciidoctor</groupId>
                <artifactId>asciidoctorj-pdf</artifactId>
                <version>${asciidoctorj-pdf.version}</version>
              </dependency>
            </dependencies>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>