<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2017-2020 Crown Copyright
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<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">
    <parent>
        <groupId>uk.gov.gchq.gaffer</groupId>
        <artifactId>example</artifactId>
        <version>2.0.0-alpha-0.2</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>federated-demo</artifactId>
    <packaging>war</packaging>

    <properties>
        <standalone-path>rest</standalone-path>
        <standalone-port>8080</standalone-port>
    </properties>

    <dependencies>
        <dependency>
            <groupId>uk.gov.gchq.gaffer</groupId>
            <artifactId>federated-store</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
        <dependency>
            <groupId>uk.gov.gchq.gaffer</groupId>
            <artifactId>accumulo-store</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
        <dependency>
            <groupId>uk.gov.gchq.gaffer</groupId>
            <artifactId>map-store</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
        <dependency>
            <groupId>uk.gov.gchq.gaffer</groupId>
            <artifactId>jcs-cache-service</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
        <dependency>
            <groupId>uk.gov.gchq.gaffer</groupId>
            <artifactId>core-rest</artifactId>
            <classifier>classes</classifier>
            <version>${project.parent.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-hdfs</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>src/main/java</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <attachClasses>true</attachClasses>
                    <classesClassifier>classes</classesClassifier>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>uk.gov.gchq.gaffer</groupId>
                        <artifactId>core-rest</artifactId>
                        <version>${project.parent.version}</version>
                        <type>war</type>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>${project.parent.groupId}</groupId>
                                    <artifactId>core-rest</artifactId>
                                    <version>${project.parent.version}</version>
                                    <type>war</type>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>
                                        ${project.build.directory}/${project.artifactId}-${project.version}
                                    </outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>federated-demo</id>
            <properties>
                <maven.test.skip>true</maven.test.skip>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.cargo</groupId>
                        <artifactId>cargo-maven3-plugin</artifactId>
                        <version>${cargo.plugin.version}</version>
                        <configuration>
                            <deployables>
                                <deployable>
                                    <properties>
                                        <context>${standalone-path}</context>
                                    </properties>
                                </deployable>
                            </deployables>
                            <properties>
                                <cargo.servlet.port>${standalone-port}</cargo.servlet.port>
                            </properties>
                            <container>
                                <containerId>tomcat9x</containerId>
                                <systemProperties>
                                    <gaffer.properties.app.title>
                                        Federated Gaffer Example
                                    </gaffer.properties.app.title>
                                    <gaffer.properties.app.description>
                                        Example of a Gaffer Federated Store
                                    </gaffer.properties.app.description>
                                    <gaffer.rest-api.basePath>${standalone-path}
                                    </gaffer.rest-api.basePath>
                                    <gaffer.graph.config>
                                        ${project.build.outputDirectory}/graphConfig.json
                                    </gaffer.graph.config>
                                    <gaffer.storeProperties>
                                        ${project.build.outputDirectory}/federatedStore.properties
                                    </gaffer.storeProperties>
                                    <gaffer.error-mode.debug>
                                        false
                                    </gaffer.error-mode.debug>
                                </systemProperties>
                            </container>
                        </configuration>
                        <executions>
                            <execution>
                                <id>deploy</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
