<?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/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>sentry-service</artifactId>
        <groupId>org.apache.sentry</groupId>
        <version>2.1.0</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>sentry-service-api</artifactId>
    <name>Sentry Service API</name>
    <dependencies>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-common</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.sentry</groupId>
            <artifactId>sentry-core-common</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.sentry</groupId>
            <artifactId>sentry-core-model-db</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.sentry</groupId>
            <artifactId>sentry-binding-hive-conf</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.thrift</groupId>
            <artifactId>libthrift</artifactId>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.hive</groupId>
            <artifactId>hive-common</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.sentry</groupId>
            <artifactId>sentry-provider-common</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.sentry</groupId>
            <artifactId>sentry-core-model-kafka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.sentry</groupId>
            <artifactId>sentry-core-model-solr</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.sentry</groupId>
            <artifactId>sentry-core-model-sqoop</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.sentry</groupId>
            <artifactId>sentry-core-model-indexer</artifactId>
        </dependency>
      <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <scope>test</scope>
      </dependency>
    </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-source</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>src/gen/thrift/gen-javabean</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <configuration>
                        <sourcepath>${project.build.sourceDirectory}:${basedir}/src/gen/thrift/gen-javabean</sourcepath>
                        <sourceFileExcludes>
                            <exclude>${project.build.sourceDirectory}:${basedir}/src/gen/thrift/gen-javabean</exclude>
                        </sourceFileExcludes>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
    <profiles>
        <profile>
            <id>thriftif</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>generate-thrift-sources</id>
                                <phase>generate-sources</phase>
                                <configuration>
                                    <target>
                                        <taskdef name="for" classname="net.sf.antcontrib.logic.ForTask"
                                                 classpathref="maven.plugin.classpath" />
                                        <property name="thrift.args" value="-I ${thrift.home} --gen java:beans,hashcode,generated_annotations=undated"/>
                                        <property name="thrift.gen.dir" value="${basedir}/src/gen/thrift"/>
                                        <delete dir="${thrift.gen.dir}"/>
                                        <mkdir dir="${thrift.gen.dir}"/>
                                        <for param="thrift.file">
                                            <path>
                                                <fileset dir="${basedir}/src/main/resources/" includes="**/*.thrift" />
                                            </path>
                                            <sequential>
                                                <echo message="Generating Thrift code for @{thrift.file}"/>
                                                <exec executable="${thrift.home}/bin/thrift"  failonerror="true" dir=".">
                                                    <arg line="${thrift.args} -I ${basedir}/src/main/resources/ -o ${thrift.gen.dir} @{thrift.file} " />
                                                </exec>
                                            </sequential>
                                        </for>
                                    </target>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-enforcer-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>enforce-property</id>
                                <goals>
                                    <goal>enforce</goal>
                                </goals>
                                <configuration>
                                    <rules>
                                        <requireProperty>
                                            <property>thrift.home</property>
                                        </requireProperty>
                                    </rules>
                                    <fail>true</fail>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>