<?xml version="1.0" encoding="UTF-8"?>
<!--
~   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">

  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.basepom</groupId>
    <artifactId>basepom-minimal</artifactId>
    <version>55</version>
  </parent>

  <scm>
    <connection>scm:git:git://github.com/opentable/otj-pg-embedded.git</connection>
    <developerConnection>scm:git:git@github.com:opentable/otj-pg-embedded.git</developerConnection>
    <url>http://github.com/opentable/otj-pg-embedded</url>
    <tag>otj-pg-embedded-1.0.3</tag>
  </scm>

  <groupId>com.opentable.components</groupId>
  <artifactId>otj-pg-embedded</artifactId>
  <version>1.0.3</version>
  <description>Embedded PostgreSQL driver</description>

  <properties>
    <dep.plugin.gpg.version>3.1.0</dep.plugin.gpg.version>
    <dep.plugin.license.version>4.2</dep.plugin.license.version>
    <basepom.check.phase-license>validate</basepom.check.phase-license> <!-- this is overriding basepom default -->
    <basepom.license.skip-existing>true</basepom.license.skip-existing>
    <basepom.release.profiles>basepom.oss-release,oss-build</basepom.release.profiles>

    <basepom.check.skip-license>${basepom.check.skip-extended}</basepom.check.skip-license>
    <basepom.check.fail-license>${basepom.check.fail-extended}</basepom.check.fail-license>
    <basepom.check.skip-spotbugs>true</basepom.check.skip-spotbugs>
    <project.build.targetJdk>11</project.build.targetJdk>
    <maven.compiler.target>${project.build.targetJdk}</maven.compiler.target>
    <project.build.systemJdk>${project.build.targetJdk}</project.build.systemJdk>
    <dep.testcontainers.version>1.19.6</dep.testcontainers.version>
    <dep.postgres-jdbc.version>42.7.2</dep.postgres-jdbc.version>
    <dep.liquibase.version>4.23.1</dep.liquibase.version>
    <dep.slf4j.version>1.7.36</dep.slf4j.version>
    <dep.flyway.version>9.16.3</dep.flyway.version>
    <dep.commons-lang.version>3.14.0</dep.commons-lang.version>
    <dep.commons-compress.version>1.26.0</dep.commons-compress.version>
    <dep.junit.version>4.13.2</dep.junit.version>
    <dep.junit5.version>5.8.2</dep.junit5.version>
    <basepom.test.timeout>1800</basepom.test.timeout>
    <basepom.javadoc.skip>false</basepom.javadoc.skip>
    <basepom.oss.skip-scala-doc>true</basepom.oss.skip-scala-doc>
    <basepom.check.skip-javadoc>false</basepom.check.skip-javadoc>
    <basepom.check.fail-javadoc>false</basepom.check.fail-javadoc>
  </properties>

  <licenses>
    <license>
      <name>Apache License, Version 2.0</name>
      <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
      <comments>A business-friendly OSS license</comments>
    </license>
  </licenses>

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

    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
      <version>${dep.commons-lang.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-compress</artifactId>
      <version>${dep.commons-compress.version}</version>
      <scope>runtime</scope>
    </dependency>

    <dependency>
      <groupId>org.flywaydb</groupId>
      <artifactId>flyway-core</artifactId>
      <optional>true</optional>
      <version>${dep.flyway.version}</version>
    </dependency>

    <dependency>
      <groupId>org.liquibase</groupId>
      <artifactId>liquibase-core</artifactId>
      <version>${dep.liquibase.version}</version>
      <optional>true</optional>
    </dependency>

    <dependency>
      <groupId>org.postgresql</groupId>
      <artifactId>postgresql</artifactId>
      <version>${dep.postgres-jdbc.version}</version>
    </dependency>

    <dependency>
      <groupId>org.testcontainers</groupId>
      <artifactId>postgresql</artifactId>
    </dependency>
    <dependency>
      <groupId>org.testcontainers</groupId>
      <artifactId>testcontainers</artifactId>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${dep.junit.version}</version>
      <scope>provided</scope>
      <optional>true</optional>
    </dependency>

    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <version>${dep.junit5.version}</version>
      <scope>provided</scope>
      <optional>true</optional>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
      <version>${dep.slf4j.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.testcontainers</groupId>
        <artifactId>postgresql</artifactId>
        <version>${dep.testcontainers.version}</version>
       </dependency>
      <dependency>
        <groupId>org.testcontainers</groupId>
        <artifactId>testcontainers</artifactId>
        <version>${dep.testcontainers.version}</version>
       </dependency>
    </dependencies>
  </dependencyManagement>

  <profiles>
    <profile>
      <id>oss-build</id>
      <activation>
        <file>
          <exists>.oss-build</exists>
        </file>
      </activation>

      <!-- note the main difference is released artifacts go to oss.sonatype instead of internal -->
      <distributionManagement>
        <snapshotRepository>
          <id>opentable.snapshot</id>
          <name>opentable-snapshots</name>
          <uniqueVersion>true</uniqueVersion>
          <url>https://artifactory.otenv.com/snapshots</url>
        </snapshotRepository>
        <repository>
          <id>sonatype-nexus-staging</id>
          <name>Nexus Release Repository</name>
          <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
      </distributionManagement>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-release-plugin</artifactId>
              <configuration>
                <!-- activate some basepom stuff, this binds the profile below -->
                <releaseProfiles>${basepom.release.profiles}</releaseProfiles>
              </configuration>
            </plugin>

            <!-- checks for valid OSS license stuff and headers -->
            <plugin>
              <groupId>com.mycila</groupId>
              <artifactId>license-maven-plugin</artifactId>
              <version>${dep.plugin.license.version}</version>
              <dependencies>
                <dependency>
                  <groupId>org.basepom</groupId>
                  <artifactId>basepom-policy</artifactId>
                  <version>${dep.basepom-policy.version}</version>
                </dependency>
              </dependencies>
              <configuration>
                <skip>${basepom.check.skip-license}</skip>
                <skipExistingHeaders>${basepom.license.skip-existing}</skipExistingHeaders>
                <failIfMissing>${basepom.check.fail-license}</failIfMissing>
                <header>license/basepom-apache-license-header.txt</header>
                <headerDefinitions>
                  <headerDefinition>license/xml-prefix.xml</headerDefinition>
                </headerDefinitions>
                <mapping>
                  <xml>XML_PREFIX</xml>
                  <java>SLASHSTAR_STYLE</java>
                  <yaml>SCRIPT_STYLE</yaml>
                </mapping>
                <strictCheck>true</strictCheck>
                <aggregate>true</aggregate>
                <useDefaultExcludes>true</useDefaultExcludes>
                <encoding>${project.build.sourceEncoding}</encoding>
                <excludes>
                  <exclude>.*/**</exclude>
                  <exclude>**/*.md</exclude>
                  <exclude>**/*.rst</exclude>
                  <exclude>**/*.adoc</exclude>
                  <exclude>**/*.sh</exclude>
                  <exclude>**/*.txt</exclude>
                  <exclude>**/*.thrift</exclude>
                  <exclude>**/*.proto</exclude>
                  <exclude>**/*.g</exclude>
                  <exclude>**/*.releaseBackup</exclude>
                  <exclude>**/*.vm</exclude>
                  <exclude>**/*.st</exclude>
                  <exclude>**/*.raw</exclude>
                  <exclude>**/*.ser</exclude>
                  <exclude>**/src/license/**</exclude>
                </excludes>
                <includes>
                  <include>src/**</include>
                  <include>**/pom.xml</include>
                </includes>
              </configuration>
            </plugin>

            <!-- sign with gpg -->
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-gpg-plugin</artifactId>
              <version>${dep.plugin.gpg.version}</version>
              <configuration>
                <useAgent>true</useAgent>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>

        <!-- more license checking. One day I'll know why both of these -->
        <plugins>
          <plugin>
            <groupId>com.mycila</groupId>
            <artifactId>license-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>basepom.default</id>
                <phase>${basepom.check.phase-license}</phase>
                <goals>
                  <goal>check</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- Active during OSS release:perform -->
    <profile>
      <id>basepom.oss-release</id>
      <properties>
        <!-- tests run in the preparation step of the release -->
        <skipTests>true</skipTests>
      </properties>
      <build>
        <plugins>
          <!-- oss requires a javadoc jar. Build one when releasing. -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <phase>package</phase>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <!-- if necessary, build a scaladoc jar. Disabled by default. -->
<!--          <plugin>-->
<!--            <groupId>net.alchim31.maven</groupId>-->
<!--            <artifactId>scala-maven-plugin</artifactId>-->
<!--            <executions>-->
<!--              <execution>-->
<!--                <id>attach-scaladocs</id>-->
<!--                <phase>package</phase>-->
<!--                <configuration>-->
<!--                  <skip>${basepom.oss.skip-scala-doc}</skip>-->
<!--                </configuration>-->
<!--                <goals>-->
<!--                  <goal>doc-jar</goal>-->
<!--                </goals>-->
<!--              </execution>-->
<!--            </executions>-->
<!--          </plugin>-->
          <!-- Sign artifacts using gpg for oss upload -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <executions>
              <execution>
                <id>basepom.sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
