<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.cyberark.conjur.api</groupId>
  <artifactId>conjur-api</artifactId>
  	<!--
		DO NOT UPDATE THE VERSION HERE
		The current version is stored in the changelog.
		When the package is built this place holder
		version will be replaced with the latest version
		from the changelog.
		See build-package.sh
	-->
	<version>3.1.0</version>
  <packaging>jar</packaging>

  <name>Conjur</name>
  <description>Programmatic Java access to the Conjur API</description>
  <url>https://github.com/cyberark/conjur-api-java</url>

  <licenses>
    <license>
      <name>The Apache License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>

  <developers>
    <developer>
      <name>Cyberark Conjur</name>
      <email>conj_maintainers@cyberark.com</email>
      <organization>Cyberark Software Ltd.</organization>
      <organizationUrl>https://conjur.org</organizationUrl>
    </developer>
  </developers>

  <scm>
    <connection>scm:git:git://github.com/cyberark/conjur-api-java.git</connection>
    <developerConnection>scm:git:ssh://github.com:cyberark/conjur-api-java.git</developerConnection>
    <url>https://github.com/cyberark/conjur-api-java</url>
  </scm>

  <profiles>
    <!-- Profile for activating Artifactory as our deployment goal -->
    <profile>
      <id>artifactory</id>
      <distributionManagement>
        <repository>
          <id>conjurinc-releases</id>
          <name>conjurinc-releases</name>
          <url>https://${env.JFROG_URL}/conjurinc/libs-release-local</url>
        </repository>
        <snapshotRepository>
          <id>conjurinc-snapshots</id>
          <name>conjurinc-snapshots</name>
          <url>https://${env.JFROG_URL}/conjurinc/libs-snapshot-local</url>
        </snapshotRepository>
      </distributionManagement>
    </profile>

    <!-- Profile for deploying and releasing to Maven Central through Central Portal -->
    <profile>
      <id>central-portal</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.sonatype.central</groupId>
            <artifactId>central-publishing-maven-plugin</artifactId>
            <version>0.7.0</version>
            <extensions>true</extensions>
            <configuration>
              <publishingServerId>central</publishingServerId>
              <autoPublish>true</autoPublish>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>3.2.1</version>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar-no-fork</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>3.4.0</version>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- Profile for signing releases -->
    <profile>
      <id>sign</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>1.5</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
                <configuration>
                  <!-- This is necessary for gpg to not try to use the pinentry programs -->
                  <gpgArguments>
                    <arg>--pinentry-mode</arg>
                    <arg>loopback</arg>
                    <arg>--passphrase-file</arg>
                    <arg>/gpg_password</arg>
                  </gpgArguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <jakarta.version>3.0.0</jakarta.version>
      <jersey.version>3.0.17</jersey.version>
    </properties>
    <dependencies>
    
      <!-- 
        JAX-RX Interface, compatible with Java 8.
      -->
      <dependency>
        <groupId>jakarta.ws.rs</groupId>
        <artifactId>jakarta.ws.rs-api</artifactId>
        <version>${jakarta.version}</version>
      </dependency>

      <!--
        JAX-RS Implementation Jersey, exclude and override to use another implementation.
      -->
      <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-client</artifactId>
        <version>${jersey.version}</version>
      </dependency>
      <dependency>
          <groupId>org.glassfish.jersey.inject</groupId>
          <artifactId>jersey-hk2</artifactId>
          <version>${jersey.version}</version>
      </dependency>

      <dependency>
        <groupId>jakarta.activation</groupId>
        <artifactId>jakarta.activation-api</artifactId>
        <version>2.0.1</version>
      </dependency>

      <!-- JSON support -->
      <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.10.1</version>
      </dependency>

      <!-- to work with token expirations -->
      <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>2.12.6</version>
      </dependency>

      <!-- for base64 -->
      <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
        <version>1.15</version>
      </dependency>
    
      <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.13.1</version>
        <scope>test</scope>
      </dependency>

      <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-core</artifactId>
        <version>4.0.0</version>
        <scope>test</scope>
      </dependency>

    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>5.7.2</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.7.2</version>
        <scope>test</scope>
    </dependency>
    </dependencies>

    <build>
      <sourceDirectory>src/main/java</sourceDirectory>
        <plugins>
          <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
              <source>1.8</source>
              <target>1.8</target>
            </configuration>
          </plugin>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.2</version>
            <configuration>
              <systemPropertyVariables>
                <CONJUR_ACCOUNT>${env.CONJUR_ACCOUNT}</CONJUR_ACCOUNT>
                <CONJUR_APPLIANCE_URL>${env.CONJUR_APPLIANCE_URL}</CONJUR_APPLIANCE_URL>
                <CONJUR_AUTHN_LOGIN>${env.CONJUR_AUTHN_LOGIN}</CONJUR_AUTHN_LOGIN>
                <CONJUR_AUTHN_API_KEY>${env.CONJUR_AUTHN_API_KEY}</CONJUR_AUTHN_API_KEY>
              </systemPropertyVariables>
            </configuration>
          </plugin>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>3.2.0</version>
            <configuration>
              <show>public</show>
              <source>8</source>
            </configuration>
            <executions>
              <execution>
                <goals>
                  <goal>javadoc</goal>
                </goals>
                <phase>package</phase>
              </execution>
            </executions>
          </plugin>

          <!-- Plugin to create jar with dependencies -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.3.0</version>
            <executions>
              <execution>
                <goals>
                  <goal>shade</goal>
                </goals>
                <configuration>
                  <createDependencyReducedPom>false</createDependencyReducedPom>
                  <shadedClassifierName>with-dependencies</shadedClassifierName>
                  <shadedArtifactAttached>true</shadedArtifactAttached>
                  <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                      <mainClass>MainTest</mainClass>
                    </transformer>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                      <resource>META-INF/cxf/bus-extensions.txt</resource>
                    </transformer>
                  </transformers>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <!--  automate the changes to the Maven POM files, sanity checks,
          the SCM operations required and the actual deployment execution.  -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <version>3.1.1</version>
            <configuration>
              <autoVersionSubmodules>true</autoVersionSubmodules>
              <useReleaseProfile>false</useReleaseProfile>
              <releaseProfiles>central-portal,sign</releaseProfiles>
              <goals>deploy</goals>
              <tagNameFormat>v@{project.version}</tagNameFormat>
            </configuration>
          </plugin>

        </plugins>
    </build>
</project>
