<?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.9.2</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>commontest</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>edu.ucr.cs.bdlab</groupId>
      <artifactId>io</artifactId>
      <version>${project.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>
    <dependency>
      <groupId>edu.ucr.cs.bdlab</groupId>
      <artifactId>raptor</artifactId>
      <version>${project.version}</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-core_${scala.compat.version}</artifactId>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.spark/spark-sql -->
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-sql_${scala.compat.version}</artifactId>
    </dependency>
  </dependencies>

  <build>
    <extensions>
      <extension>
        <groupId>org.apache.maven.archetype</groupId>
        <artifactId>archetype-packaging</artifactId>
        <version>3.1.1</version>
      </extension>
    </extensions>

    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
              <mainClass>edu.ucr.cs.bdlab.beast.operations.Main</mainClass>
            </manifest>
          </archive>
        </configuration>
      </plugin>

      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <id>distro-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <outputDirectory>../target</outputDirectory>
              <finalName>beast-${version}</finalName>
              <descriptors>
                <descriptor>src/assembly/bin.xml</descriptor>
              </descriptors>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <id>uberjar</id>
      <build>
        <plugins>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.1.1</version>

            <configuration>
              <filters>
                <filter>
                  <artifact>*:*</artifact>
                  <excludes>
                    <exclude>META-INF/*.SF</exclude>
                    <exclude>META-INF/*.DSA</exclude>
                    <exclude>META-INF/*.RSA</exclude>
                  </excludes>
                </filter>
              </filters>
              <outputDirectory>../target/</outputDirectory>
              <transformers>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                  <mainClass>edu.ucr.cs.bdlab.beast.operations.Main</mainClass>
                  <manifestEntries>
                    <!-- These entries are required for some ImageIO features to work -->
                    <Specification-Vendor>BDLab</Specification-Vendor>
                    <Implementation-Vendor>BDLab</Implementation-Vendor>
                    <Implementation-Version>${project.version}</Implementation-Version>
                  </manifestEntries>
                </transformer>
                <!-- This bit merges the various GeoTools META-INF/services files         -->
                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                <!-- Merge configuration files from all modules -->
                <transformer implementation="org.apache.maven.plugins.shade.resource.XmlAppendingTransformer">
                  <resource>beast.xml</resource>
                </transformer>
              </transformers>
            </configuration>
            <executions>
              <execution>
                <id>uberjar</id>
                <phase>package</phase>
                <goals>
                  <goal>shade</goal>
                </goals>
                <configuration>
                  <artifactSet>
                    <includes>
                      <include>edu.ucr.cs.bdlab:cg</include>
                      <include>edu.ucr.cs.bdlab:common</include>
                      <include>edu.ucr.cs.bdlab:io</include>
                      <include>edu.ucr.cs.bdlab:raptor</include>
                      <include>edu.ucr.cs.bdlab:visualization</include>
                      <include>edu.ucr.cs.bdlab:jhdf</include>
                      <include>org.locationtech.jts:jts-core</include>
                      <!-- org.mortbay.jetty:jetty + dependencies -->
                      <include>org.mortbay.jetty:jetty</include>
                      <include>org.mortbay.jetty:jetty-util</include>
                      <include>org.mortbay.jetty:servlet-api</include>
                      <!-- /org.mortbay.jetty:jetty + dependencies -->
                      <!-- org.geotools:gt-epsg-hsql + dependencies -->
                      <include>org.geotools:gt-epsg-hsql</include>
                      <include>org.geotools:gt-referencing</include>
                      <include>org.geotools:gt-metadata</include>
                      <include>org.geotools:gt-opengis</include>
                      <include>org.geotools.ogc:net.opengis.ows</include>
                      <include>org.geotools.ogc:org.w3.xlink</include>
                      <include>org.hsqldb:hsqldb</include>
                      <include>org.eclipse.emf:org.eclipse.emf.common</include>
                      <include>org.eclipse.emf:org.eclipse.emf.ecore</include>
                      <include>org.eclipse.emf:org.eclipse.emf.ecore.xmi</include>
                      <include>systems.uom:systems-common-java8</include>
                      <include>tec.uom:uom-se</include>
                      <include>tec.uom.lib:uom-lib-common</include>
                      <include>si.uom:si-quantity</include>
                      <include>si.uom:si-units-java8</include>
                      <include>javax.measure:unit-api</include>
                      <include>javax:javaee-api</include>
                      <include>javax.media:jai_core</include>
                      <include>com.sun.mail:javax.mail</include>
                      <include>org.ejml:ejml-ddense</include>
                      <include>org.ejml:ejml-core</include>
                      <include>commons-pool:commons-pool</include>
                      <include>jgridshift:jgridshift-core</include>
                      <include>net.sf.geographiclib:GeographicLib-Java</include>
                      <!-- /org.geotools:gt-epsg-hsql + dependencies -->
                    </includes>
                  </artifactSet>
                  <finalName>beast-uber-${project.version}</finalName>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
