<?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 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.apache.hugegraph</groupId>
    <artifactId>hugegraph-toolchain</artifactId>
    <version>1.2.0</version>
  </parent>
  <groupId>org.apache.hugegraph</groupId>
  <artifactId>hugegraph-dist</artifactId>
  <version>1.2.0</version>
  <licenses>
    <license>
      <name>The Apache Software License, Version 2.0</name>
      <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  <properties>
    <final.name>apache-${release.name}-incubating-${project.version}</final.name>
    <release.name>${project.parent.artifactId}</release.name>
  </properties>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <tasks>
                <echo file="${project.basedir}/dist.sh">root_path=$(cd $(dirname $0)/..; pwd)
                                    cd $root_path || exit

                                    mkdir -p ${final.name}
                                    mv -v $root_path/hugegraph-hubble/apache-hugegraph-hubble-incubating-${project.version} ${final.name}/ || exit
                                    mv -v $root_path/hugegraph-loader/apache-hugegraph-loader-incubating-${project.version} ${final.name}/ || exit
                                    mv -v $root_path/hugegraph-tools/apache-hugegraph-tools-incubating-${project.version} ${final.name}/ || exit
                                    cp -r -v $root_path/hugegraph-dist/release-docs/* $root_path/DISCLAIMER ${final.name}/ || exit

                                    tar zcvf $root_path/target/${final.name}.tar.gz ./${final.name} || exit 1

                                    md5sum $root_path/target/${final.name}.tar.gz
                                    echo -n "hugegraph-toolchain tar.gz available at: "
                                    echo "$root_path/target/${final.name}.tar.gz"
                                    rm -f ${project.basedir}/dist.sh</echo>
                <exec failonerror="true" dir="${project.basedir}" executable="${shell-executable}">
                  <arg line="./dist.sh" />
                </exec>
              </tasks>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <configuration>
          <filesets>
            <fileset>
              <directory>${project.basedir}/..</directory>
              <includes>
                <include>${final.name}.tar.gz</include>
              </includes>
              <followSymlinks>false</followSymlinks>
            </fileset>
          </filesets>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
