<?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 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.apache.atlas</groupId>
        <artifactId>apache-atlas</artifactId>
        <version>0.9-incubating-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>
        <packages.to.exclude />
    </properties>

    <profiles>
        <profile>
            <!-- default profile is for external HBase and Solr - hence not packaging those jars -->
            <id>dist</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <packages.to.exclude>WEB-INF/lib/titan-*.jar,WEB-INF/lib/je-*.jar,WEB-INF/lib/elasticsearch-*.jar,WEB-INF/lib/lucene-*.jar</packages.to.exclude>
            </properties>
        </profile>

        <profile>
            <id>berkeley-elasticsearch</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <packages.to.exclude>WEB-INF/lib/je-*.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>
        <profile>
            <id>titan1</id>
            <!-- remove conflicting lucene/titan versions from catalog when using titan 1 -->
            <dependencyManagement>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.atlas</groupId>
                        <artifactId>atlas-catalog</artifactId>
                        <version>${project.version}</version>
                        <exclusions>
                            <exclusion>
                                <groupId>com.thinkaurelius.titan</groupId>
                                <artifactId>titan-core</artifactId>
                            </exclusion>
                            <exclusion>
                                <groupId>org.apache.lucene</groupId>
                                <artifactId>lucene-core</artifactId>
                            </exclusion>
                            <exclusion>
                                <groupId>org.apache.lucene</groupId>
                                <artifactId>lucene-queryparser</artifactId>
                            </exclusion>
                            <exclusion>
                                <groupId>org.apache.lucene</groupId>
                                <artifactId>lucene-analyzers-common</artifactId>
                            </exclusion>
                        </exclusions>
                    </dependency>
                </dependencies>
            </dependencyManagement>

            <dependencies>
                <dependency>
                    <groupId>org.apache.atlas</groupId>
                    <artifactId>atlas-catalog</artifactId>
                    <scope>provided</scope>
                </dependency>
            </dependencies>
        </profile>
    </profiles>

    <dependencies>
        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-graphdb-impls</artifactId>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-common</artifactId>
        </dependency>

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

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

        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-client</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.hadoop</groupId>
            <artifactId>hadoop-common</artifactId>
        </dependency>


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

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

        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-catalog</artifactId>
        </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>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</groupId>
            <artifactId>jersey-json</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>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
        </dependency>

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

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

        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-core-asl</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>
        <dependency>
                <groupId>org.springframework.ldap</groupId>
                <artifactId>spring-ldap-core</artifactId>
        </dependency>

        <!-- Jersey + Spring -->
        <dependency>
            <groupId>com.sun.jersey.contribs</groupId>
            <artifactId>jersey-spring</artifactId>
            <version>1.8</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-web</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-beans</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-context</artifactId>
                </exclusion>
            </exclusions>
        </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.easymock</groupId>
            <artifactId>easymock</artifactId>
            <version>3.4</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-typesystem</artifactId>
            <classifier>tests</classifier>
            <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.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>3.9</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-repository</artifactId>
            <classifier>tests</classifier>
            <scope>test</scope>
        </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.8</version>
        </dependency>

        <dependency>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna</artifactId>
            <version>4.1.0</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>
                            <!-- empty groupId/artifactId represents the current build -->
                        </overlay>
                    </overlays>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                        </manifest>
                    </archive>
                    <packagingExcludes>
                        <!-- Titan and hbase jars should be excluded because an uber jar with shaded dependencies is created.
                        But mvn 3.3.x includes them for some reason. So, excluding them explicitly here -->
                        WEB-INF/lib/titan*.jar,WEB-INF/lib/hbase*.jar,${packages.to.exclude}
                    </packagingExcludes>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>keytool-maven-plugin</artifactId>
                <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.incubator.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>

        <!-- Running unit tests in pre-integration-test phase after war is built -->
            <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>
                    <!--<skipTests>true</skipTests> -->
                    <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 -XX:MaxPermSize=512m
                    </argLine>
                    <excludes>
                        <exclude>**/*Base*</exclude>
                    </excludes>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.surefire</groupId>
                        <artifactId>surefire-testng</artifactId>
                        <version>2.18.1</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>default-test</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </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>webapp/src/test/webapp</webAppSourceDirectory>
                    <webApp>
                        <contextPath>/</contextPath>
                        <descriptor>${project.basedir}/src/test/webapp/WEB-INF/web.xml</descriptor>
                        <extraClasspath>${project.build.testOutputDirectory}</extraClasspath>
                    </webApp>
                    <useTestScope>true</useTestScope>
                    <systemProperties>
                        <systemProperty>
                            <name>log4j.configuration</name>
                            <value>${log4j.configuration.url}</value>
                        </systemProperty>
                        <systemProperty>
                            <name>atlas.log.file</name>
                            <value>application.log</value>
                        </systemProperty>
                        <systemProperty>
                            <name>atlas.log.dir</name>
                            <value>${project.build.directory}/logs</value>
                        </systemProperty>
                        <systemProperty>
                            <name>atlas.graphdb.backend</name>
                            <value>${graphdb.backend.impl}</value>
                        </systemProperty>
                        <systemProperty>
                            <name>keystore.file</name>
                            <value>${project.build.directory}/atlas.keystore
                            </value>
                        </systemProperty>
                        <systemProperty>
                            <name>truststore.file</name>
                            <value>${project.build.directory}/atlas.keystore</value>
                        </systemProperty>
                        <systemProperty>
                            <name>atlas.home</name>
                            <value>${project.build.directory}</value>
                        </systemProperty>
                        <systemProperty>
                            <name>atlas.data</name>
                            <value>${project.build.directory}/data</value>
                        </systemProperty>
                        <systemProperty>
                            <name>atlas.graphdb.backend</name>
                            <value>${graphdb.backend.impl}</value>
                        </systemProperty>
                        <systemProperty>
                            <key>atlas.conf</key>
                            <value>${project.build.directory}/../../typesystem/target/test-classes</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>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
            </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>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

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


</project>