<?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/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.fcrepo</groupId>
    <artifactId>fcrepo-parent</artifactId>
    <version>6.0.0</version>
  </parent>

  <groupId>org.fcrepo.client</groupId>
  <artifactId>fcrepo-java-client</artifactId>
  <packaging>jar</packaging>

  <version>6.0.0</version>

  <name>Fedora Java Client Libraries</name>
  <description>Java libraries for interacting with a Fedora Repository</description>
  <url>http://fcrepo.org</url>

  <organization>
    <name>DuraSpace, Inc.</name>
    <url>http://www.duraspace.org/</url>
  </organization>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <project.copyrightYear>2015</project.copyrightYear>

    <!-- Use ${project_name} instead of ${project.artifactId} to avoid incorrect
      replacements of "fcrepo" in child modules (for scm, site-distribution, etc -->
    <project_name>fcrepo-java-client</project_name>

    <!-- https://github.com/github/maven-plugins/blob/master/README.md -->
    <github.global.server>github</github.global.server>

    <!-- dependencies -->
    <fcrepo.version>6.0.0</fcrepo.version>
    <commons.io.version>2.7</commons.io.version>
    <commons.lang3.version>3.7</commons.lang3.version>
    <httpclient.version>4.5.13</httpclient.version>
    <javax.ws.rs-api.vesion>2.0.1</javax.ws.rs-api.vesion>
    <jersey.version>2.34</jersey.version>
    <logback.version>1.2.3</logback.version>
    <mockito.version>2.23.0</mockito.version>
    <mockserver.version>5.4.1</mockserver.version>
    <slf4j.version>1.7.25</slf4j.version>
    <spring.version>5.3.4</spring.version>
    <jena.version>3.17.0</jena.version>
    <jetty.version>9.4.34.v20201102</jetty.version>
    <jetty.users.file>${project.build.directory}/test-classes/jetty-users.properties</jetty.users.file>

  </properties>

  <scm>
    <connection>scm:git:git://github.com/fcrepo-exts/${project_name}.git</connection>
    <developerConnection>scm:git:git@github.com:fcrepo-exts/${project_name}.git</developerConnection>
    <url>https://github.com/fcrepo-exts/fcrepo-java-client</url>
    <tag>fcrepo-java-client-6.0.0</tag>
  </scm>

  <repositories>
    <repository>
      <id>snapshots-repo</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>

  <dependencies>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
      <version>${commons.lang3.version}</version>
    </dependency>

    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
      <version>${httpclient.version}</version>
    </dependency>
    
    <!-- logging -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${slf4j.version}</version>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <!-- testing -->
    <dependency>
      <groupId>org.glassfish.jersey.core</groupId>
      <artifactId>jersey-common</artifactId>
      <version>${jersey.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>${logback.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>${mockito.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>${commons.io.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.jena</groupId>
      <artifactId>jena-core</artifactId>
      <version>${jena.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.jena</groupId>
      <artifactId>jena-arq</artifactId>
      <version>${jena.version}</version>
      <scope>test</scope>
    </dependency>
    
    <dependency>
      <groupId>org.mock-server</groupId>
      <artifactId>mockserver-client-java</artifactId>
      <version>${mockserver.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.mock-server</groupId>
      <artifactId>mockserver-netty</artifactId>
      <version>${mockserver.version}</version>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <build>
    <defaultGoal>install</defaultGoal>

    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <filtering>true</filtering>
        <directory>src/test/resources</directory>
      </testResource>
    </testResources>

    <plugins>

      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <configuration>
          <portNames>
            <portName>fcrepo.dynamic.test.port</portName>
            <portName>jetty.dynamic.stop.port</portName>
          </portNames>
        </configuration>
        <executions>
          <execution>
            <id>reserve-port</id>
            <phase>package</phase>
            <goals>
              <goal>reserve-network-port</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-failsafe-plugin</artifactId>
        <configuration>
          <!--Set reuseForks=false due to the need for different instances of the-->
          <!--Singleton ServletContainerAuthenticationProvider-->
          <reuseForks>false</reuseForks>
          <argLine>${jacoco.agent.it.arg}</argLine>
          <systemPropertyVariables>
            <fcrepo.dynamic.test.port>${fcrepo.dynamic.test.port}</fcrepo.dynamic.test.port>
            <project.build.outputDirectory>${project.build.outputDirectory}</project.build.outputDirectory>
          </systemPropertyVariables>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
      </plugin>

      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
      </plugin>

      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
      </plugin>

      <!-- verify that source files contain the correct license headers
        $ mvn license:check to check files
        $ mvn license:format to update files -->
      <plugin>
        <groupId>com.mycila</groupId>
        <artifactId>license-maven-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>com.github.github</groupId>
        <artifactId>site-maven-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
      </plugin>

      <!-- Launch jetty for integration testing with fedora -->
      <plugin>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>${jetty.version}</version>
        <configuration>
          <supportedPackagings>jar</supportedPackagings>
          <systemProperties>
            <force>true</force>
            <systemProperty>
              <name>fcrepo.home</name>
              <value>${project.build.directory}/fcrepo-data</value>
            </systemProperty>
            <systemProperty>
              <name>fcrepo.dynamic.test.port</name>
              <value>${fcrepo.dynamic.test.port}</value>
            </systemProperty>
            <systemProperty>
              <name>fcrepo.jms.enabled</name>
              <value>false</value>
            </systemProperty>
            <systemProperty>
              <name>fcrepo.home</name>
              <value>${project.build.directory}/fcrepo-home</value>
            </systemProperty>
            <systemProperty>
              <name>fcrepo.external.content.allowed</name>
              <value>${project.build.directory}/test-classes/allowed_external_paths.txt</value>
            </systemProperty>
            <systemProperty>
              <name>fcrepo.activemq.directory</name>
              <value>${project.build.directory}/active-mq</value>
            </systemProperty>	
          </systemProperties>
          <scanIntervalSeconds>10</scanIntervalSeconds>
          <stopKey>STOP</stopKey>
          <stopPort>${jetty.dynamic.stop.port}</stopPort>
          <daemon>true</daemon>
        </configuration>
        <executions>
          <execution>
            <id>start-jetty</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>start</goal>
            </goals>
            <configuration>
              <jettyXml>${project.build.directory}/test-classes/jetty-test.xml</jettyXml>
              <scanIntervalSeconds>0</scanIntervalSeconds>
              <daemon>true</daemon>
              <contextHandlers>
                <contextHandler implementation="org.eclipse.jetty.maven.plugin.JettyWebAppContext">
                  <war>${project.build.directory}/fcrepo.war</war>
                  <contextPath>/fcrepo</contextPath>
                </contextHandler>
              </contextHandlers>
            </configuration>
          </execution>

          <execution>
            <id>stop-jetty</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>stop</goal>
            </goals>
            <configuration>
              <stopPort>${jetty.dynamic.stop.port}</stopPort>
            </configuration>
          </execution>

        </executions>
      </plugin>

      <!--Bring in fcrepo webapp for integration testing-->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>copy</id>
            <phase>package</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>org.fcrepo</groupId>
                  <artifactId>fcrepo-webapp</artifactId>
                  <version>${fcrepo.version}</version>
                  <type>war</type>
                  <outputDirectory>${project.build.directory}</outputDirectory>
                  <destFileName>fcrepo.war</destFileName>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <issueManagement>
    <system>GitHub</system>
    <url>https://github.com/fcrepo-exts/fcrepo-java-client/issues</url>
  </issueManagement>

</project>
