<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~ 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 https://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.apache.atlas</groupId>
        <artifactId>apache-atlas</artifactId>
        <version>3.0.0-SNAPSHOT</version>
    </parent>
    <artifactId>atlas-webapp</artifactId>
    <description>Apache Atlas Web Application</description>
    <name>Apache Atlas Web Application</name>
    <packaging>war</packaging>

    <properties>
        <projectBaseDir>${project.basedir}/..</projectBaseDir>
        <debug.jetty.daemon>true</debug.jetty.daemon>
        <log4j.configuration.url>file:///${project.build.directory}/../../distro/src/conf/atlas-log4j.xml</log4j.configuration.url>
    </properties>

    <profiles>
        <profile>
            <id>dist</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <packages.to.exclude>${distro.exclude.packages}</packages.to.exclude>
            </properties>
        </profile>

        <profile>
            <id>berkeley-elasticsearch</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <packages.to.exclude>WEB-INF/lib/je-*.jar,WEB-INF/lib/dom4j-*.jar</packages.to.exclude>
            </properties>
        </profile>

        <profile>
            <id>berkeley-solr</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <packages.to.exclude>WEB-INF/lib/dom4j-*.jar</packages.to.exclude>
            </properties>
        </profile>

        <profile>
            <id>Windows</id>
            <activation>
                <os>
                    <family>windows</family>
                </os>
            </activation>
            <properties>
                <log4j.configuration.url>file:/${project.build.directory}/../../distro/src/conf/atlas-log4j.xml</log4j.configuration.url>
            </properties>
        </profile>

    </profiles>

    <dependencies>
        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-graphdb-impls</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-handler</artifactId>
                </exclusion>
            </exclusions>
            <type>pom</type>
        </dependency>

        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-common</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-repository</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-handler</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-client-v1</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-client-v2</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-authorization</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-notification</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-intg</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-janusgraph-hbase2</artifactId>
            <version>${project.version}</version>
            <exclusions>
              <exclusion>
                <groupId>org.noggit</groupId>
                <artifactId>noggit</artifactId>
              </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-common</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>javax.servlet</groupId>
                    <artifactId>servlet-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-minikdc</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-hdfs</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>javax.servlet</groupId>
                    <artifactId>servlet-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Zookeeper, curator -->
        <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-framework</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-recipes</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-client</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.zookeeper</groupId>
            <artifactId>zookeeper</artifactId>


        </dependency>
        <!-- supports simple auth handler -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
        </dependency>

        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
        </dependency>

        <dependency>
            <groupId>commons-configuration</groupId>
            <artifactId>commons-configuration</artifactId>
        </dependency>

        <dependency>
            <groupId>commons-cli</groupId>
            <artifactId>commons-cli</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-collections4</artifactId>
        </dependency>

        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
        </dependency>

        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-server</artifactId>
        </dependency>

        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-webapp</artifactId>
        </dependency>

        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-core</artifactId>
        </dependency>

        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
        </dependency>

        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-client</artifactId>
        </dependency>

        <dependency>
            <groupId>com.sun.jersey.contribs</groupId>
            <artifactId>jersey-multipart</artifactId>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
        </dependency>

        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
        </dependency>

        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>${guice.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.google.inject.extensions</groupId>
            <artifactId>guice-throwingproviders</artifactId>
            <version>${guice.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.google.inject.extensions</groupId>
            <artifactId>guice-multibindings</artifactId>
            <version>${guice.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-jsp</artifactId>
        </dependency>

        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>javax.el</artifactId>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>

        <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
        </dependency>

        <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-web</artifactId>
        </dependency>

        <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
        </dependency>

        <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-core</artifactId>
        </dependency>

        <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-web</artifactId>
        </dependency>

        <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-config</artifactId>
        </dependency>

        <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-ldap</artifactId>
        </dependency>
        <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
        </dependency>

        <!-- Jersey + Spring -->
        <dependency>
            <groupId>com.sun.jersey.contribs</groupId>
            <artifactId>jersey-spring</artifactId>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-servlet</artifactId>
        </dependency>
        <!-- Required for Spring configuration processing -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>1.8.9</version>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.8.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-dashboardv2</artifactId>
            <type>war</type>
        </dependency>
        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-dashboardv3</artifactId>
            <type>war</type>
        </dependency>
        <dependency>
            <groupId>org.easymock</groupId>
            <artifactId>easymock</artifactId>
            <version>3.4</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-intg</artifactId>
            <classifier>tests</classifier>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-repository</artifactId>
            <classifier>tests</classifier>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-high-level-client</artifactId>
            <version>${elasticsearch.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.elasticsearch</groupId>
                    <artifactId>elasticsearch</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-graphdb-common</artifactId>
            <classifier>tests</classifier>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.nimbusds</groupId>
            <artifactId>nimbus-jose-jwt</artifactId>
            <version>5.4</version>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.bouncycastle</groupId>
                    <artifactId>bcprov-jdk15on</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-server-api</artifactId>
        </dependency>

        <dependency>
            <groupId>com.webcohesion.enunciate</groupId>
            <artifactId>enunciate-core-annotations</artifactId>
        </dependency>
        <!-- PAM -->
        <dependency>
            <groupId>org.kohsuke</groupId>
            <artifactId>libpam4j</artifactId>
            <version>1.11</version>
        </dependency>

        <dependency>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna</artifactId>
            <version>5.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-hdfs-client</artifactId>
            <version>${hadoop.version}</version>
        </dependency>

        <!-- AWS library -->
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-aws</artifactId>
            <version>${hadoop.version}</version>
        </dependency>

        <!-- Keycloak -->
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-spring-security-adapter</artifactId>
            <version>${keycloak.version}</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <archiveClasses>true</archiveClasses>
                    <attachClasses>true</attachClasses>
                    <overlays>
                        <overlay>
                            <groupId>org.apache.atlas</groupId>
                            <artifactId>atlas-dashboardv2</artifactId>
                        </overlay>
                        <overlay>
                            <groupId>org.apache.atlas</groupId>
                            <artifactId>atlas-dashboardv3</artifactId>
                        </overlay>
                        <overlay>
                            <!-- empty groupId/artifactId represents the current build -->
                        </overlay>
                    </overlays>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                        </manifest>
                    </archive>
                    <packagingExcludes>
                        WEB-INF/lib/junit*.jar,WEB-INF/lib/dom4j-*.jar,${packages.to.exclude}
                    </packagingExcludes>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>keytool-maven-plugin</artifactId>
                <version>1.5</version>
                <executions>
                    <execution>
                        <id>clean</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>generateKeyPair</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>generateKeyPair</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <dname>cn=atlas.apache.org</dname>
                    <keystore>${project.build.directory}/atlas.keystore</keystore>
                    <keypass>keypass</keypass>
                    <storepass>keypass</storepass>
                    <alias>atlas</alias>
                    <keyalg>RSA</keyalg>
                    <validity>100000</validity>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemProperties>
                        <user.dir>${project.basedir}</user.dir>
                        <projectBaseDir>${project.basedir}/..</projectBaseDir>
                    </systemProperties>
                    <forkMode>always</forkMode>
                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
                    <argLine>-Djava.awt.headless=true -Dproject.version=${project.version}
                        -Dhadoop.tmp.dir=${project.build.directory}/tmp-hadoop-${user.name}
                        -Xmx1024m
                    </argLine>
                </configuration>
                <executions>
                    <!-- Needed for explicit separation of UTs, SSL/Kerberos/Secure server tests and ITs-->
                    <execution>
                        <id>default-test</id>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </execution>

                    <!-- Unit tests don't rely of WAR being built and don't interact with real server -->
                    <execution>
                        <id>unit-tests</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>**/*Test.java</include>
                            </includes>
                            <excludes>
                                <exclude>**/*SSL*.java</exclude>
                                <exclude>**/*Kerberos*.java</exclude>
                                <exclude>**/*Base*.java</exclude>
                                <exclude>**/*Secure*.java</exclude>
                                <exclude>**/*Server*.java</exclude>
                                <exclude>**/*$*.java</exclude>
                            </excludes>
                        </configuration>
                    </execution>

                    <!-- Secure tests rely on the generated WAR and (may) start atlas server for tests -->
                    <!-- Eventually all these server interaction tests need to move to IT phase -->
                    <execution>
                        <id>secure-tests</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>**/*SSL*Test.java</include>
                                <include>**/*Kerberos*Test.java</include>
                                <include>**/*Secure*Test.java</include>
                                <include>**/*Server*Test.java</include>
                                <include>**/*$*.java</include>
                            </includes>
                            <excludes>
                                <exclude>**/*Base*.java</exclude>
                            </excludes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <tasks>
                                <delete dir="${project.build.directory}/data"/>
                                <delete dir="${project.build.directory}/logs"/>
                            </tasks>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <configuration>
                    <skip>${skipTests}</skip>
                    <!--only skip int tests -->
                    <httpConnector>
                        <port>31000</port>
                        <idleTimeout>60000</idleTimeout>
                    </httpConnector>
                    <war>${project.build.directory}/atlas-webapp-${project.version}.war</war>
                    <daemon>true</daemon>
                    <webAppSourceDirectory>${project.basedir}/src/main/webapp</webAppSourceDirectory>
                    <webApp>
                        <contextPath>/</contextPath>
                        <descriptor>${project.basedir}/src/main/webapp/WEB-INF/web.xml</descriptor>
                        <extraClasspath>${project.build.testOutputDirectory}</extraClasspath>
                    </webApp>
                    <useTestScope>true</useTestScope>
                    <systemProperties>
                        <systemProperty>
                            <name>atlas.home</name>
                            <value>${project.build.directory}</value>
                        </systemProperty>
                        <systemProperty>
                            <key>atlas.conf</key>
                            <value>${project.build.directory}/test-classes</value>
                        </systemProperty>
                        <systemProperty>
                            <name>atlas.data</name>
                            <value>${project.build.directory}/data</value>
                        </systemProperty>
                        <systemProperty>
                            <name>atlas.log.dir</name>
                            <value>${project.build.directory}/logs</value>
                        </systemProperty>
                        <systemProperty>
                            <name>atlas.log.file</name>
                            <value>application.log</value>
                        </systemProperty>
                        <systemProperty>
                            <name>log4j.configuration</name>
                            <value>${log4j.configuration.url}</value>
                        </systemProperty>
                        <systemProperty>
                            <name>atlas.graphdb.backend</name>
                            <value>${graphdb.backend.impl}</value>
                        </systemProperty>
                        <systemProperty>
                            <key>embedded.solr.directory</key>
                            <value>${project.build.directory}</value>
                        </systemProperty>
                        <systemProperty>
                            <name>org.eclipse.jetty.annotations.maxWait</name>
                            <value>5000</value>
                        </systemProperty>
                        <systemProperty>
                            <name>org.eclipse.jetty.annotations.maxWait</name>
                            <value>5000</value>
                        </systemProperty>
                    </systemProperties>
                    <stopKey>atlas-stop</stopKey>
                    <stopPort>31001</stopPort>
                    <stopWait>${jetty-maven-plugin.stopWait}</stopWait>
                    <daemon>${debug.jetty.daemon}</daemon>
                    <testClassesDirectory>${project.build.testOutputDirectory}</testClassesDirectory>
                    <useTestClasspath>true</useTestClasspath>
                </configuration>
                <executions>
                    <execution>
                        <id>start-jetty</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>deploy-war</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>stop-jetty</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
           <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/models/</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}/../addons/models/</directory>
                                    <includes>
                                        <include>0000-Area0/0011-glossary_model.json</include>
                                        <include>0000-Area0/0010-base_model.json</include>
                                        <include>1000-Hadoop/**</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>

                    <execution>
                        <id>copy-solr-resources</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/solr</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}/../test-tools/src/main/resources/solr</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.webcohesion.enunciate</groupId>
                <artifactId>enunciate-maven-plugin</artifactId>
                <version>${enunciate-maven-plugin.version}</version>
                <configuration>
                    <configFile>${project.parent.basedir}/build-tools/src/main/resources/enunciate.xml</configFile>
                    <enunciateArtifactId/>
                    <docsDir>${project.build.directory}/api/v2/</docsDir>
                    <source>1.8</source>
                    <target>1.8</target>
                    <skipEnunciate>${skipEnunciate}</skipEnunciate>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>javax.annotation</groupId>
                        <artifactId>javax.annotation-api</artifactId>
                        <version>1.3</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>


</project>
