<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2020 Red Hat, Inc. and/or its affiliates.
  ~
  ~ 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.optaweb.vehiclerouting</groupId>
    <artifactId>optaweb-vehicle-routing</artifactId>
    <version>7.32.0.Final</version>
  </parent>

  <artifactId>optaweb-vehicle-routing-docs</artifactId>
  <packaging>pom</packaging>

  <name>OptaWeb Vehicle Routing Documentation</name>

  <properties>
    <source.document.name>index.adoc</source.document.name>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>org.asciidoctor</groupId>
        <artifactId>asciidoctor-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
      </plugin>
    </plugins>

    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.asciidoctor</groupId>
          <artifactId>asciidoctor-maven-plugin</artifactId>
          <configuration>
            <imagesDir>.</imagesDir>
            <attributes>
              <revnumber>${project.version}</revnumber>
            </attributes>
          </configuration>
          <executions>
            <execution>
              <id>generate-single-html</id>
              <phase>generate-resources</phase>
              <goals>
                <goal>process-asciidoc</goal>
              </goals>
              <configuration>
                <!-- Needs to be duplicated to avoid rendering each adoc separately -->
                <sourceDocumentName>${source.document.name}</sourceDocumentName>
                <backend>html5</backend>
                <sourceHighlighter>highlightjs</sourceHighlighter>
                <outputDirectory>${project.build.directory}/generated-docs/html_single</outputDirectory>
              </configuration>
            </execution>
            <execution>
              <id>generate-pdf</id>
              <phase>generate-resources</phase>
              <goals>
                <goal>process-asciidoc</goal>
              </goals>
              <configuration>
                <!-- Needs to be duplicated to avoid rendering each adoc separately -->
                <sourceDocumentName>${source.document.name}</sourceDocumentName>
                <backend>pdf</backend>
                <sourceHighlighter>coderay</sourceHighlighter><!-- highlightjs does not work in PDF -->
                <outputDirectory>${project.build.directory}/generated-docs/pdf</outputDirectory>
              </configuration>
            </execution>
          </executions>
          <dependencies>
            <dependency>
              <groupId>org.asciidoctor</groupId>
              <artifactId>asciidoctorj</artifactId>
              <version>1.5.5</version>
            </dependency>
            <dependency>
              <groupId>org.asciidoctor</groupId>
              <artifactId>asciidoctorj-pdf</artifactId>
              <version>1.5.0-alpha.15</version>
            </dependency>
          </dependencies>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-assembly-plugin</artifactId>
          <executions>
            <execution>
              <id>package-generated-docs</id>
              <phase>package</phase>
              <goals>
                <goal>single</goal>
              </goals>
              <configuration>
                <finalName>${project.artifactId}-${project.version}</finalName>
                <appendAssemblyId>false</appendAssemblyId>
                <descriptors>
                  <descriptor>src/main/assembly/assembly-generated-docs-zip.xml</descriptor>
                </descriptors>
                <archive>
                  <addMavenDescriptor>true</addMavenDescriptor>
                </archive>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>
