<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.postgresql</groupId>
    <artifactId>pgjdbc-core-parent</artifactId>
    <version>1.1.6</version>
    <relativePath />
  </parent>

  <artifactId>postgresql</artifactId>
  <packaging>bundle</packaging>
  <name>PostgreSQL JDBC Driver - JDBC 4.2</name>
  <version>42.2.10</version>
  <description>Java JDBC 4.2 (JRE 8+) driver for PostgreSQL database</description>
  <url>https://github.com/pgjdbc/pgjdbc</url>

  <licenses>
    <license>
      <name>BSD-2-Clause</name>
      <url>https://jdbc.postgresql.org/about/license.html</url>
    </license>
  </licenses>

  <organization>
    <name>PostgreSQL Global Development Group</name>
    <url>https://jdbc.postgresql.org/</url>
  </organization>

  <properties>
    <!-- Require JDK 1.8 or later -->
    <javac.target>1.8</javac.target>
    <postgresql.enforce.jdk.version>1.8</postgresql.enforce.jdk.version>
    <jdbc.specification.version>4.2</jdbc.specification.version>
    <jdbc.specification.version.nodot>42</jdbc.specification.version.nodot>
    <skip.assembly>false</skip.assembly>
    <checkstyle.version>8.29</checkstyle.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>com.ongres.scram</groupId>
      <artifactId>client</artifactId>
      <version>2.1</version>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>translate</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>com.github.vlsi.gettext</groupId>
            <artifactId>gettext-maven-plugin</artifactId>
            <version>1.4.0</version>
            <executions>
              <execution>
                <id>update_po_with_new_messages</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>gettext</goal>
                </goals>
              </execution>
              <execution>
                <id>remove_obsolete_translations</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>attrib</goal>
                </goals>
                <configuration>
                  <extraArgs>
                    <extraArg>--no-obsolete</extraArg>
                  </extraArgs>
                </configuration>
              </execution>
              <execution>
                <id>generate_pot_and_po_files</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>merge</goal>
                </goals>
              </execution>
              <execution>
                <id>generate_resource_bundles</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>dist</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <outputFormat>java</outputFormat>
              <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
              <outputDirectory>${project.build.sourceDirectory}</outputDirectory>
              <keysFile>messages.pot</keysFile>
              <poDirectory>src/main/java/org/postgresql/translation</poDirectory>
              <targetBundle>org.postgresql.translation.messages</targetBundle>
              <keywords>-kGT.tr</keywords>
              <msgmergeCmd>msgmerge</msgmergeCmd>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>excludeWaffleFiles</id>
      <activation>
        <property>
          <name>waffleEnabled</name>
          <value>false</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
              <excludes combine.children="append">
                <exclude>org/postgresql/sspi/NTDSAPI.java</exclude>
                <exclude>org/postgresql/sspi/NTDSAPIWrapper.java</exclude>
                <exclude>org/postgresql/sspi/SSPIClient.java</exclude>
              </excludes>
              <testExcludes>
                <exclude>org/postgresql/test/sspi/*.java</exclude>
              </testExcludes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>excludeOsgiFiles</id>
      <activation>
        <property>
          <name>osgiEnabled</name>
          <value>false</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
              <excludes combine.children="append">
                <exclude>org/postgresql/osgi/PGBundleActivator.java</exclude>
                <exclude>org/postgresql/osgi/PGDataSourceFactory.java</exclude>
              </excludes>
              <testExcludes combine.children="append">
                <exclude>**/PGDataSourceFactoryTest.java</exclude>
                <exclude>**/OsgiTestSuite.java</exclude>
              </testExcludes>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <excludes>
                <exclude>**/OsgiTestSuite.java</exclude>
                <exclude>**/PGDataSourceFactoryTest.java</exclude>
              </excludes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>jdk9-workarounds</id>
      <!-- see https://github.com/pgjdbc/pgjdbc/pull/565 -->
      <activation>
        <property>
          <name>javac.target</name>
          <value>1.9</value>
        </property>
      </activation>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-source-plugin</artifactId>
              <dependencies>
                <dependency>
                  <groupId>org.codehaus.plexus</groupId>
                  <artifactId>plexus-archiver</artifactId>
                  <version>2.4.4</version>
                  <!-- newer versions fail as described in http://stackoverflow.com/a/36605759/1261287
                       Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
                        at org.codehaus.plexus.archiver.zip.AbstractZipArchiver.<clinit>(AbstractZipArchiver.java:116)
                  -->
                </dependency>
              </dependencies>
            </plugin>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-jar-plugin</artifactId>
              <dependencies>
                <dependency>
                  <groupId>org.codehaus.plexus</groupId>
                  <artifactId>plexus-archiver</artifactId>
                  <version>2.4.4</version>
                </dependency>
              </dependencies>
            </plugin>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-assembly-plugin</artifactId>
              <version>2.4.1</version> <!-- override version to older one -->
              <dependencies>
                <dependency>
                  <groupId>org.codehaus.plexus</groupId>
                  <artifactId>plexus-archiver</artifactId>
                  <version>2.4.4</version>
                </dependency>
              </dependencies>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>

  </profiles>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>
        <configuration>
          <chmod>true</chmod>
          <inputEncoding>UTF-8</inputEncoding>
          <outputEncoding>UTF-8</outputEncoding>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.8.5</version>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifestEntries>
              <Automatic-Module-Name>org.postgresql.jdbc</Automatic-Module-Name>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>3.1.0</version>
        <configuration>
          <minimizeJar>true</minimizeJar>
          <filters>
            <filter>
              <artifact>com.ongres.scram:client</artifact>
              <includes>
                <include>**</include>
              </includes>
            </filter>
            <filter>
              <artifact>com.github.waffle:waffle-jna</artifact>
              <excludes>
                <exclude>**</exclude>
              </excludes>
            </filter>
            <filter>
              <artifact>org.slf4j:jcl-over-slf4j</artifact>
              <excludes>
                <exclude>**</exclude>
              </excludes>
            </filter>
            <filter>
              <artifact>*:*</artifact>
              <excludes>
                <exclude>com/sun/jna/**</exclude>
              </excludes>
            </filter>
          </filters>
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <relocations>
                <relocation>
                  <pattern>com.ongres</pattern>
                  <shadedPattern>org.postgresql.shaded.com.ongres</shadedPattern>
                </relocation>
              </relocations>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.karaf.tooling</groupId>
        <artifactId>karaf-maven-plugin</artifactId>
        <version>4.2.5</version>
        <extensions>true</extensions>
        <configuration>
          <startLevel>80</startLevel>
          <includeTransitiveDependency>false</includeTransitiveDependency>
          <aggregateFeatures>false</aggregateFeatures>
          <includeProjectArtifact>true</includeProjectArtifact>
        </configuration>
        <executions>
          <execution>
            <id>generate-features-file</id>
            <phase>package</phase>
            <goals>
              <goal>features-generate-descriptor</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>

    <pluginManagement>
      <plugins>
        <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>${checkstyle.version}</version>
            </dependency>
          </dependencies>
          <configuration>
            <configLocation>src/main/checkstyle/checks.xml</configLocation>
            <suppressionsLocation>src/main/checkstyle/suppressions.xml</suppressionsLocation>
            <violationSeverity>error</violationSeverity>
            <failOnViolation>true</failOnViolation>
            <failsOnError>true</failsOnError>
            <consoleOutput>true</consoleOutput>
            <includeTestSourceDirectory>true</includeTestSourceDirectory>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <configuration>
            <failOnWarnings>true</failOnWarnings>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <scm>
    <tag>REL42.2.10</tag>
  </scm>
</project>
