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

    Copyright 2014-2021 Lukas Krejci
    and other contributors as indicated by the @author tags.

    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">
    <parent>
        <artifactId>revapi-parent</artifactId>
        <groupId>org.revapi</groupId>
        <version>13</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>42</version>
    <packaging>pom</packaging>
    <url>https://revapi.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <self-api-check.maven-version>0.12.2</self-api-check.maven-version>
        <self-api-check.java-extension-version>0.22.1</self-api-check.java-extension-version>

        <version.maven-assembly-plugin>2.5.5</version.maven-assembly-plugin>
        <version.build-helper-maven-plugin>3.0.0</version.build-helper-maven-plugin>
        <version.maven-enforce-plugin>3.0.0-M3</version.maven-enforce-plugin>
        <version.maven-surefire-plugin>3.0.0-M5</version.maven-surefire-plugin>
        <version.maven-compiler-plugin>3.8.1</version.maven-compiler-plugin>
        <version.maven-jar-plugin>3.2.0</version.maven-jar-plugin>
        <version.maven-failsafe-plugin>${version.maven-surefire-plugin}</version.maven-failsafe-plugin>
        <version.impsort-maven-plugin>1.4.1</version.impsort-maven-plugin>
        <version.license-maven-plugin>3.0</version.license-maven-plugin>
        <version.jacoco-maven-plugin>0.8.2</version.jacoco-maven-plugin>

        <version.ch.qos.logback>1.1.2</version.ch.qos.logback>
        <version.com.google.code.findbugs>3.0.0</version.com.google.code.findbugs>
        <version.org.junit>5.7.0</version.org.junit>
        <version.org.slf4j>1.7.5</version.org.slf4j>
        <version.org.mockito>3.2.4</version.org.mockito>

        <version.revapi-build-support>5</version.revapi-build-support>

        <version.pw.krejci.multi-release-jar-maven-plugin>0.1.5</version.pw.krejci.multi-release-jar-maven-plugin>

        <automatic.module.name>define this in child modules</automatic.module.name>

	<!--
            Work around Intellij's lack for maven.compiler.release attribute
            See https://youtrack.jetbrains.com/issue/IDEA-173143
	-->
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>

        <antora-module.version>master</antora-module.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-classic</artifactId>
                <version>${version.ch.qos.logback}</version>
            </dependency>

            <dependency>
                <groupId>com.google.code.findbugs</groupId>
                <artifactId>annotations</artifactId>
                <version>${version.com.google.code.findbugs}</version>
            </dependency>

            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-core</artifactId>
                <version>${version.org.mockito}</version>
            </dependency>

            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>${version.org.slf4j}</version>
            </dependency>

            <dependency>
                <groupId>org.junit</groupId>
                <artifactId>junit-bom</artifactId>
                <version>${version.org.junit}</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>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <extensions>
            <extension>
                <groupId>pw.krejci</groupId>
                <artifactId>multi-release-jar-maven-plugin</artifactId>
                <version>${version.pw.krejci.multi-release-jar-maven-plugin}</version>
            </extension>
        </extensions>

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>${version.build-helper-maven-plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>${version.maven-enforce-plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${version.maven-surefire-plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>${version.maven-failsafe-plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${version.maven-compiler-plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>${version.maven-jar-plugin}</version>
                </plugin>
                <plugin>
                    <groupId>net.revelc.code.formatter</groupId>
                    <artifactId>formatter-maven-plugin</artifactId>
                    <version>${version.net.revelc.code.formatter}</version>
                </plugin>
                <plugin>
                    <groupId>net.revelc.code</groupId>
                    <artifactId>impsort-maven-plugin</artifactId>
                    <version>${version.impsort-maven-plugin}</version>
                </plugin>
                <plugin>
                    <groupId>com.mycila</groupId>
                    <artifactId>license-maven-plugin</artifactId>
                    <version>${version.license-maven-plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>${version.jacoco-maven-plugin}</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <Automatic-Module-Name>${automatic.module.name}</Automatic-Module-Name>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>

            <plugin>
                <groupId>pw.krejci</groupId>
                <artifactId>multi-release-jar-maven-plugin</artifactId>
                <version>${version.pw.krejci.multi-release-jar-maven-plugin}</version>
                <configuration>
                    <mainModuleInfo>9</mainModuleInfo>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-enforcer-plugin</artifactId>
                <executions>
                    <execution>
                        <id>java-version-check</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireJavaVersion>
                                    <version>9</version>
                                </requireJavaVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <forkCount>2</forkCount>
                    <reuseForks>true</reuseForks>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>prepare-unit-test</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <destFile>${project.build.directory}/jacoco-ut.exec</destFile>
                        </configuration>
                    </execution>
                    <execution>
                        <id>prepare-it-tests</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>prepare-agent-integration</goal>
                        </goals>
                        <configuration>
                            <destFile>${project.build.directory}/jacoco-it.exec</destFile>
                        </configuration>
                    </execution>
                    <execution>
                      <id>report-unit-tests</id>
                      <phase>test</phase>
                      <goals>
                          <goal>report</goal>
                      </goals>
                        <configuration>
                            <dataFile>${project.build.directory}/jacoco-ut.exec</dataFile>
                        </configuration>
                    </execution>
                    <execution>
                        <id>report-integration-tests</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>report-integration</goal>
                        </goals>
                        <configuration>
                            <dataFile>${project.build.directory}/jacoco-it.exec</dataFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <configuration>
                    <header>license-template.ftl</header>
                    <excludes>
                        <exclude>**/README</exclude>
                        <exclude>**/README.*</exclude>
                        <exclude>LICENSE</exclude>
                        <exclude>**/*.adoc</exclude>
                    </excludes>
                    <mapping>
                        <css>SLASHSTAR_STYLE</css>
                        <java>SLASHSTAR_STYLE</java>
                        <groovy>SLASHSTAR_STYLE</groovy>
                        <atom>XML_STYLE</atom>
                    </mapping>
                </configuration>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>format</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>com.mycila</groupId>
                        <artifactId>license-maven-plugin-git</artifactId>
                        <version>3.0</version>
                    </dependency>
                    <dependency>
                        <groupId>org.revapi</groupId>
                        <artifactId>revapi-build-support</artifactId>
                        <version>${version.revapi-build-support}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>net.revelc.code</groupId>
                <artifactId>impsort-maven-plugin</artifactId>
                <configuration>
                    <groups>java.,javax.,*</groups>
                    <staticGroups>java,javax,*</staticGroups>
                </configuration>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>sort</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
<!-- Enable this once we have formatter rules very similar to the current convention -->
<!--            <plugin>-->
<!--                <groupId>net.revelc.code.formatter</groupId>-->
<!--                <artifactId>formatter-maven-plugin</artifactId>-->
<!--                <executions>-->
<!--                    <execution>-->
<!--                        <phase>generate-sources</phase>-->
<!--                        <goals>-->
<!--                            <goal>format</goal>-->
<!--                        </goals>-->
<!--                    </execution>-->
<!--                </executions>-->
<!--            </plugin>-->
            <plugin>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>org.revapi</groupId>
                        <artifactId>revapi-build-support</artifactId>
                        <version>${version.revapi-build-support}</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>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <id>set-metadata-in-antora</id>
                        <phase>process-sources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <replaceregexp byline="true">
                                    <regexp pattern="^version: .*"/>
                                    <substitution expression="version: ${antora-module.version}"/>
                                    <fileset dir="${basedir}">
                                        <include name="src/site/antora.yml"/>
                                    </fileset>
                                </replaceregexp>
                                <replaceregexp byline="true">
                                    <regexp pattern="^title: .*"/>
                                    <substitution expression="title: ${project.name}"/>
                                    <fileset dir="${basedir}">
                                        <include name="src/site/antora.yml"/>
                                    </fileset>
                                </replaceregexp>
                                <replaceregexp byline="true">
                                    <regexp pattern="^name: .*"/>
                                    <substitution expression="name: ${project.artifactId}"/>
                                    <fileset dir="${basedir}">
                                        <include name="src/site/antora.yml"/>
                                    </fileset>
                                </replaceregexp>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>2.7</version>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>index</report>
                            <report>license</report>
                            <report>mailing-list</report>
                            <report>issue-tracking</report>
                            <report>scm</report>
                            <report>project-team</report>
                            <report>cim</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <source>8</source>
                </configuration>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>javadoc</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
            <plugin>
                <groupId>org.revapi</groupId>
                <artifactId>revapi-maven-plugin</artifactId>
                <version>${self-api-check.maven-version}</version>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>report</report>
                        </reports>
                    </reportSet>
                </reportSets>
                <configuration>
                    <analysisConfiguration>
                        <revapi.filter>
                            <archives>
                                <include>
                                    <item>${project.groupId}:${project.artifactId}:.*</item>
                                </include>
                            </archives>
                        </revapi.filter>
                    </analysisConfiguration>
                </configuration>
            </plugin>
        </plugins>
    </reporting>

    <profiles>
        <profile>
            <id>java9</id>
            <activation>
                <jdk>[9,]</jdk>
            </activation>
            <properties>
                <maven.compiler.release>8</maven.compiler.release>
            </properties>
        </profile>
        <profile>
            <id>java8</id>
            <activation>
                <jdk>[,1.8]</jdk>
            </activation>
            <build>
                <plugins>
                    <!-- skip the java9 enforcer check -->
                    <plugin>
                        <artifactId>maven-enforcer-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>java-version-check</id>
                                <configuration>
                                    <skip>true</skip>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>api-check</id>
            <activation>
		    <jdk>[,]</jdk>
            </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>
                                <revapi.java>
                                    <missing-classes>
                                        <behavior>report</behavior>
                                    </missing-classes>
                                </revapi.java>
                                <revapi.semver.ignore>
                                    <enabled>true</enabled>
                                    <passThroughDifferences>
                                        <item>java.class.nonPublicPartOfAPI</item>
                                    </passThroughDifferences>
                                </revapi.semver.ignore>
                                <revapi.differences>
                                    <ignore>true</ignore>
                                    <differences>
                                        <item>
                                            <regex>true</regex>
                                            <code>java.class.externalClassExposedInAPI</code>
                                            <newArchive>org\.revapi:revapi:.*</newArchive>
                                            <justification>
                                                Revapi sub-modules implement the Revapi API which makes them expose
                                                Revapi-specific classes usually. In our case this is generally OK because
                                                the modules are just Revapi extensions which are supposed to do that.
                                            </justification>
                                        </item>
                                        <item>
                                            <regex>true</regex>
                                            <code>java.class.externalClassExposedInAPI</code>
                                            <newArchive>org\.jboss:jboss-dmr:.*</newArchive>
                                            <justification>
                                                Revapi sub-modules implement the Revapi API which makes them expose
                                                Jboss DMR (which is part of our API). In our case this is generally OK
                                                because the modules are just Revapi extensions which are supposed to do
                                                that.
                                            </justification>
                                        </item>
                                        <item>
                                            <regex>true</regex>
                                            <code>java.class.nonPublicPartOfAPI</code>
                                            <newArchive>com\.fasterxml\.jackson\.core:.*:.*</newArchive>
                                            <justification>
                                                Revapi uses Jackson for representing the JSON configuration.
                                            </justification>
                                        </item>
                                        <item>
                                            <regex>true</regex>
                                            <code>java.class.externalClassExposedInAPI</code>
                                            <newArchive>com\.fasterxml\.jackson\.core:.*.*</newArchive>
                                            <justification>
                                                Revapi uses Jackson for representing the JSON configuration.
                                            </justification>
                                        </item>
                                    </differences>
                                </revapi.differences>
                            </analysisConfiguration>
                            <analysisConfigurationFiles>
                                <configurationFile>
                                    <path>api-changes.json</path>
                                    <roots>
                                        <!--suppress MavenModelInspection -->
                                        <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>
        <profile>
            <id>antora-release</id>
            <properties>
                <antora-module.version>${project.version}</antora-module.version>
            </properties>
        </profile>
    </profiles>

    <distributionManagement>
        <site>
            <id>site</id>
            <url>https://revapi.org</url>
        </site>
    </distributionManagement>

    <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>HEAD</tag>
    </scm>
</project>
