<?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>apache-storm-bin</artifactId>
        <groupId>org.apache.storm</groupId>
        <version>3.0.0</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>final-package</artifactId>


    <name>Storm Binary Distribution Final Package</name>
    <packaging>pom</packaging>
    <description>Storm binary distribution</description>

    <dependencies>
        <dependency>
            <groupId>org.apache.storm</groupId>
            <artifactId>storm-core</artifactId>
            <version>${project.version}</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>apache-storm-${project.version}</finalName>
        <plugins>
            <!--
                Stage the daemon (lib) and shared (lib-common) jars before assembly and de-duplicate
                them. The worker classpath is a byte-identical subset of the daemon classpath, so the
                shared jars are kept once in lib-common (referenced by both classpaths in bin/storm.py)
                and removed from lib. See src/main/scripts/dedup-libs.py.
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>stage-daemon-lib</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeScope>runtime</includeScope>
                            <outputDirectory>${project.build.directory}/staging/lib</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>stage-common-lib</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/staging/lib-common</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${project.basedir}/../storm-client-bin/target/client/client/lib-worker</directory>
                                    <includes>
                                        <include>*.jar</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>dedup-libs</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>python3</executable>
                            <arguments>
                                <argument>${project.basedir}/src/main/scripts/dedup-libs.py</argument>
                                <argument>${project.build.directory}/staging</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <!-- Full distribution: apache-storm-${version}.tar.gz / .zip -->
                    <execution>
                        <id>bin</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>${project.basedir}/src/main/assembly/binary.xml</descriptor>
                            </descriptors>
                            <appendAssemblyId>false</appendAssemblyId>
                        </configuration>
                    </execution>
                    <!--
                        Lean "storm-lite" distribution: apache-storm-${version}-lite.tar.gz / .zip
                        (attached with the "lite" classifier). Same contents as the full
                        distribution minus the bundled storm-autocreds and storm-kafka-monitor jars.
                    -->
                    <execution>
                        <id>lite</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>${project.basedir}/src/main/assembly/binary-lite.xml</descriptor>
                            </descriptors>
                            <appendAssemblyId>true</appendAssemblyId>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <attach>true</attach>
                    <tarLongFileMode>posix</tarLongFileMode>
                    <runOnlyAtExecutionRoot>false</runOnlyAtExecutionRoot>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>unix_py_tests</id>
            <activation>
                <os>
                    <family>unix</family>
                </os>
            </activation>
            <build>
                <plugins>
                    <!-- Run the dedup-libs.py unit tests before the script is used at prepare-package time. -->
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>python3-test-dedup-libs</id>
                                <phase>test</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>python3</executable>
                                    <workingDirectory>src/main/scripts</workingDirectory>
                                    <arguments>
                                        <argument>test_dedup_libs.py</argument>
                                    </arguments>
                                    <environmentVariables>
                                        <PYTHONDONTWRITEBYTECODE>true</PYTHONDONTWRITEBYTECODE>
                                    </environmentVariables>
                                    <skip>${skipTests}</skip>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
