<?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-serialization</artifactId>
  <packaging>bundle</packaging>

  <name>Fedora Serialization Service</name>
  <description>Camel-based object serialization service</description>

  <properties>
    <osgi.export.packages>org.fcrepo.camel.serialization;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.fcrepo.camel</groupId>
      <artifactId>fcrepo-camel</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-exec</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>org.apache.activemq</groupId>
      <artifactId>activemq-camel</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
    </dependency>

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

    <dependency>
      <groupId>org.glassfish.hk2.external</groupId>
      <artifactId>javax.inject</artifactId>
      <scope>test</scope>
    </dependency>

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

    <dependency>
      <groupId>xerces</groupId>
      <artifactId>xercesImpl</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>

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

      <!-- to generate the MANIFEST-FILE of the bundle -->
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-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>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>
            <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>
        <version>${dependency.plugin.version}</version>
        <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>
