<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you 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>net.sansa-stack</groupId>
        <artifactId>sansa-inference-parent_2.12</artifactId>
        <version>0.8.0-RC1</version>
    </parent>

    <artifactId>sansa-inference-flink_2.12</artifactId>

    <name>Inference API - Flink</name>
    <description>Apache Flink based inference layer for RDF and OWL</description>

    <dependencies>
        <dependency>
            <groupId>net.sansa-stack</groupId>
            <artifactId>sansa-inference-common_${scala.binary.version}</artifactId>
        </dependency>

        <!-- RDF Layer -->
        <dependency>
            <groupId>net.sansa-stack</groupId>
            <artifactId>sansa-rdf-flink_${scala.binary.version}</artifactId>
        </dependency>

        <!-- Apache Flink -->
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-scala_${scala.binary.version}</artifactId>
        </dependency>
        <!--		<dependency>-->
        <!--			<groupId>org.apache.flink</groupId>-->
        <!--			<artifactId>flink-streaming-scala_${scala.binary.version}</artifactId>-->
        <!--		</dependency>-->
        <!--		<dependency>-->
        <!--			<groupId>org.apache.flink</groupId>-->
        <!--			<artifactId>flink-clients_${scala.binary.version}</artifactId>-->
        <!--		</dependency>-->

        <!-- Apache JENA 3.x-->
        <dependency>
            <groupId>org.apache.jena</groupId>
            <artifactId>jena-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.jena</groupId>
            <artifactId>jena-arq</artifactId>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>com.typesafe.scala-logging</groupId>
            <artifactId>scala-logging_${scala.binary.version}</artifactId>
        </dependency>

        <!-- Guava -->
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>

        <!-- Test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
        </dependency>
        <dependency>
            <groupId>org.scalatest</groupId>
            <artifactId>scalatest_${scala.binary.version}</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-test-utils_${scala.binary.version}</artifactId>
            <version>${flink.version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.directory.jdbm</groupId>
                    <artifactId>apacheds-jdbm1</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Scopt -->
        <dependency>
            <groupId>com.github.scopt</groupId>
            <artifactId>scopt_${scala.binary.version}</artifactId>
        </dependency>

        <dependency>
            <groupId>net.sansa-stack</groupId>
            <artifactId>sansa-inference-tests_${scala.binary.version}</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <profiles>
        <profile>
            <!-- A profile that does everything correctly:
            We set the Flink dependencies to provided -->
            <id>build-jar</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.apache.flink</groupId>
                    <artifactId>flink-scala_${scala.binary.version}</artifactId>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>org.apache.flink</groupId>
                    <artifactId>flink-streaming-scala_${scala.binary.version}</artifactId>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>org.apache.flink</groupId>
                    <artifactId>flink-clients_${scala.binary.version}</artifactId>
                    <scope>provided</scope>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>dist</id>
            <activation>
                <property>
                    <name>dist</name>
                </property>
            </activation>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-shade-plugin</artifactId>
                        <executions>
                            <!-- Run shade goal on package phase -->
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>shade</goal>
                                </goals>
                                <configuration>
                                    <!--<minimizeJar>true</minimizeJar>-->
                                    <artifactSet>
                                        <excludes>
                                            <!-- This list contains all dependencies of flink-dist
                                            Everything else will be packaged into the fat-jar
                                            -->
                                            <exclude>org.apache.flink:*</exclude>

                                            <!-- Also exclude very big transitive dependencies of Flink

                                            WARNING: You have to remove these excludes if your code relies on other
                                            versions of these dependencies.

                                            -->

                                            <exclude>org.scala-lang:scala-library</exclude>
                                            <exclude>org.scala-lang:scala-compiler</exclude>
                                            <exclude>org.scala-lang:scala-reflect</exclude>
                                            <exclude>com.amazonaws:aws-java-sdk</exclude>
                                            <exclude>com.typesafe.akka:akka-actor_*</exclude>
                                            <exclude>com.typesafe.akka:akka-remote_*</exclude>
                                            <exclude>com.typesafe.akka:akka-slf4j_*</exclude>
                                            <exclude>io.netty:netty-all</exclude>
                                            <exclude>io.netty:netty</exclude>
                                            <exclude>org.eclipse.jetty:jetty-server</exclude>
                                            <exclude>org.eclipse.jetty:jetty-continuation</exclude>
                                            <exclude>org.eclipse.jetty:jetty-http</exclude>
                                            <exclude>org.eclipse.jetty:jetty-io</exclude>
                                            <exclude>org.eclipse.jetty:jetty-util</exclude>
                                            <exclude>org.eclipse.jetty:jetty-security</exclude>
                                            <exclude>org.eclipse.jetty:jetty-servlet</exclude>
                                            <exclude>org.gephi:*</exclude>
                                            <exclude>org.netbeans.api:*</exclude>

                                            <exclude>commons-fileupload:commons-fileupload</exclude>
                                            <exclude>org.apache.avro:avro</exclude>
                                            <exclude>commons-collections:commons-collections</exclude>
                                            <exclude>org.codehaus.jackson:jackson-core-asl</exclude>
                                            <exclude>org.codehaus.jackson:jackson-mapper-asl</exclude>
                                            <exclude>com.thoughtworks.paranamer:paranamer</exclude>
                                            <exclude>org.xerial.snappy:snappy-java</exclude>
                                            <exclude>org.apache.commons:commons-compress</exclude>
                                            <exclude>org.tukaani:xz</exclude>
                                            <exclude>com.esotericsoftware.kryo:kryo</exclude>
                                            <exclude>com.esotericsoftware.minlog:minlog</exclude>
                                            <exclude>org.objenesis:objenesis</exclude>
                                            <exclude>com.twitter:chill_*</exclude>
                                            <exclude>com.twitter:chill-java</exclude>
                                            <exclude>com.twitter:chill-avro_*</exclude>
                                            <exclude>com.twitter:chill-bijection_*</exclude>
                                            <exclude>com.twitter:bijection-core_*</exclude>
                                            <exclude>com.twitter:bijection-avro_*</exclude>
                                            <exclude>commons-lang:commons-lang</exclude>
                                            <exclude>junit:junit</exclude>
                                            <exclude>de.javakaffee:kryo-serializers</exclude>
                                            <exclude>joda-time:joda-time</exclude>
                                            <exclude>org.apache.commons:commons-lang3</exclude>
                                            <exclude>org.slf4j:slf4j-api</exclude>
                                            <exclude>org.slf4j:slf4j-log4j12</exclude>
                                            <exclude>log4j:log4j</exclude>
                                            <exclude>org.apache.commons:commons-math</exclude>
                                            <exclude>org.apache.sling:org.apache.sling.commons.json</exclude>
                                            <exclude>commons-logging:commons-logging</exclude>
                                            <exclude>org.apache.httpcomponents:httpclient</exclude>
                                            <exclude>org.apache.httpcomponents:httpcore</exclude>
                                            <exclude>commons-codec:commons-codec</exclude>
                                            <exclude>com.fasterxml.jackson.core:jackson-core</exclude>
                                            <exclude>com.fasterxml.jackson.core:jackson-databind</exclude>
                                            <exclude>com.fasterxml.jackson.core:jackson-annotations</exclude>
                                            <exclude>org.codehaus.jettison:jettison</exclude>
                                            <exclude>stax:stax-api</exclude>
                                            <exclude>com.typesafe:config</exclude>
                                            <exclude>org.uncommons.maths:uncommons-maths</exclude>
                                            <!--<exclude>com.github.scopt:scopt_*</exclude>-->
                                            <exclude>org.mortbay.jetty:servlet-api</exclude>
                                            <exclude>commons-io:commons-io</exclude>
                                            <exclude>commons-cli:commons-cli</exclude>

                                            <exclude>sqlite:*</exclude>
                                            <exclude>netbeans:*</exclude>
                                            <exclude>org.apache.xmlgraphics:*</exclude>
                                            <exclude>mysql:*</exclude>
                                            <exclude>jfree:*</exclude>
                                            <exclude>org.scala-lang.modules:*</exclude>
                                        </excludes>
                                    </artifactSet>
                                    <filters>
                                        <filter>
                                            <artifact>org.apache.flink:*</artifact>
                                            <excludes>
                                                <exclude>org/apache/flink/shaded/**</exclude>
                                                <exclude>web-docs/**</exclude>
                                            </excludes>
                                        </filter>
                                        <filter>
                                            <!-- Do not copy the signatures in the META-INF folder.
                                            Otherwise, this might cause SecurityExceptions when using the JAR. -->
                                            <artifact>*:*</artifact>
                                            <excludes>
                                                <exclude>META-INF/*.SF</exclude>
                                                <exclude>META-INF/*.DSA</exclude>
                                                <exclude>META-INF/*.RSA</exclude>
                                            </excludes>
                                        </filter>
                                    </filters>
                                    <finalName>dist-${project.artifactId}-${project.version}</finalName>
                                    <transformers>
                                        <!-- add Main-Class to manifest file -->
                                        <transformer
                                                implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                            <mainClass>net.sansa_stack.inference.flink.RDFGraphMaterializer</mainClass>
                                        </transformer>
                                    </transformers>
                                    <createDependencyReducedPom>false</createDependencyReducedPom>
                                    <relocations>
                                        <relocation>
                                            <pattern>scopt</pattern>
                                            <shadedPattern>scopt.shaded</shadedPattern>
                                        </relocation>
                                    </relocations>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>dist-package</id>
            <build>
                <finalName>SANSA-Inference-Flink-${project.version}</finalName>
                <plugins>
                    <plugin>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-resources</id>
                                <!-- here the phase you need -->
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${basedir}/target/scripts</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>scripts</directory>
                                            <filtering>true</filtering>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>prepare-package</phase>
                                <configuration>
                                    <tasks>
                                        <replace token="VERSION_TMP"
                                                 value="dist-${project.artifactId}-${project.version}.jar"
                                                 dir="target/scripts">
                                            <include name="cli"/>
                                        </replace>
                                    </tasks>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-shade-plugin</artifactId>
                        <executions>
                            <!-- Run shade goal on package phase -->
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>shade</goal>
                                </goals>
                                <configuration>
                                    <!--<minimizeJar>true</minimizeJar>-->
                                    <artifactSet>
                                        <excludes>
                                            <!-- This list contains all dependencies of flink-dist
                                            Everything else will be packaged into the fat-jar
                                            -->
                                            <exclude>org.apache.flink:*</exclude>

                                            <!-- Also exclude very big transitive dependencies of Flink

                                            WARNING: You have to remove these excludes if your code relies on other
                                            versions of these dependencies.

                                            -->

                                            <exclude>org.scala-lang:scala-library</exclude>
                                            <exclude>org.scala-lang:scala-compiler</exclude>
                                            <exclude>org.scala-lang:scala-reflect</exclude>
                                            <exclude>com.amazonaws:aws-java-sdk</exclude>
                                            <exclude>com.typesafe.akka:akka-actor_*</exclude>
                                            <exclude>com.typesafe.akka:akka-remote_*</exclude>
                                            <exclude>com.typesafe.akka:akka-slf4j_*</exclude>
                                            <exclude>io.netty:netty-all</exclude>
                                            <exclude>io.netty:netty</exclude>
                                            <exclude>org.eclipse.jetty:jetty-server</exclude>
                                            <exclude>org.eclipse.jetty:jetty-continuation</exclude>
                                            <exclude>org.eclipse.jetty:jetty-http</exclude>
                                            <exclude>org.eclipse.jetty:jetty-io</exclude>
                                            <exclude>org.eclipse.jetty:jetty-util</exclude>
                                            <exclude>org.eclipse.jetty:jetty-security</exclude>
                                            <exclude>org.eclipse.jetty:jetty-servlet</exclude>
                                            <exclude>org.gephi:*</exclude>
                                            <exclude>org.netbeans.api:*</exclude>

                                            <exclude>commons-fileupload:commons-fileupload</exclude>
                                            <exclude>org.apache.avro:avro</exclude>
                                            <exclude>commons-collections:commons-collections</exclude>
                                            <exclude>org.codehaus.jackson:jackson-core-asl</exclude>
                                            <exclude>org.codehaus.jackson:jackson-mapper-asl</exclude>
                                            <exclude>com.thoughtworks.paranamer:paranamer</exclude>
                                            <exclude>org.xerial.snappy:snappy-java</exclude>
                                            <exclude>org.apache.commons:commons-compress</exclude>
                                            <exclude>org.tukaani:xz</exclude>
                                            <exclude>com.esotericsoftware.kryo:kryo</exclude>
                                            <exclude>com.esotericsoftware.minlog:minlog</exclude>
                                            <exclude>org.objenesis:objenesis</exclude>
                                            <exclude>com.twitter:chill_*</exclude>
                                            <exclude>com.twitter:chill-java</exclude>
                                            <exclude>com.twitter:chill-avro_*</exclude>
                                            <exclude>com.twitter:chill-bijection_*</exclude>
                                            <exclude>com.twitter:bijection-core_*</exclude>
                                            <exclude>com.twitter:bijection-avro_*</exclude>
                                            <exclude>commons-lang:commons-lang</exclude>
                                            <exclude>junit:junit</exclude>
                                            <exclude>de.javakaffee:kryo-serializers</exclude>
                                            <exclude>joda-time:joda-time</exclude>
                                            <exclude>org.apache.commons:commons-lang3</exclude>
                                            <exclude>org.slf4j:slf4j-api</exclude>
                                            <exclude>org.slf4j:slf4j-log4j12</exclude>
                                            <exclude>log4j:log4j</exclude>
                                            <exclude>org.apache.commons:commons-math</exclude>
                                            <exclude>org.apache.sling:org.apache.sling.commons.json</exclude>
                                            <exclude>commons-logging:commons-logging</exclude>
                                            <!--											<exclude>org.apache.httpcomponents:httpclient</exclude>-->
                                            <!--											<exclude>org.apache.httpcomponents:httpcore</exclude>-->
                                            <exclude>commons-codec:commons-codec</exclude>
                                            <!--<exclude>com.fasterxml.jackson.core:jackson-core</exclude>-->
                                            <!--<exclude>com.fasterxml.jackson.core:jackson-databind</exclude>-->
                                            <!--<exclude>com.fasterxml.jackson.core:jackson-annotations</exclude>-->
                                            <exclude>org.codehaus.jettison:jettison</exclude>
                                            <exclude>stax:stax-api</exclude>
                                            <exclude>com.typesafe:config</exclude>
                                            <exclude>org.uncommons.maths:uncommons-maths</exclude>
                                            <!--<exclude>com.github.scopt:scopt_*</exclude>-->
                                            <exclude>org.mortbay.jetty:servlet-api</exclude>
                                            <exclude>commons-io:commons-io</exclude>
                                            <exclude>commons-cli:commons-cli</exclude>

                                            <exclude>sqlite:*</exclude>
                                            <exclude>netbeans:*</exclude>
                                            <exclude>org.apache.xmlgraphics:*</exclude>
                                            <exclude>mysql:*</exclude>
                                            <exclude>jfree:*</exclude>
                                            <exclude>org.scala-lang.modules:*</exclude>
                                        </excludes>
                                    </artifactSet>
                                    <filters>
                                        <filter>
                                            <artifact>org.apache.flink:*</artifact>
                                            <excludes>
                                                <exclude>org/apache/flink/shaded/**</exclude>
                                                <exclude>web-docs/**</exclude>
                                            </excludes>
                                        </filter>
                                        <filter>
                                            <!-- Do not copy the signatures in the META-INF folder.
                                            Otherwise, this might cause SecurityExceptions when using the JAR. -->
                                            <artifact>*:*</artifact>
                                            <excludes>
                                                <exclude>META-INF/*.SF</exclude>
                                                <exclude>META-INF/*.DSA</exclude>
                                                <exclude>META-INF/*.RSA</exclude>
                                            </excludes>
                                        </filter>
                                    </filters>
                                    <finalName>dist-${project.artifactId}-${project.version}</finalName>
                                    <outputDirectory>${project.build.directory}/shaded</outputDirectory>
                                    <transformers>
                                        <transformer
                                                implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                                        <!-- add Main-Class to manifest file -->
                                        <transformer
                                                implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                            <mainClass>net.sansa_stack.inference.flink.RDFGraphMaterializer</mainClass>
                                        </transformer>
                                    </transformers>
                                    <createDependencyReducedPom>false</createDependencyReducedPom>
                                    <relocations>
                                        <relocation>
                                            <pattern>scopt</pattern>
                                            <shadedPattern>scopt.shaded</shadedPattern>
                                        </relocation>
                                    </relocations>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <configuration>
                            <descriptors>
                                <descriptor>src/assembly/assembly-bin.xml</descriptor>
                            </descriptors>
                            <appendAssemblyId>false</appendAssemblyId>
                        </configuration>
                        <executions>
                            <execution>
                                <id>make-assembly</id> <!-- this is used for inheritance merges -->
                                <phase>package</phase> <!-- bind to the packaging phase -->
                                <goals>
                                    <goal>single</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
