<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>
    <groupId>org.dspace</groupId>
    <artifactId>dspace-server-webapp</artifactId>
    <packaging>war</packaging>
    <name>DSpace Server Webapp</name>
    <description>
        DSpace Server Webapp (Spring Boot)
    </description>

    <!--
      A Parent POM that Maven inherits DSpace Default
      POM attributes from.
    -->
    <parent>
        <groupId>org.dspace</groupId>
        <artifactId>dspace-parent</artifactId>
        <version>7.0-beta1</version>
        <relativePath>..</relativePath>
    </parent>

    <properties>
        <!-- This is the path to the root [dspace-src] directory. -->
        <root.basedir>${basedir}/..</root.basedir>

        <!-- Default resource delimiter for Spring Boot, so it doesn't clash with Spring ${} placeholders-->
        <resource.delimiter>@</resource.delimiter>
        <!-- Define our starting class for our Spring Boot Application -->
        <start-class>org.dspace.app.rest.Application</start-class>
        <!-- Library for managing JSON Web Tokens (JWT): https://bitbucket.org/connect2id/nimbus-jose-jwt/wiki/Home -->
        <nimbus-jose-jwt.version>7.9</nimbus-jose-jwt.version>
    </properties>

    <profiles>
        <!-- If Unit Testing is enabled, then setup the Unit Test Environment.
             See also the 'skiptests' profile in Parent POM. -->
        <profile>
            <id>test-environment</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <property>
                    <name>maven.test.skip</name>
                    <value>false</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <!-- Unit/Integration Testing setup: This plugin unzips the
                         'testEnvironment.zip' file (created by dspace-parent POM), into
                         the 'target/testing/' folder, to essentially create a test
                         install of DSpace, against which Tests can be run. -->
                    <plugin>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <configuration>
                            <outputDirectory>${project.build.directory}/testing</outputDirectory>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.dspace</groupId>
                                    <artifactId>dspace-parent</artifactId>
                                    <version>${project.version}</version>
                                    <type>zip</type>
                                    <classifier>testEnvironment</classifier>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                        <executions>
                            <execution>
                                <id>setupTestEnvironment</id>
                                <phase>generate-test-resources</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>setupIntegrationTestEnvironment</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- This plugin allows us to run a Groovy script in our Maven POM
                         (see: http://gmaven.codehaus.org/Executing+Groovy+Code )
                         We are generating a OS-agnostic version (agnostic.build.dir) of
                         the ${project.build.directory} property (full path of target dir).
                         This is needed by the FileWeaver & Surefire plugins (see below)
                         to initialize the Unit Test environment's dspace.cfg file.
                         Otherwise, the Unit Test Framework will not work on Windows OS.
                         This Groovy code was mostly borrowed from:
                         http://stackoverflow.com/questions/3872355/how-to-convert-file-separator-in-maven
                    -->
                    <plugin>
                        <groupId>org.codehaus.gmaven</groupId>
                        <artifactId>groovy-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>setproperty</id>
                                <phase>generate-test-resources
                                </phase> <!-- XXX I think this should be 'initialize' - MHW -->
                                <goals>
                                    <goal>execute</goal>
                                </goals>
                                <configuration>
                                    <source>
                                        project.properties['agnostic.build.dir'] = project.build.directory.replace(File.separator, '/');
                                        println("Initializing Maven property 'agnostic.build.dir' to: " + project.properties['agnostic.build.dir']);
                                    </source>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Run Unit Testing! This plugin just kicks off the tests (when enabled). -->
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <systemPropertyVariables>
                                <!-- Specify the dspace.dir to use for test environment -->
                                <!-- This system property is loaded by AbstractDSpaceTest to initialize the test environment -->
                                <dspace.dir>${agnostic.build.dir}/testing/dspace/</dspace.dir>
                                <!-- Turn off any DSpace logging -->
                                <dspace.log.init.disable>true</dspace.log.init.disable>
                                <solr.install.dir>${agnostic.build.dir}/testing/dspace/solr/</solr.install.dir>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>

                    <!-- Run Integration Testing! This plugin just kicks off the tests (when enabled). -->
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <systemPropertyVariables>
                                <!-- Specify the dspace.dir to use for test environment -->
                                <dspace.dir>${agnostic.build.dir}/testing/dspace/</dspace.dir>
                                <!-- Turn off any DSpace logging -->
                                <dspace.log.init.disable>true</dspace.log.init.disable>
                                <solr.install.dir>${agnostic.build.dir}/testing/dspace/solr/</solr.install.dir>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                </plugins>
            </build>

        </profile>
    </profiles>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <attachClasses>true</attachClasses>
                    <!-- Filter the web.xml (needed for IDE compatibility/debugging) -->
                    <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
                </configuration>
                <executions>
                    <execution>
                        <phase>prepare-package</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <!-- Builds a *-tests.jar of all test classes -->
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-expression</artifactId>
                <version>${spring.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>

        <!-- These next two dependencies build a WAR that is BOTH executable
             AND deployable into an external container (Tomcat).
             See: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#build-tool-plugins-maven-packaging -->
        <!-- NOTE: For rapid development (if you don't need Solr or other webapps),
             you can temporarily comment these out, and switch <packaging> to "jar".
             This lets you develop in a standalone, runnable JAR application. -->
        <!--<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>-->
        <!-- Ensure embedded servlet container doesn't interfere when this
             WAR is deployed to an external Tomcat (i.e. provided). -->
        <!--<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>-->

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>${spring-boot.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
            <version>${spring-boot.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
            <version>${spring-boot.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
            <version>${spring-boot.version}</version>
        </dependency>

        <dependency>
            <groupId>com.flipkart.zjsonpatch</groupId>
            <artifactId>zjsonpatch</artifactId>
            <version>0.4.6</version>
        </dependency>

        <!-- The HAL Browser -->
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-rest-hal-browser</artifactId>
            <version>3.1.10.RELEASE</version>
            <!-- if you get a java.util.zip.ZipException: invalid LOC
                 header (bad signature) during the tomcat startup
                 force the use of the previous version as the jar file
                 looks corrupted in the maven repository -->
        </dependency>

        <!-- Add in Spring Security for AuthN and AuthZ -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
            <version>${spring-boot.version}</version>
        </dependency>

        <!-- Add in log4j support by excluding default logging, and
	     using starter-log4j -->
        <!-- See:  http://docs.spring.io/spring-boot/docs/current/reference
	     /html/howto-logging.html#howto-configure-log4j-for-logging -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
	        <version>${spring-boot.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j2</artifactId>
	        <version>${spring-boot.version}</version>
        </dependency>

        <!-- DSpace dependencies -->
        <dependency>
            <groupId>org.dspace</groupId>
            <artifactId>dspace-api</artifactId>
        </dependency>

        <dependency>
            <groupId>org.dspace</groupId>
            <artifactId>dspace-services</artifactId>
        </dependency>

        <!-- DSpace modules to deploy (this modules are all optional, but add features/endpoints to webapp) -->
        <!-- You may choose to comment out any of these modules if you do not want/need its features -->
        <dependency>
            <groupId>org.dspace</groupId>
            <artifactId>dspace-oai</artifactId>
        </dependency>
        <dependency>
            <groupId>org.dspace</groupId>
            <artifactId>dspace-rdf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.dspace</groupId>
            <artifactId>dspace-sword</artifactId>
        </dependency>
        <dependency>
            <groupId>org.dspace</groupId>
            <artifactId>dspace-swordv2</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-collections4</artifactId>
        </dependency>
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>

        <dependency>
            <groupId>com.nimbusds</groupId>
            <artifactId>nimbus-jose-jwt</artifactId>
            <version>${nimbus-jose-jwt.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.solr</groupId>
            <artifactId>solr-solrj</artifactId>
            <version>${solr.client.version}</version>
        </dependency>

        <!-- TEST DEPENDENCIES -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.jayway.jsonpath</groupId>
            <artifactId>json-path</artifactId>
            <version>${json-path.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.jayway.jsonpath</groupId>
            <artifactId>json-path-assert</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- Solr Core is needed for Integration Tests (to run a MockSolrServer)     -->
        <!-- The following Solr / Lucene dependencies also support integration tests -->
        <dependency>
            <groupId>org.apache.solr</groupId>
            <artifactId>solr-core</artifactId>
            <version>${solr.client.version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-continuation</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-deploy</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-http</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-io</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-jmx</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-rewrite</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-security</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-server</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-servlet</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-servlets</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-util</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-webapp</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-xml</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.solr</groupId>
            <artifactId>solr-cell</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-continuation</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-deploy</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-http</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-io</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-jmx</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-rewrite</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-security</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-server</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-servlet</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-servlets</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-util</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-webapp</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-xml</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- Reminder: Keep icu4j (in Parent POM) synced with version used by lucene-analyzers-icu below,
             otherwise ICUFoldingFilterFactory may throw errors in tests.  -->
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-analyzers-icu</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-analyzers-smartcn</artifactId>
            <version>${solr.client.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-analyzers-stempel</artifactId>
            <version>${solr.client.version}</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

</project>
