<?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.optaplanner</groupId>
    <artifactId>optaplanner</artifactId>
    <version>7.31.0.Final</version>
  </parent>

  <artifactId>optaplanner-docs</artifactId>
  <packaging>pom</packaging>

  <name>OptaPlanner documentation</name>
  <description>
    OptaPlanner solves planning problems.
    This lightweight, embeddable planning engine implements powerful and scalable algorithms
    to optimize business resource scheduling and planning.

    This module builds the documentation.
  </description>
  <url>https://www.optaplanner.org</url>

  <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>
          <version>1.5.7.1</version>
          <configuration>
            <imagesDir>.</imagesDir>
            <attributes>
              <revnumber>${project.version}</revnumber>
              <!-- Custom attributes -->
              <codeDir>${project.build.directory}/code</codeDir>
              <COMMUNITY-ONLY/>
              <shared-dir>${project.basedir}/../shared/</shared-dir>
              <html-googleAnalyticsId>UA-39485370-1</html-googleAnalyticsId>
            </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.8.1</version>
            </dependency>
            <dependency>
              <groupId>org.asciidoctor</groupId>
              <artifactId>asciidoctorj-pdf</artifactId>
              <version>1.5.0-alpha.16</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/generated-docs-zip.xml</descriptor>
                </descriptors>
                <archive>
                  <addMavenDescriptor>true</addMavenDescriptor>
                </archive>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
 
  <profiles>
    <profile>
      <id>community</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.jboss.maven.plugins</groupId>
              <artifactId>maven-jdocbook-plugin</artifactId>
              <configuration>
                <profiling>
                  <enabled>true</enabled>
                  <attributeName>condition</attributeName>
                  <attributeValue>COMMUNITY-ONLY</attributeValue>
                </profiling>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>

    <profile>
      <id>productizationDocsProfile</id>
      <activation>
        <property>
          <name>productizationDocs</name>
        </property>
      </activation>
      
      <properties>
        <!-- This file does not exist in the community repository, but it does exist in the product-docs repo -->
        <source.document.name>product-index.adoc</source.document.name>
      </properties>
      
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.jboss.maven.plugins</groupId>
              <artifactId>maven-jdocbook-plugin</artifactId>
              <configuration>
                <profiling>
                  <enabled>true</enabled>
                  <attributeName>condition</attributeName>
                  <attributeValue>PRODUCT-ONLY</attributeValue>
                </profiling>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
  </profiles>
  
</project>
