<?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">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <artifactId>tajo-project</artifactId>
    <groupId>org.apache.tajo</groupId>
    <version>0.11.1</version>
    <relativePath>../tajo-project</relativePath>
  </parent>
  <artifactId>tajo-cli</artifactId>
  <packaging>jar</packaging>
  <name>Tajo CLI tools</name>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <metrics.version>3.0.1</metrics.version>
  </properties>

  <repositories>
    <repository>
      <id>repository.jboss.org</id>
      <url>https://repository.jboss.org/nexus/content/repositories/releases/
      </url>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
  </repositories>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.rat</groupId>
        <artifactId>apache-rat-plugin</artifactId>
        <executions>
          <execution>
            <phase>verify</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <systemProperties>
            <tajo.test.enabled>true</tajo.test.enabled>
          </systemProperties>
          <argLine>-Xms512m -Xmx1024m -Dfile.encoding=UTF-8</argLine>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.2</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>test-jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-dependencies</id>
            <phase>package</phase>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <configuration>
              <includeScope>runtime</includeScope>
              <outputDirectory>${project.build.directory}/lib</outputDirectory>
              <overWriteReleases>false</overWriteReleases>
              <overWriteSnapshots>false</overWriteSnapshots>
              <overWriteIfNewer>true</overWriteIfNewer>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-pmd-plugin</artifactId>
        <version>2.7.1</version>
      </plugin>
    </plugins>
  </build>


  <dependencies>
    <dependency>
      <groupId>org.apache.tajo</groupId>
      <artifactId>tajo-client</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.tajo</groupId>
      <artifactId>tajo-catalog-common</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.tajo</groupId>
      <artifactId>tajo-storage-common</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.tajo</groupId>
      <artifactId>tajo-storage-hdfs</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.tajo</groupId>
      <artifactId>tajo-rpc-protobuf</artifactId>
    </dependency>
    <dependency>
      <groupId>commons-cli</groupId>
      <artifactId>commons-cli</artifactId>
      <version>1.2</version>
    </dependency>

    <dependency>
      <groupId>org.apache.hadoop</groupId>
      <artifactId>hadoop-client</artifactId>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <artifactId>protobuf-java</artifactId>
          <groupId>com.google.protobuf</groupId>
        </exclusion>
        <exclusion>
          <artifactId>hadoop-mapreduce-client-app</artifactId>
          <groupId>org.apache.hadoop</groupId>
        </exclusion>
        <exclusion>
          <artifactId>hadoop-yarn-api</artifactId>
          <groupId>org.apache.hadoop</groupId>
        </exclusion>
        <exclusion>
          <artifactId>hadoop-mapreduce-client-jobclient</artifactId>
          <groupId>org.apache.hadoop</groupId>
        </exclusion>
        <exclusion>
          <artifactId>hadoop-mapreduce-client-core</artifactId>
          <groupId>org.apache.hadoop</groupId>
        </exclusion>
        <exclusion>
          <artifactId>netty-all</artifactId>
          <groupId>io.netty</groupId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>2.4</version>
    </dependency>
    <dependency>
      <groupId>jline</groupId>
      <artifactId>jline</artifactId>
    </dependency>
  </dependencies>


  <profiles>
    <profile>
      <id>all-dependencies</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <dependencies>
        <dependency>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-client</artifactId>
          <exclusions>
            <exclusion>
              <artifactId>protobuf-java</artifactId>
              <groupId>com.google.protobuf</groupId>
            </exclusion>
            <exclusion>
              <artifactId>hadoop-mapreduce-client-app</artifactId>
              <groupId>org.apache.hadoop</groupId>
            </exclusion>
            <exclusion>
              <artifactId>hadoop-yarn-api</artifactId>
              <groupId>org.apache.hadoop</groupId>
            </exclusion>
            <exclusion>
              <artifactId>hadoop-mapreduce-client-jobclient</artifactId>
              <groupId>org.apache.hadoop</groupId>
            </exclusion>
            <exclusion>
              <artifactId>hadoop-mapreduce-client-core</artifactId>
              <groupId>org.apache.hadoop</groupId>
            </exclusion>
          </exclusions>
        </dependency>
      </dependencies>
    </profile>


    <profile>
      <id>docs</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
              <execution>
                <!-- build javadoc jars per jar for publishing to maven -->
                <id>module-javadocs</id>
                <phase>package</phase>
                <goals>
                  <goal>jar</goal>
                </goals>
                <configuration>
                  <destDir>${project.build.directory}</destDir>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>dist</id>
      <activation>
        <activeByDefault>false</activeByDefault>
        <property>
          <name>tar|rpm|deb</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
              <execution>
                <id>dist</id>
                <phase>package</phase>
                <goals>
                  <goal>run</goal>
                </goals>
                <configuration>
                  <target>
                    <echo file="${project.build.directory}/dist-layout-stitching.sh">
                      run() {
                      echo "\$ ${@}"
                      "${@}"
                      res=$?
                      if [ $res != 0 ]; then
                      echo
                      echo "Failed!"
                      echo
                      exit $res
                      fi
                      }

                      ROOT=`cd ${basedir}/..;pwd`
                      echo
                      echo "Current directory `pwd`"
                      echo
                      run rm -rf ${project.artifactId}-${project.version}
                      run mkdir ${project.artifactId}-${project.version}
                      run cd ${project.artifactId}-${project.version}
                      run cp -r ${basedir}/target/${project.artifactId}-${project.version}*.jar .
                      echo
                      echo "Tajo Client dist layout available at: ${project.build.directory}/${project.artifactId}-${project.version}"
                      echo
                    </echo>
                    <exec executable="sh" dir="${project.build.directory}" failonerror="true">
                      <arg line="./dist-layout-stitching.sh" />
                    </exec>
                  </target>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-project-info-reports-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-report-plugin</artifactId>
      </plugin>
    </plugins>
  </reporting>
</project>

