<?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>

    <groupId>com.github.susom</groupId>
    <artifactId>vertx-parent</artifactId>
    <version>1.6</version>
    <packaging>pom</packaging>

    <!-- These are here because Sonatype requires them for release to Maven Central,
         but we don't want our (parent pom) values. -->
    <name>${project.groupId}:${project.artifactId}</name>
    <description>To be provided by child pom.</description>
    <url>https://github.com/susom/vertx-parent</url>

    <licenses>
        <license>
            <name>To be provided by child pom.</name>
            <url>https://example.com/to-be-provided-by-child-pom</url>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>To be provided by child pom.</name>
            <email>to-be-provided-by-child-pom@example.com</email>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:https://github.com/susom/vertx-parent.git</connection>
        <developerConnection>scm:git:https://github.com/susom/vertx-parent.git</developerConnection>
        <url>https://github.com/susom/vertx-parent</url>
        <tag>v1.6</tag>
    </scm>

    <distributionManagement>
        <snapshotRepository>
            <id>io.cloudrepo.rit-public-snapshot</id>
            <url>https://susom.mycloudrepo.io/repositories/rit-public-snapshot</url>
        </snapshotRepository>
        <repository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <properties>
        <vertx.version>3.9.13</vertx.version>
        <checkerframework.version>2.1.14</checkerframework.version>
        <!-- Can't upgrade to 2.2.x yet because they changed the format of
             the stub files
        <checkerframework.version>2.2.0</checkerframework.version>
        -->
        <errorprone.version>2.1.3</errorprone.version>
        <maven.compiler.target>1.8</maven.compiler.target>
        <forbiddenapis.parent.txt>target/vertx-parent-files/forbidden-apis-parent.txt</forbiddenapis.parent.txt>
        <forbiddenapis.txt>src/tool/forbidden-apis.txt</forbiddenapis.txt>
        <checkstyle.parent.txt>target/vertx-parent-files/checkstyle.xml</checkstyle.parent.txt>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <!--
           NOTE: Below is the explicit/expanded version of:
                 <annotatedJdk>${org.checkerframework:jdk8:jar}</annotatedJdk>
           However, IntelliJ marks the shortened version as invalid, see:
                 https://stackoverflow.com/questions/50336147/checker-framework-cant-resolve-symbolannotatedjdkorg-checkerframeworkjdk8j
           for a discussion.
           -->
        <annotatedJdk>
            ${settings.localRepository}/org/checkerframework/jdk8/${checkerframework.version}/jdk8-${checkerframework.version}.jar
        </annotatedJdk>
    </properties>

    <modules>
        <module>vertx-parent-files</module>
    </modules>

    <dependencies>
        <dependency>
            <!-- This is used to get files into the child project so plugins can
                 reference them (for example configuration files for source code
                 static analysis) -->
            <groupId>com.github.susom</groupId>
            <artifactId>vertx-parent-files</artifactId>
            <version>1.6</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.github.susom</groupId>
            <artifactId>vertx-base</artifactId>
            <version>2.4</version>
        </dependency>
        <dependency>
            <groupId>com.github.susom</groupId>
            <artifactId>server-logging</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>org.checkerframework</groupId>
            <artifactId>checker-qual</artifactId>
            <version>${checkerframework.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.checkerframework</groupId>
            <artifactId>checker</artifactId>
            <version>${checkerframework.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.checkerframework</groupId>
            <artifactId>jdk8</artifactId>
            <version>${checkerframework.version}</version>
            <scope>provided</scope>
        </dependency>
        <!-- TODO vertx-base embeds some Spring stuff that needs JCL -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>1.7.36</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-unit</artifactId>
            <version>${vertx.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <!-- Unpack files from vertx-parent-files so later plugins can use them
                     (some plugins require actual files for config rather than
                     using resources) -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.10</version>
                <configuration>
                    <outputDirectory>${project.build.directory}/vertx-parent-files</outputDirectory>
                    <includeArtifactIds>vertx-parent-files</includeArtifactIds>
                </configuration>
                <executions>
                    <execution>
                        <id>unpack-parent-files</id>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <phase>package</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.20</version>
                <configuration>
                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.20</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
                </configuration>
            </plugin>
            <!-- NOTE: We are using the maven release plugin to deploy to Maven Central, see:
      https://central.sonatype.org/pages/apache-maven.html#performing-a-release-deployment-with-the-maven-release-plugin
      for explanation as to why the useReleaseProfile is set to false. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.5.3</version>
                <configuration>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                    <useReleaseProfile>false</useReleaseProfile>
                    <releaseProfiles>release</releaseProfiles>
                    <goals>deploy</goals>
                </configuration>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.7.0</version>
                    <configuration>
                        <source>8</source>
                        <target>8</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>3.1.1</version>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                            <configuration>
                                <filters>
                                    <filter>
                                        <artifact>*:*</artifact>
                                        <excludes>
                                            <exclude>META-INF/*.SF</exclude>
                                            <exclude>META-INF/*.DSA</exclude>
                                            <exclude>META-INF/*.RSA</exclude>
                                        </excludes>
                                    </filter>
                                </filters>
                                <transformers>
                                    <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                        <mainClass>${main.class}</mainClass>
                                    </transformer>
                                </transformers>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.0.2</version>
                    <configuration>
                        <!-- To avoid overlapping classes warnings from shade plugin -->
                        <forceCreation>true</forceCreation>
                    </configuration>
                    <executions>
                        <execution>
                            <id>default-jar</id>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                            <phase>package</phase>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>3.1.1</version>
                    <executions>
                        <execution>
                            <id>make-assembly</id>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <finalName>deploy</finalName>
                        <appendAssemblyId>false</appendAssemblyId>
                        <descriptors>
                            <descriptor>target/vertx-parent-files/deploy-zip.xml</descriptor>
                        </descriptors>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>3.0.1</version>
                    <executions>
                        <execution>
                            <id>attach-sources</id>
                            <goals>
                                <goal>jar-no-fork</goal>
                            </goals>
                            <configuration>
                                <includes>
                                    <include>**/*</include>
                                </includes>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>2.10.4</version>
                    <executions>
                        <execution>
                            <id>attach-javadocs</id>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                            <configuration>
                                <additionalparam>-Xdoclint:none</additionalparam>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>

    </build>

    <profiles>
        <profile>
            <id>hsql</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.hsqldb</groupId>
                    <artifactId>hsqldb</artifactId>
                    <version>2.5.1</version>
                    <scope>runtime</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <includes>
                                <include>**/*DaoTest</include>
                                <include>**/*DbTest</include>
                                <include>**/*HsqlTest</include>
                            </includes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>postgres</id>
            <dependencies>
                <dependency>
                    <groupId>org.postgresql</groupId>
                    <artifactId>postgresql</artifactId>
                    <version>42.4.1</version>
                    <scope>runtime</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <includes>
                                <include>**/*DaoTest</include>
                                <include>**/*DbTest</include>
                                <include>**/*PostgresTest</include>
                            </includes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>oracle12</id>
            <dependencies>
                <dependency>
                    <groupId>com.oracle</groupId>
                    <artifactId>ojdbc7</artifactId>
                    <version>12.1.0.2</version>
                    <scope>runtime</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <includes>
                                <include>**/*DaoTest</include>
                                <include>**/*DbTest</include>
                                <include>**/*OracleTest</include>
                            </includes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>check-errorprone</id>
            <!-- Error Prone is a static analysis tool for checking Java code. For more
                 information see http://errorprone.info/ and https://github.com/google/error-prone -->
            <activation>
                <property>
                    <!-- We use two sets of checking profiles because errorprone and the checker framework conflict -->
                    <name>check1</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>3.7.0</version>
                        <configuration>
                            <source>8</source>
                            <target>8</target>
                            <compilerId>javac-with-errorprone</compilerId>
                            <forceJavacCompilerUse>true</forceJavacCompilerUse>
                        </configuration>
                        <dependencies>
                            <dependency>
                                <groupId>org.codehaus.plexus</groupId>
                                <artifactId>plexus-compiler-javac-errorprone</artifactId>
                                <version>2.8.2</version>
                            </dependency>
                            <dependency>
                                <groupId>com.google.errorprone</groupId>
                                <artifactId>error_prone_core</artifactId>
                                <version>${errorprone.version}</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>check-macker</id>
            <!-- Macker enforces architectural constraints (static Java code dependencies)
                 for more information see https://innig.net/macker/ and
                 https://github.com/andrena/macker-maven-plugin -->
            <activation>
                <property>
                    <name>check1</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>de.andrena.tools.macker</groupId>
                        <artifactId>macker-maven-plugin</artifactId>
                        <version>1.0.2</version>
                        <configuration>
                            <rule>src/tool/macker-rules.xml</rule>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>compile</phase>
                                <goals>
                                    <goal>macker</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>check-forbidden</id>
            <!-- The Forbidden APIs tool makes sure your code does not call certain
                 unsafe or undesirable classes or methods. For more information see
                 https://github.com/policeman-tools/forbidden-apis -->
            <activation>
                <property>
                    <name>check1</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>de.thetaphi</groupId>
                        <artifactId>forbiddenapis</artifactId>
                        <version>3.3</version>
                        <configuration>
                            <failOnUnsupportedJava>true</failOnUnsupportedJava>
                            <bundledSignatures>
                                <bundledSignature>jdk-unsafe</bundledSignature>
                                <bundledSignature>jdk-deprecated</bundledSignature>
                                <bundledSignature>jdk-internal</bundledSignature>
                                <bundledSignature>jdk-non-portable</bundledSignature>
                                <bundledSignature>jdk-reflection</bundledSignature>
                            </bundledSignatures>
                            <signaturesFiles>
                                <signaturesFile>${forbiddenapis.parent.txt}</signaturesFile>
                                <signaturesFile>${forbiddenapis.txt}</signaturesFile>
                            </signaturesFiles>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>check</goal>
                                    <goal>testCheck</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>checkstyle</id>
            <!-- Checkstyle enforces some basic code formatting (e.g. spaces, not tabs).
                 For more information see https://github.com/checkstyle/checkstyle -->
            <activation>
                <property>
                    <name>check1</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <!-- Use checkstyle to verify basic source code formatting -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-checkstyle-plugin</artifactId>
                        <version>3.1.0</version>
                        <dependencies>
                            <dependency>
                                <groupId>com.puppycrawl.tools</groupId>
                                <artifactId>checkstyle</artifactId>
                                <version>8.29</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution>
                                <id>validate</id>
                                <phase>verify</phase>
                                <configuration>
                                    <configLocation>${checkstyle.parent.txt}</configLocation>
                                    <encoding>UTF-8</encoding>
                                    <consoleOutput>true</consoleOutput>
                                    <failsOnError>true</failsOnError>
                                    <violationSeverity>warning</violationSeverity>
                                </configuration>
                                <goals>
                                    <goal>check</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>checker</id>
            <!-- The Checker Framework is a static analysis tool that can perform
                 many kinds of advanced error checking. We use it primarily for
                 making sure there are no SQL injection security problems. For
                 more information see http://types.cs.washington.edu/checker-framework/ -->
            <activation>
                <property>
                    <!-- We use two sets of checking profiles because errorprone and the checker framework conflict -->
                    <name>check2</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>properties</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>3.7.0</version>
                        <configuration>
                            <source>8</source>
                            <target>8</target>
                            <fork>true</fork>
                            <annotationProcessors>
                                <!--<annotationProcessor>org.checkerframework.checker.nullness.NullnessChecker</annotationProcessor>-->
                                <annotationProcessor>org.checkerframework.checker.tainting.TaintingChecker</annotationProcessor>
                            </annotationProcessors>
                            <compilerArgs>
                                <arg>-J-Xmx1g</arg>
                                <arg>-J-Xss32m</arg>
                                <arg>-Xbootclasspath/p:${annotatedJdk}</arg>
                                <arg>-version</arg>
                                <arg>-AprintErrorStack</arg>
                                <arg>-AprintAllQualifiers</arg>
                                <arg>-AatfCacheSize=400</arg>
                                <arg>-Astubs=${com.github.susom:database:jar}</arg>
                            </compilerArgs>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>release</id>
            <properties>
                <gpg.executable>gpg</gpg.executable>
                <gpg.keyname>${env.GPG_KEY_NAME}</gpg.keyname>
                <gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.6.6</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
