<?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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <artifactId>zeppelin</artifactId>
    <groupId>org.apache.zeppelin</groupId>
    <version>0.12.1</version>
    <relativePath>../pom.xml</relativePath>
  </parent>

  <artifactId>zeppelin-distribution</artifactId>
  <packaging>pom</packaging>
  <name>Zeppelin: Packaging distribution</name>

  <dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>zeppelin-server</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>zeppelin-web-angular</artifactId>
      <version>${project.version}</version>
      <type>war</type>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-install-plugin</artifactId>
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-deploy-plugin</artifactId>
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>

      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
          <finalName>${project.parent.artifactId}-${project.version}-bin</finalName>
          <appendAssemblyId>false</appendAssemblyId>
          <attach>false</attach>
          <tarLongFileMode>posix</tarLongFileMode>
          <descriptors>
            <descriptor>src/assemble/distribution.xml</descriptor>
          </descriptors>
        </configuration>
      </plugin>

    </plugins>
  </build>

  <profiles>
    <profile>
      <id>web-classic</id>
      <dependencies>
        <dependency>
          <groupId>${project.groupId}</groupId>
          <artifactId>zeppelin-web</artifactId>
          <version>${project.version}</version>
          <type>war</type>
        </dependency>
      </dependencies>
    </profile>

    <profile>
      <id>publish-distr</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <build>
        <!-- skip tests in surefire plugin -->
        <!-- assembly:single -->
        <!-- publish distribution to S3

        to settings.xml add:
        <profiles><profile>
           <id>inject-s3-credentials</id>
           <properties>
            <s3-upload.accessKey>your-key</s3-upload.accessKey>
            <s3-upload.secretKey>your-secret-key</s3-upload.secretKey>
           </properties>
         </profile></profiles>
        <activeProfiles>
          <activeProfile>inject-s3-credentials</activeProfile>
        </activeProfiles>
        -->

        <plugins>
          <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <skipTests>true</skipTests>
            </configuration>
          </plugin>
          <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
              <tarLongFileMode>posix</tarLongFileMode>
            </configuration>
            <executions>
              <execution>
                <id>make-assembly</id>
                <phase>package</phase>
                <goals>
                  <goal>single</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>com.bazaarvoice.maven.plugins</groupId>
            <artifactId>s3-upload-maven-plugin</artifactId>
            <configuration>
              <bucketName>zeppel.in</bucketName>
              <endpoint>s3-ap-northeast-1.amazonaws.com</endpoint>
              <makePublic>true</makePublic>
              <sourceFile>zeppelin-distribution/target/zeppelin-${project.version}-bin.tgz</sourceFile>
              <destinationFile>zeppelin-${project.version}-bin.tgz</destinationFile>
            </configuration>
            <executions>
              <execution>
                <id>publish-distr-to-s3</id>
                <phase>package</phase>
                <goals>
                  <goal>s3-upload</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
