<?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>minifi</artifactId>
        <groupId>org.apache.nifi.minifi</groupId>
        <version>1.15.2</version>
    </parent>
    <artifactId>minifi-assembly</artifactId>
    <packaging>pom</packaging>
    <description>This is the assembly of Apache NiFi - MiNiFi</description>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <finalName>minifi-${project.version}</finalName>
                    <attach>false</attach>
                </configuration>
                <executions>
                    <execution>
                        <id>make shared resource</id>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <phase>package</phase>
                        <configuration>
                            <archiverConfig>
                                <defaultDirectoryMode>0775</defaultDirectoryMode>
                                <directoryMode>0775</directoryMode>
                                <fileMode>0664</fileMode>
                            </archiverConfig>
                            <descriptors>
                                <descriptor>src/main/assembly/dependencies.xml</descriptor>
                            </descriptors>
                            <tarLongFileMode>posix</tarLongFileMode>
                            <formats>
                                <format>dir</format>
                                <format>zip</format>
                                <format>tar.gz</format>
                            </formats>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <!-- Logging -->
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jul-to-slf4j</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>log4j-over-slf4j</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi.minifi</groupId>
            <artifactId>minifi-docs</artifactId>
            <classifier>resources</classifier>
            <scope>runtime</scope>
            <type>zip</type>
        </dependency>

        <!-- MiNiFi -->
        <dependency>
            <groupId>org.apache.nifi.minifi</groupId>
            <artifactId>minifi-resources</artifactId>
            <classifier>resources</classifier>
            <scope>runtime</scope>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-bootstrap-utils</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi.minifi</groupId>
            <artifactId>minifi-bootstrap</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi.minifi</groupId>
            <artifactId>minifi-runtime</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi.minifi</groupId>
            <artifactId>minifi-framework-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi.minifi</groupId>
            <artifactId>minifi-framework-nar</artifactId>
            <version>1.15.2</version>
            <type>nar</type>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi.minifi</groupId>
            <artifactId>minifi-server-nar</artifactId>
            <version>1.15.2</version>
            <type>nar</type>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi.minifi</groupId>
            <artifactId>minifi-provenance-repository-nar</artifactId>
            <type>nar</type>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi.minifi</groupId>
            <artifactId>minifi-standard-nar</artifactId>
            <type>nar</type>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi.minifi</groupId>
            <artifactId>minifi-update-attribute-nar</artifactId>
            <type>nar</type>
        </dependency>
        <dependency> <!-- handling this explicitly  Must be in root lib -->
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <scope>compile</scope>
        </dependency>

        <!-- NiFi Assembly Dependencies-->
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-framework-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-jetty-bundle</artifactId>
            <type>nar</type>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-standard-services-api-nar</artifactId>
            <type>nar</type>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-ssl-context-service-nar</artifactId>
            <type>nar</type>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-site-to-site-reporting-nar</artifactId>
            <type>nar</type>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-provenance-repository-nar</artifactId>
            <type>nar</type>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-kerberos-credentials-service-nar</artifactId>
            <type>nar</type>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-runtime</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-nar-utils</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-properties</artifactId>
        </dependency>
    </dependencies>

    <properties>
        <!--Bootstrap Properties -->
        <minifi.jvm.heap.mb>256</minifi.jvm.heap.mb>
        <minifi.jvm.permgen.mb>128</minifi.jvm.permgen.mb>
        <minifi.run.as />

        <!--Commons Daemon Properties-->
        <commons.daemon.version>1.2.1</commons.daemon.version>
        <commons.daemon.sha512sum>62777d2424361162736b4a9b39b9fb4155760d4d7c4a3489fe1868e0912158ae126ef5f42abbd1bcca1dbf5aa6204d8d0029be7c49f222293d6e1421a5173dd7</commons.daemon.sha512sum>
        <commons.daemon.mirror.url>https://repo1.maven.org/maven2/commons-daemon/commons-daemon/${commons.daemon.version}</commons.daemon.mirror.url>
    </properties>

    <profiles>
        <profile>
            <id>windows-service-assembly</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <dependencies>
                            <dependency>
                                <groupId>ant-contrib</groupId>
                                <artifactId>ant-contrib</artifactId>
                                <version>20020829</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution>
                                <id>download-commons-daemon</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <taskdef resource="net/sf/antcontrib/antcontrib.properties" />
                                        <if>
                                            <available file="${basedir}/target/minifiw.exe" />
                                            <then>
                                                <echo message="Skipping download of commons-daemon." />
                                            </then>
                                            <else>
                                                <echo message="Downloading Commons Daemon Windows binaries." />
                                                <property name="commons.daemon.file" value="commons-daemon-${commons.daemon.version}-bin-windows.zip" />
                                                <get src="${commons.daemon.mirror.url}/${commons.daemon.file}" dest="${java.io.tmpdir}/${commons.daemon.file}" skipexisting="true" />
                                                <local name="checksum.matches" />
                                                <checksum file="${java.io.tmpdir}/${commons.daemon.file}" algorithm="SHA-512" property="${commons.daemon.sha512sum}" verifyProperty="checksum.matches" />
                                                <echo message="Checksum match = ${checksum.matches}" />
                                                <condition property="checksum.matches.fail">
                                                    <equals arg1="${checksum.matches}" arg2="false" />
                                                </condition>
                                                <fail if="checksum.matches.fail">Checksum error</fail>
                                                <unzip src="${java.io.tmpdir}/${commons.daemon.file}" dest="${java.io.tmpdir}" />
                                                <copy file="${java.io.tmpdir}/prunmgr.exe" tofile="${basedir}/target/minifiw.exe" />
                                                <copy file="${java.io.tmpdir}/amd64/prunsrv.exe" tofile="${basedir}/target/minifi.exe" />
                                            </else>
                                        </if>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <configuration>
                            <finalName>minifi-${project.version}</finalName>
                            <attach>false</attach>
                        </configuration>
                        <executions>
                            <execution>
                                <id>make shared resource</id>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <phase>package</phase>
                                <configuration>
                                    <archiverConfig>
                                        <defaultDirectoryMode>0775</defaultDirectoryMode>
                                        <directoryMode>0775</directoryMode>
                                        <fileMode>0664</fileMode>
                                    </archiverConfig>
                                    <descriptors>
                                        <descriptor>src/main/assembly/dependencies-windows-service.xml</descriptor>
                                    </descriptors>
                                    <tarLongFileMode>posix</tarLongFileMode>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>minimal-assembly</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <configuration>
                            <finalName>minifi-${project.version}</finalName>
                            <attach>false</attach>
                        </configuration>
                        <executions>
                            <execution>
                                <id>make shared resource</id>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <phase>package</phase>
                                <configuration>
                                    <archiverConfig>
                                        <defaultDirectoryMode>0775</defaultDirectoryMode>
                                        <directoryMode>0775</directoryMode>
                                        <fileMode>0664</fileMode>
                                    </archiverConfig>
                                    <descriptors>
                                        <descriptor>src/main/assembly/dependencies.xml</descriptor>
                                    </descriptors>
                                    <tarLongFileMode>posix</tarLongFileMode>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>avoid-archive-formats</id>
            <activation>
                <property>
                    <name>dir-only</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <configuration>
                            <finalName>minifi-${project.version}</finalName>
                            <attach>false</attach>
                        </configuration>
                        <executions>
                            <execution>
                                <id>make shared resource</id>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <phase>package</phase>
                                <configuration>
                                    <archiverConfig>
                                        <defaultDirectoryMode>0775</defaultDirectoryMode>
                                        <directoryMode>0775</directoryMode>
                                        <fileMode>0664</fileMode>
                                    </archiverConfig>
                                    <descriptors>
                                        <descriptor>src/main/assembly/dependencies.xml</descriptor>
                                    </descriptors>
                                    <tarLongFileMode>posix</tarLongFileMode>
                                    <formats>
                                        <format>dir</format>
                                    </formats>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
