<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright 2018 University of California, Riverside

  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">
  <parent>
    <artifactId>beast</artifactId>
    <groupId>edu.ucr.cs.bdlab</groupId>
    <version>0.2.0-RC1</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>

  <artifactId>beast-spark</artifactId>
  <dependencies>
    <dependency>
      <groupId>edu.ucr.cs.bdlab</groupId>
      <artifactId>common</artifactId>
      <version>${project.version}</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>edu.ucr.cs.bdlab</groupId>
      <artifactId>geolite</artifactId>
      <version>${project.version}</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.scalatest</groupId>
      <artifactId>scalatest_2.11</artifactId>
      <version>3.0.5</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>edu.ucr.cs.bdlab</groupId>
      <artifactId>commontest</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>edu.ucr.cs.bdlab</groupId>
      <artifactId>synopses</artifactId>
      <version>${project.version}</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>edu.ucr.cs.bdlab</groupId>
      <artifactId>indexing</artifactId>
      <version>${project.version}</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>edu.ucr.cs.bdlab</groupId>
      <artifactId>io</artifactId>
      <version>${project.version}</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-core_2.11</artifactId>
      <version>${spark.version}</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>edu.ucr.cs.bdlab</groupId>
      <artifactId>visualization</artifactId>
      <version>${project.version}</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>edu.ucr.cs.bdlab</groupId>
      <artifactId>cg</artifactId>
      <version>${project.version}</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <!-- This plugin compiles Scala files -->
      <plugin>
        <groupId>net.alchim31.maven</groupId>
        <artifactId>scala-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>scala-compile-first</id>
            <phase>process-resources</phase>
            <goals>
              <goal>add-source</goal>
              <goal>compile</goal>
            </goals>

          </execution>
          <execution>
            <id>scala-test-compile</id>
            <phase>process-test-resources</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>3.1.1</version>
        <configuration>
          <artifactSet>
            <excludes>
              <exclude>org.apache.spark:spark-core_2.11</exclude>
            </excludes>
            <includes>
              <include>edu.ucr.cs.bdlab:common</include>
              <include>edu.ucr.cs.bdlab:geolite</include>
              <include>edu.ucr.cs.bdlab:cg</include>
              <include>edu.ucr.cs.bdlab:spark-operations</include>
              <include>edu.ucr.cs.bdlab:synopses</include>
              <include>edu.ucr.cs.bdlab:indexing</include>
              <include>edu.ucr.cs.bdlab:visualization</include>
              <include>edu.ucr.cs.bdlab:io</include>
              <include>com.esri.geometry:esri-geometry-api</include>
            </includes>
          </artifactSet>
          <filters>
            <filter>
              <artifact>*:*</artifact>
              <excludes>
                <exclude>META-INF/*.SF</exclude>
                <exclude>META-INF/*.DSA</exclude>
                <exclude>META-INF/*.RSA</exclude>
              </excludes>
            </filter>
          </filters>
          <finalName>beast-uber-spark-${project.version}</finalName>
          <outputDirectory>../target/</outputDirectory>
          <transformers>
            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
              <mainClass>edu.ucr.cs.bdlab.sparkOperations.Main</mainClass>
            </transformer>
            <!-- Merge configuration files from all modules -->
            <transformer implementation="org.apache.maven.plugins.shade.resource.XmlAppendingTransformer">
              <resource>beast.xml</resource>
            </transformer>
          </transformers>
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>3.1.1</version>
        <configuration>
          <outputDirectory>${project.build.directory}</outputDirectory>
          <descriptors>
            <descriptor>src/assembly/assembly.xml</descriptor>
          </descriptors>
        </configuration>
        <executions>
          <execution>
            <id>bin</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <!--
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <configuration>
              <tasks>
                <copy file="${project.basedir}/src/main/bash/beast" todir="${project.basedir}/../target/" />
                <chmod file="${project.basedir}/../target/beast" perm="ugo+rx" />
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      -->
    </plugins>
  </build>
</project>
