<?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>
  <name>Oracle NoSQL Database SDK for Java</name>
  <description>
    This project contains the SDK used for Oracle NoSQL Database
  </description>
  <url>https://github.com/oracle/nosql-java-sdk</url>
  <licenses>
    <license>
      <name>The Universal Permissive License (UPL), Version 1.0</name>
      <url>https://www.oracle.com/downloads/licenses/upl-license1.html</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  <developers>
    <developer>
      <id>oracle</id>
      <name>Oracle</name>
      <organizationUrl>https://www.oracle.com</organizationUrl>
    </developer>
  </developers>
  <scm>
    <connection>scm:git:git@github.com:oracle/nosql-java-sdk.git</connection>
    <url>https://github.com/oracle/nosql-java-sdk</url>
  </scm>

  <groupId>com.oracle.nosql.sdk</groupId>
  <artifactId>nosqldriver</artifactId>
  <version>5.4.17</version>
  <packaging>jar</packaging>

  <organization>
    <name>Oracle Corporation</name>
    <url>http://www.oracle.com/</url>
  </organization>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <timestamp>${maven.build.timestamp}</timestamp>
    <maven.build.timestamp.format>d-MMMM-yyyy</maven.build.timestamp.format>
    <copyright>Copyright (c) 2011, 2024 Oracle and/or its affiliates. All rights reserved.</copyright>
    <java.apidoc>http://docs.oracle.com/javase/8/docs/api</java.apidoc>
    <maven.deploy.skip>false</maven.deploy.skip>
    <netty.version>4.1.118.Final</netty.version>
    <jackson.version>2.15.2</jackson.version>
   <!-- by default, skip tests; tests require a profile -->
   <maven.test.skip>true</maven.test.skip>
   <javac>javac</javac>
  </properties>

  <profiles>

    <!-- test profiles used with the test target
         Running tests requires a running on-premises service and httpproxy
         or a running cloud simulator. Required information:
            o endpoint
         Examples:
           mvn -Ptest-cloudsim test -DargLine="-Dtest.endpoint=http://localhost:8080"
           mvn -Ptest-onprem test -DargLine="-Dtest.endpoint=http://localhost:8090"

        These tests are not designed to work directly against the cloud service
        as they require a high rate of DDL operations and generally use more
        resource than a user might want to use in the cloud.

        A secure, onprem configuration requires more information:
          1. user name and password
          2. trust store and optional password for the SSL certificate to use to
          communicate with the proxy
        These are also passed as system properties, e.g.:
          mvn -Ptest-onprem-secure test -DargLine="-Dtest.endpoint=<secure-endpoint> -Dtest.user=<username> -Dtest.password=<user-password> -Dtest.trust=<path-to-trust-store> -Dtest.trust.password=<trust-store-password>"

        Individual test methods can be traced by adding "-Dtest.trace=true" to
        the argLine string
    -->
    <profile>
      <id>test-cloudsim</id>
      <properties>
        <maven.test.skip>false</maven.test.skip>
        <secure>false</secure>
        <onprem>false</onprem>
        <serverType>cloudsim</serverType>
        <!-- exclude non-server tests and on-premises tests -->
        <excluded.tests>
          StoreAccessTokenProviderTest.java, ResourcePrincipalProviderTest.java,
          ConfigFileTest.java, SignatureProviderTest.java,
          UserProfileProviderTest.java, InstancePrincipalsProviderTest.java,
          HandleConfigTest.java, JsonTest.java, ValueTest.java,
          OnPremiseTest.java, ConnectionPoolTest.java
        </excluded.tests>
      </properties>
    </profile>

    <profile>
      <id>test-onprem</id>
      <properties>
        <maven.test.skip>false</maven.test.skip>
        <secure>false</secure>
        <onprem>true</onprem>
        <serverType>onprem</serverType>
        <!-- exclude non-server tests -->
        <excluded.tests>
          StoreAccessTokenProviderTest.java, ResourcePrincipalProviderTest.java,
          ConfigFileTest.java, SignatureProviderTest.java,
          UserProfileProviderTest.java, InstancePrincipalsProviderTest.java,
          HandleConfigTest.java, JsonTest.java, ValueTest.java, ConnectionPoolTest.java
        </excluded.tests>
      </properties>
    </profile>

    <profile>
      <id>test-onprem-secure</id>
      <properties>
        <maven.test.skip>false</maven.test.skip>
        <secure>true</secure>
        <onprem>true</onprem>
        <serverType>onprem</serverType>
        <!-- exclude non-server tests -->
        <excluded.tests>
          StoreAccessTokenProviderTest.java, ResourcePrincipalProviderTest.java,
          ConfigFileTest.java, SignatureProviderTest.java,
          UserProfileProviderTest.java, InstancePrincipalsProviderTest.java,
          HandleConfigTest.java, JsonTest.java, ValueTest.java, ConnectionPoolTest.java
        </excluded.tests>
        <maven.buildNumber.doCheck>false</maven.buildNumber.doCheck>
      </properties>
    </profile>

    <!-- these tests require no server; new tests of that nature go here -->
    <profile>
      <id>test-local</id>
      <properties>
        <maven.test.skip>false</maven.test.skip>
        <local>true</local>
        <serverType>none</serverType>
        <included.tests>
          StoreAccessTokenProviderTest.java, ResourcePrincipalProviderTest.java,
          ConfigFileTest.java, SignatureProviderTest.java,
          UserProfileProviderTest.java, InstancePrincipalsProviderTest.java,
          HandleConfigTest.java, JsonTest.java, ValueTest.java,
          SessionTokenProviderTest.java
        </included.tests>
      </properties>
    </profile>

    <!-- skip javadoc -->
    <profile>
      <id>xdoc</id>
      <properties>
        <maven.javadoc.skip>true</maven.javadoc.skip>
      </properties>
    </profile>

        <!-- The profile to run eclipse compiler check -->
    <!--
      It sets the compiler output directory to target/ecj-target, making sure that
      we don't accidentally use ecj compiled classes in release package.
      It also triggers `clean` phase automatically.
    -->
    <profile>
      <id>warnings</id>
      <build>
        <directory>${project.basedir}/target/ecj-target</directory>
        <pluginManagement>
          <plugins>
            <plugin>
              <artifactId>maven-compiler-plugin</artifactId>
              <version>3.11.0</version>
              <configuration>
                <compilerId>eclipse</compilerId>
                <fork>true</fork>
                <debug>false</debug>
                <failOnWarning>false</failOnWarning>
                <compilerArgs>
                  <arg>-properties</arg>
                  <arg>${maven.multiModuleProjectDirectory}/.settings/org.eclipse.jdt.core.prefs</arg>
                  <arg>-enableJavadoc</arg>
                  <arg>-Xemacs</arg>
                </compilerArgs>
              </configuration>

              <dependencies>
                <dependency>
                  <groupId>org.codehaus.plexus</groupId>
                  <artifactId>plexus-compiler-eclipse</artifactId>
                  <version>2.13.0</version>
                </dependency>

                <dependency>
                  <groupId>org.eclipse.jdt</groupId>
                  <artifactId>ecj</artifactId>
                  <version>3.34.0</version>
                </dependency>
              </dependencies>
            </plugin>
          </plugins>
        </pluginManagement>
        <plugins>
          <plugin>
            <artifactId>maven-clean-plugin</artifactId>
            <executions>
              <execution>
                <id>auto-clean</id>
                <phase>initialize</phase>
                <goals>
                  <goal>clean</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

  </profiles>
  <dependencies>

    <!-- jackson core - JSON processing -->
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
      <version>${jackson.version}</version>
    </dependency>

    <!-- Netty - networking -->
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-buffer</artifactId>
      <version>${netty.version}</version>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-codec-http</artifactId>
      <version>${netty.version}</version>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-handler</artifactId>
      <version>${netty.version}</version>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-handler-proxy</artifactId>
      <version>${netty.version}</version>
    </dependency>

    <!-- test -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.13.1</version>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>3.3.1</version>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>3.3.1</version>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.11.0</version>
        <configuration>
          <fork>true</fork>
          <source>1.8</source>
          <target>1.8</target>
          <showDeprecation>true</showDeprecation>
          <showWarnings>true</showWarnings>
          <compilerArgument>-Xlint:all</compilerArgument>
          <!-- this is parameterized to allow it to be overridden -->
          <executable>${javac}</executable>
        </configuration>
      </plugin>
      <plugin>
        <!-- test plugin -->
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.1.2</version>
        <configuration>
          <!-- uncomment below to write stdout to files
               in target/surefire-reports -->
          <!-- <redirectTestOutputToFile>true</redirectTestOutputToFile> -->
          <workingDirectory>${project.build.directory}/test-run</workingDirectory>
          <systemPropertyVariables>
            <test.serverType>${serverType}</test.serverType>
            <test.secure>${secure}</test.secure>
            <test.onprem>${onprem}</test.onprem>
            <test.local>${local}</test.local>
          </systemPropertyVariables>
          <includes>
            <include>${included.tests}</include>
          </includes>
          <excludes>
            <exclude>${excluded.tests}</exclude>
          </excludes>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.3.0</version>
        <configuration>
          <archive>
            <manifest>
              <addDefaultEntries>false</addDefaultEntries>
              <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
              <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
              <addBuildEnvironmentEntries>true</addBuildEnvironmentEntries>
              <addClasspath>true</addClasspath>
              <!--  drop version from dependent jar files in manifest class path
              -->
              <classpathLayoutType>custom</classpathLayoutType>
              <customClasspathLayout>
                $${artifact.artifactId}.$${artifact.extension}
              </customClasspathLayout>
              <mainClass>oracle.nosql.driver.DriverMain</mainClass>
            </manifest>
            <manifestEntries>
              <Build-Id>${buildNumber}</Build-Id>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>
      <!-- this plugin is used to add Build-Id to the manifest -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>buildnumber-maven-plugin</artifactId>
        <version>3.2.0</version>
        <executions>
          <execution>
            <phase>validate</phase>
            <goals>
              <goal>create</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <!-- allow this to work with local changes, don't update the repo-->
          <doCheck>false</doCheck>
          <doUpdate>false</doUpdate>
          <!-- shorten git changeset to first 8 characters-->
          <shortRevisionLength>8</shortRevisionLength>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-install-plugin</artifactId>
        <version>3.1.1</version>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>3.3.0</version>
        <executions>
          <execution>
            <id>attach-sources</id>
            <phase>install</phase>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- javadoc -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.5.0</version>
        <configuration>
          <quiet>true</quiet>
          <doclint>-missing</doclint>
          <source>8</source>
          <doctitle>${project.name} ${project.version}</doctitle>
          <windowtitle>${project.name} ${project.version}</windowtitle>
          <!-- exclude these packages.
               TODO: the this list should include
               oracle.nosql.driver.ops.serde. The problem is that if added
               javadoc fails as it tries to operate on files in that package anyway.
               May need to post-process the doc to remove the package and link.
          -->
          <excludePackageNames>
            oracle.nosql.driver.http;oracle.nosql.driver.httpclient;oracle.nosql.driver.query;oracle.nosql.driver.util;oracle.nosql.driver.ops.serde;oracle.nosql.driver.ops.serde.nson;oracle.nosql.driver.iam.pki
          </excludePackageNames>
          <show>public</show>
          <header>
            <![CDATA[<b>Oracle NoSQL Database</b><br><font size=\"-1\"> Version ${project.version} ${maven.build.timestamp}</font>]]>
          </header>
          <bottom><![CDATA[<font size=1>${copyright}</font>]]> </bottom>
          <additionalOptions>
            <additionalOption>-author</additionalOption>
          </additionalOptions>
          <!-- put output in target/apidocs -->
          <reportOutputDirectory>
            ${project.build.directory}/apidocs
          </reportOutputDirectory>
        </configuration>
        <executions>
          <execution>
            <id>javadoc-jar</id>
            <goals>
              <goal>jar</goal>
              <goal>javadoc</goal>
            </goals>
            <phase>install</phase>
          </execution>
        </executions>
      </plugin>

      <!-- create the tar.gz and .zip archives in package phase -->
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
          <!-- suppress warning about long paths in tarball -->
          <tarLongFileMode>gnu</tarLongFileMode>
          <!--
              Drop the version on the name of the tar.gz and zip files generated.
              Add it to the archive name when released.
          -->
          <finalName>oracle-nosql-java-sdk</finalName>
          <!-- assembly id is "sdk," don't append it to the archive names -->
          <appendAssemblyId>false</appendAssemblyId>
          <!-- don't deploy at this time -->
          <attach>true</attach>
          <descriptors>
            <descriptor>src/main/assembly/sdk.xml</descriptor>
          </descriptors>
        </configuration>
        <executions>
          <execution>
            <id>make-assembly</id>
            <phase>install</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- add license files to jar files -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>3.1.0</version>
        <executions>
          <execution>
            <id>Generate SDK Version strings</id>
            <phase>generate-sources</phase>
            <configuration>
              <executable>${basedir}/scripts/generate_version_strings.sh</executable>
            </configuration>
            <goals>
              <goal>exec</goal>
            </goals>
          </execution>
          <execution>
            <id>human-readable NSON string generation</id>
            <phase>generate-sources</phase>
            <configuration>
              <executable>${basedir}/scripts/build_nson_strings.sh</executable>
            </configuration>
            <goals>
              <goal>exec</goal>
            </goals>
          </execution>
          <execution>
            <id>add license files to runtime jar</id>
            <phase>package</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>jar</executable>
              <workingDirectory>${basedir}/target</workingDirectory>
              <arguments>
                <argument>uf</argument>
                <argument>nosqldriver.jar</argument>
                <argument>../../LICENSE.txt</argument>
                <argument>../../THIRD_PARTY_LICENSES.txt</argument>
              </arguments>
            </configuration>
          </execution>
          <execution>
            <id>add license file to javadoc jar</id>
            <phase>install</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>jar</executable>
              <workingDirectory>${basedir}/target</workingDirectory>
              <arguments>
                <argument>uf</argument>
                <argument>nosqldriver-javadoc.jar</argument>
                <argument>../../LICENSE.txt</argument>
              </arguments>
            </configuration>
          </execution>
          <execution>
            <id>add license file to source jar</id>
            <phase>install</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>jar</executable>
              <workingDirectory>${basedir}/target</workingDirectory>
              <arguments>
                <argument>uf</argument>
                <argument>nosqldriver-sources.jar</argument>
                <argument>../../LICENSE.txt</argument>
              </arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
