<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
 * Copyright (c) Codice Foundation
 *
 * This is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either
 * version 3 of the License, or any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details. A copy of the GNU Lesser General Public License is distributed along with this program and can be found at
 * <http://www.gnu.org/licenses/lgpl.html>.
 *
 **/
-->
<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>
        <groupId>ddf</groupId>
        <artifactId>distribution</artifactId>
        <version>2.26.46</version>
    </parent>
    <artifactId>ddf-catalog</artifactId>
    <groupId>org.codice.ddf</groupId>
    <name>DDF :: Distribution :: DDF Catalog</name>
    <packaging>pom</packaging>
    <properties>
        <distribution.file.name>ddf-catalog-${project.version}</distribution.file.name>
        <setup.folder>target/dependencies</setup.folder>
    </properties>
    <build>
        <resources>
            <!--
            Resources for this distribution include its features XML file and the Apache Karaf
            .cfg file that defines the feature repositories and list of features to install at startup.
            -->
            <resource>
                <directory>src/main/filtered-resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/*</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <!--
            Resources plugin will do filtering on dirs/files specified in
            <resources> above. This will result in these files being
            filtered and their generated resource being placed in target/classes
            directory.
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>filter</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>resources</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!--
                Adds all of the feature repositories from DDF Kernel distribution, and this DDF Catalog distribution to the Karaf system folder, which is the repo for Karaf at runtime.
            -->
            <plugin>
                <groupId>org.apache.karaf.tooling</groupId>
                <artifactId>karaf-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>features-add-to-repository</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>features-add-to-repository</goal>
                        </goals>
                        <configuration>
                            <addTransitiveFeatures>true</addTransitiveFeatures>
                            <descriptors>
                                <descriptor>
                                    mvn:ddf.features/kernel/${project.version}/xml/features
                                </descriptor>
                                <descriptor>
                                    mvn:ddf.features/install-profiles/${project.version}/xml/features
                                </descriptor>
                            </descriptors>
                            <features>
                                <feature>kernel</feature>
                                <feature>profile-minimum</feature>
                                <feature>profile-catalog</feature>
                            </features>
                            <repository>${setup.folder}/ddf-kernel-${project.version}/system</repository>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.codice.ddf</groupId>
                                    <artifactId>kernel</artifactId>
                                    <version>${project.version}</version>
                                    <type>zip</type>
                                    <outputDirectory>${setup.folder}</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!--
            Uses the assembly descriptor in this DDF distribution project (bin.xml) which
            also injects the copied common-bin.xml descriptor from ddf-common, to create
            the ddf-kernel-xxx.zip distribution in the /target directory.
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <id>bin</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>src/main/descriptors/bin.xml</descriptor>
                            </descriptors>
                            <appendAssemblyId>false</appendAssemblyId>
                            <finalName>${distribution.file.name}</finalName>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <executions>
                    <execution>
                        <id>check-artifact-size</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireFilesSize>
                                    <maxsize>300000000</maxsize>
                                    <minsize>260000000</minsize>
                                    <files>
                                        <file>${project.build.directory}/${distribution.file.name}.zip</file>
                                    </files>
                                </requireFilesSize>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>org.codice.ddf</groupId>
            <artifactId>kernel</artifactId>
            <version>${project.version}</version>
            <type>zip</type>
            <exclusions>
                <exclusion>
                    <artifactId>*</artifactId>
                    <groupId>*</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>ddf.features</groupId>
            <artifactId>kernel</artifactId>
            <version>${project.version}</version>
            <type>xml</type>
            <classifier>features</classifier>
        </dependency>
        <dependency>
            <groupId>ddf.features</groupId>
            <artifactId>install-profiles</artifactId>
            <version>${project.version}</version>
            <classifier>features</classifier>
            <type>xml</type>
        </dependency>
    </dependencies>
</project>
