<?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>
    <artifactId>fcrepo-camel-toolbox</artifactId>
    <groupId>org.fcrepo.camel</groupId>
    <version>4.7.2</version>
  </parent>

  <artifactId>fcrepo-indexing-triplestore</artifactId>
  <packaging>bundle</packaging>

  <name>Fedora Indexing Service with a Triplestore backend</name>
  <description>Camel-based indexing service for an external triplestore</description>

  <properties>
    <osgi.export.packages>org.fcrepo.camel.indexing.triplestore;version=${project.version}</osgi.export.packages>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-blueprint</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-http4</artifactId>
    </dependency>
    <dependency>
      <groupId>org.fcrepo.camel</groupId>
      <artifactId>fcrepo-camel</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-spring</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
    </dependency>

    <!-- logging -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
    </dependency>

    <!-- Testing & Camel Plugin -->
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-test-blueprint</artifactId>
    </dependency>

    <dependency>
      <groupId>com.jayway.awaitility</groupId>
      <artifactId>awaitility</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.activemq</groupId>
      <artifactId>activemq-camel</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-all</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.jena</groupId>
      <artifactId>jena-fuseki-embedded</artifactId>
    </dependency>

    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.fcrepo.client</groupId>
      <artifactId>fcrepo-java-client</artifactId>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <build>
    <defaultGoal>install</defaultGoal>

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

      <!-- to generate the MANIFEST-FILE of the bundle -->
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
      </plugin>

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

        <!-- reserve network ports for integration testing -->
        <!-- add configuration file to artifact set for OSGi deployment -->
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <configuration>
            <portNames>
              <portName>fuseki.dynamic.test.port</portName>
              <portName>fcrepo.dynamic.test.port</portName>
              <portName>fcrepo.dynamic.jms.port</portName>
              <portName>fcrepo.dynamic.stomp.port</portName>
              <portName>jetty.dynamic.stop.port</portName>
            </portNames>
          </configuration>
        </plugin>

        <!-- integration testing -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-failsafe-plugin</artifactId>
          <configuration>
            <argLine>${jacoco.agent.it.arg}</argLine>
            <systemPropertyVariables>
              <fuseki.dynamic.test.port>${fuseki.dynamic.test.port}</fuseki.dynamic.test.port>
              <fcrepo.dynamic.jms.port>${fcrepo.dynamic.jms.port}</fcrepo.dynamic.jms.port>
              <fcrepo.dynamic.stomp.port>${fcrepo.dynamic.stomp.port}</fcrepo.dynamic.stomp.port>
              <fcrepo.dynamic.test.port>${fcrepo.dynamic.test.port}</fcrepo.dynamic.test.port>
              <jetty.dynamic.test.port>${jetty.dynamic.test.port}</jetty.dynamic.test.port>
            </systemPropertyVariables>
          </configuration>
        </plugin>


        <!-- Launch jetty for integration testing with fedora -->
        <plugin>
          <groupId>org.eclipse.jetty</groupId>
          <artifactId>jetty-maven-plugin</artifactId>
          <configuration>
            <systemProperties>
              <force>true</force>
              <systemProperty>
                <name>fcrepo.home</name>
                <value>${project.build.directory}/fcrepo-data</value>
              </systemProperty>
              <systemProperty>
                <name>fcrepo.dynamic.jms.port</name>
                <value>${fcrepo.dynamic.jms.port}</value>
              </systemProperty>
              <systemProperty>
                <name>fcrepo.dynamic.stomp.port</name>
                <value>${fcrepo.dynamic.stomp.port}</value>
              </systemProperty>
              <systemProperty>
                <name>fcrepo.modeshape.configuration</name>
                <value>classpath:/config/file-simple/repository.json</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>stop</goal>
                <goal>start</goal>
              </goals>
              <configuration>
                <httpConnector>
                  <port>${fcrepo.dynamic.test.port}</port>
                </httpConnector>
                <scanIntervalSeconds>0</scanIntervalSeconds>
                <daemon>true</daemon>
                <contextHandlers>
                    <contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
                      <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>
             </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>

</project>
