<?xml version="1.0" encoding="UTF-8"?>
<!--
/**********************************************************************
 * Copyright (c) 2017-2022 Contributors to the Eclipse Foundation
 *
 * See the NOTICES file(s) distributed with this work for additional
 * information regarding copyright ownership.
 *
 * 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.
 *
 * SPDX-License-Identifier: Apache-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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.eclipse.microprofile</groupId>
        <artifactId>microprofile</artifactId>
        <version>6.0</version>
    </parent>

    <groupId>org.eclipse.microprofile</groupId>
    <artifactId>microprofile-spec</artifactId>
    <packaging>pom</packaging>
    <name>MicroProfile Specification</name>

    <properties>
        <asciidoctor.maven.plugin.version>2.2.2</asciidoctor.maven.plugin.version>
        <!-- Required dependency overwrite versions for the AsciiDoctor Maven Plugin version -->
        <asciidoctorj.version>2.5.7</asciidoctorj.version>
        <asciidoctorj.diagram.version>2.2.3</asciidoctorj.diagram.version>
        <asciidoctorj.pdf.version>2.3.0</asciidoctorj.pdf.version>
        <jruby.version>9.3.8.0</jruby.version>
        
        <build.helper.maven.plugin.version>3.3.0</build.helper.maven.plugin.version>

        <maven.build.timestamp.format>MMMM dd, yyyy</maven.build.timestamp.format>
        <revisiondate>${maven.build.timestamp}</revisiondate>
        <revremark>Draft</revremark>
        <inceptionYear>2016</inceptionYear>
        <spec.pdf>${project.build.directory}/generated-docs/${project.build.finalName}.pdf</spec.pdf>
        <spec.html>${project.build.directory}/generated-docs/${project.build.finalName}.html</spec.html>
    </properties>

    <build>
        <defaultGoal>clean package</defaultGoal>
        <plugins>
            <plugin>
                <groupId>org.asciidoctor</groupId>
                <artifactId>asciidoctor-maven-plugin</artifactId>
                <version>${asciidoctor.maven.plugin.version}</version>
                <dependencies>
                    <!-- Comment this section to use the default jruby artifact provided by the plugin -->
                    <dependency>
                        <groupId>org.jruby</groupId>
                        <artifactId>jruby</artifactId>
                        <version>${jruby.version}</version>
                    </dependency>
                    <!-- Comment this section to use the default AsciidoctorJ artifact provided by the plugin -->
                    <dependency>
                        <groupId>org.asciidoctor</groupId>
                        <artifactId>asciidoctorj</artifactId>
                        <version>${asciidoctorj.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.asciidoctor</groupId>
                        <artifactId>asciidoctorj-diagram</artifactId>
                        <version>${asciidoctorj.diagram.version}</version>
                    </dependency>
                    <!-- Since asciidoctorj-diagram v2.2.0, uncomment to use specific version of plantuml or ditaa -->
                    <!--
                    <dependency>
                        <groupId>org.asciidoctor</groupId>
                        <artifactId>asciidoctorj-diagram-plantuml</artifactId>
                        <version>1.2022.5</version>
                    </dependency>
                    <dependency>
                        <groupId>org.asciidoctor</groupId>
                        <artifactId>asciidoctorj-diagram-ditaamini</artifactId>
                        <version>1.0.3</version>
                    </dependency>
                    -->
                    <dependency>
                        <groupId>org.asciidoctor</groupId>
                        <artifactId>asciidoctorj-pdf</artifactId>
                        <version>${asciidoctorj.pdf.version}</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <sourceDirectory>src/main/asciidoc</sourceDirectory>
                    <sourceDocumentName>microprofile-spec.adoc</sourceDocumentName>
                    <!-- Attributes common to all output formats -->
                    <attributes>
                        <icons>font</icons>
                        <idprefix />
                        <idseparator>-</idseparator>
                        <!-- Images located to documents source -->
                        <imagesdir>./image</imagesdir>
                        <sourcedir>${project.build.sourceDirectory}</sourcedir>
                        <license>Apache License v2.0</license>
                        <revnumber>${project.version}</revnumber>
                        <revremark>${revremark}</revremark>
                        <revdate>${revisiondate}</revdate>
                        <inceptionYear>${inceptionYear}</inceptionYear>
                        <currentYear>${currentYear}</currentYear>
                        <organization>${project.organiazation.name}</organization>
                        <source-highlighter>coderay</source-highlighter>
                    </attributes>
                    <requires>
                        <require>asciidoctor-diagram</require>
                    </requires>
                </configuration>
                <executions>
                    <execution>
                        <id>generate-html-doc</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>process-asciidoc</goal>
                        </goals>
                        <configuration>
                            <backend>html5</backend>
                            <outputFile>${spec.html}</outputFile>
                            <!-- Attributes specific to output formats -->
                            <attributes>
                                <toc>left</toc>
                                <sectanchors>true</sectanchors>
                            </attributes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>generate-pdf-doc</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>process-asciidoc</goal>
                        </goals>
                        <configuration>
                            <backend>pdf</backend>
                            <doctype>book</doctype>
                            <outputFile>${spec.pdf}</outputFile>
                            <!-- Attributes specific to output formats -->
                            <attributes>
                                <pagenums />
                                <toc />
                            </attributes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>${build.helper.maven.plugin.version}</version>
                <executions>
                    <execution>
                        <id>timestamp-property</id>
                        <goals>
                            <goal>timestamp-property</goal>
                        </goals>
                        <phase>validate</phase>
                        <configuration>
                            <locale>en,US</locale>
                            <name>currentYear</name>
                            <pattern>yyyy</pattern>
                        </configuration>
                    </execution>
                    <execution>
                        <id>attach-artifacts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <artifact>
                                    <file>${spec.pdf}</file>
                                    <type>pdf</type>
                                </artifact>
                                <artifact>
                                    <file>${spec.html}</file>
                                    <type>html</type>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
