<?xml version="1.0" encoding="UTF-8"?>
<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"
>
    <parent>
        <groupId>org.opennms</groupId>
        <artifactId>org.opennms.container</artifactId>
        <version>27.0.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.opennms.container</groupId>
    <artifactId>org.opennms.container.karaf</artifactId>
    <packaging>karaf-assembly</packaging>
    <name>OpenNMS :: OSGi Container :: Embedded Karaf</name>

    <build>
        <!-- Include resources from src/main in the distribution -->
        <resources>
            <resource>
                <directory>${project.basedir}/src/main/filtered-resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>

        <plugins>
            <!--
                This configuration mimics the default Karaf assembly from:

                https://github.com/apache/karaf/blob/karaf-X.X.X/assemblies/apache-karaf/pom.xml
            -->
            <plugin>
                <groupId>org.apache.karaf.tooling</groupId>
                <artifactId>karaf-maven-plugin</artifactId>
                <version>${karafVersion}</version>
                <extensions>true</extensions>
                <configuration>
                    <bootRepositories>
                        <!-- OPENNMS: Replace the standard, spring, and spring-legacy features files with our modified versions -->
                        <repository>mvn:org.opennms.karaf/opennms/${project.version}/xml/standard</repository>
                        <repository>mvn:org.opennms.karaf/opennms/${project.version}/xml/spring</repository>
                        <repository>mvn:org.opennms.karaf/opennms/${project.version}/xml/spring-legacy</repository>
                        <!-- OPENNMS: Add the OpenNMS feature repository -->
                        <repository>mvn:org.opennms.karaf/opennms/${project.version}/xml/features</repository>
                        <!-- OPENNMS: Add the OpenNMS Karaf extensions feature repository -->
                        <repository>mvn:org.opennms.karaf/opennms/${project.version}/xml/karaf-extensions</repository>
                        <!-- OPENNMS: Add the OpenNMS Minion feature repository -->
                        <repository>mvn:org.opennms.karaf/opennms/${project.version}/xml/minion</repository>
                    </bootRepositories>
                    <installedFeatures>
                        <feature>wrapper</feature>
                    </installedFeatures>
                    <startupFeatures>
                        <feature>eventadmin</feature>
                    </startupFeatures>
                    <bootFeatures>
                        <feature>wrap</feature>
                        <feature>aries-blueprint</feature>
                        <feature>shell</feature>
                        <feature>shell-compat</feature>
                        <feature>feature</feature>
                        <feature>jaas</feature>
                        <feature>ssh</feature>
                        <feature>management</feature>
                        <feature>bundle</feature>
                        <feature>config</feature>
                        <feature>deployer</feature>
                        <feature>diagnostic</feature>
                        <feature>feature</feature>
                        <feature>instance</feature>
                        <feature>kar</feature>
                        <feature>log</feature>
                        <feature>package</feature>
                        <feature>service</feature>
                        <feature>system</feature>

                        <!-- OPENNMS: Add http, http-whiteboard to the default list of features -->
                        <feature>http</feature>
                        <feature>http-whiteboard</feature>
                    </bootFeatures>
                    <libraries>
                        <library>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xerces/2.11.0_1;type:=endorsed;export:=true;delegate:=true</library>
                        <library>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jaxp-api-1.4/${karaf.servicemix.specs.version};type:=endorsed;export:=true</library>
                        <library>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jaxb-api-2.2/${karaf.servicemix.specs.version};type:=endorsed;export:=true</library>
                        <library>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jaxb-api-2.3/2.3_1;type:=endorsed;export:=true</library>
                        <library>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jaxws-api-2.2/${karaf.servicemix.specs.version};type:=endorsed;export:=true</library>
                        <library>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.saaj-api-1.3/${karaf.servicemix.specs.version};type:=endorsed;export:=true</library>
                        <library>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.activation-api-1.1/${karaf.servicemix.specs.version};type:=endorsed;export:=true</library>
                        <library>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.stax-api-1.2/${karaf.servicemix.specs.version};type:=endorsed;export:=true</library>
                        <library>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xalan/2.7.2_3;type:=endorsed;export:=true</library>
                        <library>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xalan-serializer/2.7.2_1;type:=endorsed;export:=true</library>
                        <library>mvn:javax.annotation/javax.annotation-api/1.2;type:=endorsed;export:=true</library>

                        <library>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.activator/${karaf.servicemix.specs.version};type:=default;export:=true</library>
                        <library>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.locator/${karaf.servicemix.specs.version};type:=default;export:=true</library>

                        <library>mvn:net.java.dev.jna/jna/${jnaVersion};type:=boot;export:=false</library>
                        <library>mvn:net.java.dev.jna/jna-platform/${jnaVersion};type:=boot;export:=false</library>

                        <!-- OPENNMS: Add MINA bundles to prevent mina-sshd-core from refreshing (KARAF-5384) -->
                        <library>mvn:org.apache.mina/mina-core/${minaVersion};type:=boot;export:=false</library>

                        <!-- OPENNMS: Add our custom branding JAR -->
                        <library>mvn:org.opennms.container/org.opennms.container.branding/${project.version};type:=default;export:=true</library>
                    </libraries>
                    <javase>1.8</javase>
                </configuration>
            </plugin>
            <plugin>
                <groupId>net.nicoulaj.maven.plugins</groupId>
                <artifactId>checksum-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>prepare-package</phase>
                        <goals><goal>files</goal></goals>
                    </execution>
                </executions>
                <configuration>
                    <algorithms><algorithm>SHA-1</algorithm></algorithms>
                    <fileSets>
                        <fileSet>
                            <directory>${project.build.directory}/assembly/system</directory>
                            <includes>
                                <include>**/*.jar</include>
                                <include>**/*.pom</include>
                                <include>**/*.war</include>
                                <include>**/*.xml</include>
                            </includes>
                        </fileSet>
                    </fileSets>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <executions>
                    <execution>
                        <id>cleanup-after-integration-tests</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                        <configuration>
                            <excludeDefaultDirectories>true</excludeDefaultDirectories>
                            <filesets>
                                <fileset>
                                    <directory>${project.build.directory}/assembly</directory>
                                </fileset>
                            </filesets>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.apache.karaf.features</groupId>
            <artifactId>framework</artifactId>
            <version>${karafVersion}</version>
            <type>kar</type>
            <exclusions>
                <exclusion>
                    <groupId>javax.xml.bind</groupId>
                    <artifactId>jaxb-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!--
            This is the original version of mvn:org.opennms.karaf/opennms//xml/standard so it
            shouldn't be necessary but the karaf-maven-plugin doesn't resolve the bootFeatures
            without it. The plugin looks at the classifier and scope when it does its magic so
            something about mvn:org.opennms.karaf/opennms//xml/standard doesn't line up like
            the original one does.
        -->
        <dependency>
            <groupId>org.apache.karaf.features</groupId>
            <artifactId>standard</artifactId>
            <version>${karafVersion}</version>
            <classifier>features</classifier>
            <type>xml</type>
            <exclusions>
                <exclusion>
                    <groupId>javax.xml.bind</groupId>
                    <artifactId>jaxb-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.opennms.karaf</groupId>
            <artifactId>opennms</artifactId>
            <version>${project.version}</version>
            <classifier>standard</classifier>
            <type>xml</type>
        </dependency>
        <dependency>
            <groupId>org.opennms.karaf</groupId>
            <artifactId>opennms</artifactId>
            <version>${project.version}</version>
            <classifier>spring</classifier>
            <type>xml</type>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.opennms.karaf</groupId>
            <artifactId>opennms</artifactId>
            <version>${project.version}</version>
            <classifier>spring-legacy</classifier>
            <type>xml</type>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.opennms.karaf</groupId>
            <artifactId>opennms</artifactId>
            <version>${project.version}</version>
            <classifier>features</classifier>
            <type>xml</type>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.opennms.karaf</groupId>
            <artifactId>opennms</artifactId>
            <version>${project.version}</version>
            <classifier>minion</classifier>
            <type>xml</type>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.http.bridge</artifactId>
            <version>${felixBridgeVersion}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.opennms.container</groupId>
            <artifactId>org.opennms.container.branding</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>
        <!--
        <dependency>
            <groupId>org.apache.karaf</groupId>
            <artifactId>org.apache.karaf.main</artifactId>
            <version>${karafVersion}</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.xml.bind</groupId>
                    <artifactId>jaxb-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.karaf.jaas</groupId>
            <artifactId>org.apache.karaf.jaas.boot</artifactId>
            <version>${karafVersion}</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.xml.bind</groupId>
                    <artifactId>jaxb-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        -->
    </dependencies>

    <repositories>
        <repository>
            <snapshots><enabled>false</enabled></snapshots>
            <releases><enabled>true</enabled></releases>
            <id>central</id>
            <name>Maven Central</name>
            <url>http://maven.opennms.org/content/repositories/central/</url>
        </repository>
    </repositories>
</project>
