<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2017 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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>uk.gov.gchq.gaffer</groupId>
        <artifactId>gaffer-tools</artifactId>
        <version>0.6.2</version>
    </parent>

    <artifactId>slider</artifactId>

    <properties>
        <addon.pkg.name>Gaffer</addon.pkg.name>
        <addon.pkg.file>gaffer-slider-${project.version}</addon.pkg.file>

        <!-- Dependency Versions -->
        <slider.version>0.91.0-incubating</slider.version>
        <slider.accumulo.branch>branches/branch-0.91</slider.accumulo.branch>

        <!-- Output Locations -->
        <gaffer.output.directory>${project.build.directory}/gaffer</gaffer.output.directory>
        <slider.output.directory>${project.build.directory}/slider</slider.output.directory>
        <slider.accumulo.output.directory>${project.build.directory}/accumulo-pkg</slider.accumulo.output.directory>
    </properties>

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

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
            <resource>
                <directory>scripts</directory>
                <filtering>true</filtering>
                <targetPath>${project.build.directory}/scripts</targetPath>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>${dependency.plugin.version}</version>
                <configuration>
                    <overWriteIfNewer>true</overWriteIfNewer>
                    <overWriteReleases>true</overWriteReleases>
                    <overWriteSnapshots>true</overWriteSnapshots>
                </configuration>

                <executions>
                    <execution>
                        <id>get-gaffer-iterators</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>uk.gov.gchq.gaffer</groupId>
                                    <artifactId>accumulo-store</artifactId>
                                    <classifier>iterators</classifier>
                                    <version>${gaffer.version}</version>
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>${gaffer.output.directory}</outputDirectory>
                        </configuration>
                    </execution>

                    <execution>
                        <id>get-slider-distribution</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.apache.slider</groupId>
                                    <artifactId>slider-assembly</artifactId>
                                    <classifier>all</classifier>
                                    <type>zip</type>
                                    <version>${slider.version}</version>
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>${slider.output.directory}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.5.0</version>
                <executions>
                    <execution>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>scripts/build_accumulo_package.sh</executable>
                            <arguments>
                                <argument>${slider.accumulo.branch}</argument>
                                <argument>${accumulo.version}</argument>
                                <argument>${slider.accumulo.output.directory}</argument>
                                <argument>--build-native</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptor>src/assembly/package.xml</descriptor>
                            <appendAssemblyId>false</appendAssemblyId>
                            <finalName>${addon.pkg.file}</finalName>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
