<?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">
    <parent>
        <artifactId>revapi-parent</artifactId>
        <groupId>org.revapi</groupId>
        <version>1</version>
        <relativePath>../revapi-parent</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <name>Revapi Build Parent</name>
    <description>
        This module is meant to serve as parent for other modules that actually contain code and
        need to depend on other libraries.
    </description>

    <artifactId>revapi-build</artifactId>
    <version>2</version>
    <packaging>pom</packaging>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.revapi</groupId>
                <artifactId>revapi-bom</artifactId>
                <version>2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>annotations</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.revapi</groupId>
            <artifactId>revapi-site-base</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>com.puppycrawl.tools</groupId>
                        <artifactId>checkstyle</artifactId>
                        <version>6.4</version>
                    </dependency>
                    <dependency>
                        <groupId>org.revapi</groupId>
                        <artifactId>revapi-build-support</artifactId>
                        <version>1</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <consoleOutput>true</consoleOutput>
                    <includeTestSourceDirectory>true</includeTestSourceDirectory>
                    <configLocation>checkstyle.xml</configLocation>
                    <suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
                </configuration>
                <executions>
                    <execution>
                        <goals><goal>check</goal></goals>
                        <phase>verify</phase>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-site-base</id>
                        <phase>pre-site</phase>
                        <goals><goal>run</goal></goals>
                        <configuration>
                            <target>
                                <unzip src="${org.revapi:revapi-site-base:jar}" dest="${project.build.directory}/site-base" />
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.asciidoctor</groupId>
                <artifactId>asciidoctor-maven-plugin</artifactId>
                <configuration>
                    <sourceDirectory>${project.basedir}/src/site/asciidoc</sourceDirectory>
                    <outputDirectory>${project.build.directory}/staging/docs/${project.artifactId}</outputDirectory>
                    <preserveDirectories>true</preserveDirectories>
                    <backend>html5</backend>
                    <sourceHighlighter>coderay</sourceHighlighter>
                    <templateDir>${project.build.directory}/site-base</templateDir>
                    <templateEngine>haml</templateEngine>
                    <attributes>
                        <endpoint-url>http://revapi.org</endpoint-url>
                        <linkcss>true</linkcss>
                        <stylesheet>blah.css</stylesheet>
                        <coderay-css>style</coderay-css>
                        <icons>font</icons>
                        <iconfont-remote>true</iconfont-remote>
                    </attributes>
                </configuration>
                <executions>
                    <execution>
                        <id>generate-module-docs</id>
                        <goals><goal>process-asciidoc</goal></goals>
                        <!-- don't run this yet. The workflow has not been finalized. -->
                        <phase>none</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>api-check</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>parse-version</id>
                                <goals>
                                    <goal>parse-version</goal>
                                </goals>
                                <phase>validate</phase>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.revapi</groupId>
                        <artifactId>revapi-maven-plugin</artifactId>
                        <version>${self-api-check.maven-version}</version>
                        <dependencies>
                            <dependency>
                                <groupId>org.revapi</groupId>
                                <artifactId>revapi-java</artifactId>
                                <version>${self-api-check.java-extension-version}</version>
                            </dependency>
                        </dependencies>
                        <configuration>
                            <failOnMissingConfigurationFiles>false</failOnMissingConfigurationFiles>
                            <analysisConfiguration><![CDATA[
                                {
                                    "revapi" : {
                                        "java" : {
                                            "missing-classes" : {
                                                "behavior" : "report"
                                            }
                                        }
                                    }
                                }
                            ]]></analysisConfiguration>
                            <analysisConfigurationFiles>
                                <configurationFile>
                                    <path>api-changes.json</path>
                                    <roots>
                                        <root>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}</root>
                                    </roots>
                                </configurationFile>
                            </analysisConfigurationFiles>
                        </configuration>
                        <executions>
                            <execution>
                                <id>api-check</id>
                                <goals><goal>check</goal></goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <scm>
        <connection>scm:git:git://github.com/revapi/revapi.git</connection>
        <developerConnection>scm:git:ssh://git@github.com/revapi/revapi.git</developerConnection>
        <url>https://github.com/revapi/revapi</url>
        <tag>revapi-build-2</tag>
    </scm>
</project>
