<?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/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.ops4j.pax.logging</groupId>
        <artifactId>pax-logging-it-karaf</artifactId>
        <version>2.0.13</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <groupId>org.ops4j.pax.logging.karaf</groupId>
    <artifactId>karaf-distribution</artifactId>
    <packaging>pom</packaging>

    <name>OPS4J Pax Logging - Karaf Distribution</name>

    <build>
        <plugins>
            <plugin>
                <!--
                    karaf-maven-plugin defines 3 "stages" related 1:1 with Maven scopes:
                     - <scope>compile</scope>  : stage = Startup
                     - <scope>runtime</scope>  : stage = Boot
                     - <scope>provided</scope> : stage = Installed
                    These stages are "implemented" using different Karaf files:
                     - Startup stage: etc/startup.properties - startup features, startup profiles, startup bundles
                       are used to prepare list of bundles to include in etc/startup.properties
                     - Boot stage: etc/org.apache.karaf.features.cfg - manages features available in featuresBoot
                       property and repositories in featuresRepositories property
                     - Install stage: just installs the artifacts in ${karaf.home}/${karaf.default.repository}
                    And finally there are 5 kinds of artifacts that may be declared to belong to one of 3 stages:
                     - <stage>Bundles
                     - <stage>Features
                     - <stage>Profiles
                     - <stage>PropertiesFile
                     - <stage>Repositories
                -->
                <groupId>org.apache.karaf.tooling</groupId>
                <artifactId>karaf-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>process-resources</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>assembly</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>package</id>
                        <phase>package</phase>
                        <goals>
                            <goal>archive</goal>
                        </goals>
                        <configuration>
                            <archiveTarGz>false</archiveTarGz>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <!--
                        explicit <framework> configuration is needed if there's no compile dependency on
                        mvn:org.apache.karaf.features/framework/VERSION/kar or
                        mvn:org.apache.karaf.features/static/VERSION/kar
                        "custom" means the kar won't be detected - we have to provide it manually - and we have to
                        to use our own pax-logging version
                    -->
                    <framework>custom</framework>
                    <!--
                        installAllFeaturesByDefault should be false when using custom kar. Otherwise all
                        features from feature repositories found in the kar would be installed by default
                    -->
                    <installAllFeaturesByDefault>false</installAllFeaturesByDefault>
                    <startupFeatures>
                        <!--
                            "framework" feature is implicitly added if not specified
                            it's fundamental feature that starts feature service, configadmin, fileinstall
                            pax-logging and pax-url-aether
                            here. our "framework" is different - it provides our current pax-logging
                        -->
                        <feature>framework</feature>
                    </startupFeatures>
                    <installedBundles>
                        <bundle>mvn:org.ops4j.pax.logging/pax-logging-log4j2-extra/${project.version}</bundle>
                        <bundle>mvn:com.fasterxml.jackson.core/jackson-annotations/${version.com.fasterxml.jackson}</bundle>
                        <bundle>mvn:com.fasterxml.jackson.core/jackson-core/${version.com.fasterxml.jackson}</bundle>
                        <bundle>mvn:com.fasterxml.jackson.core/jackson-databind/${version.com.fasterxml.jackson}</bundle>
                    </installedBundles>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>

        <!-- pax-logging own artifacts -->

        <!--
            dependencies with "kar" type will be added as startup (scope=compile), boot (scope=runtime) or
            installed (scope=provided) kars in karaf-maven-plugin
            kars are simply unzipped to working directory (target/assembly) and features XMLs are being
            searched for and used as additional feature repositories (with stage equal to the stage of given kar)
        -->
        <dependency>
            <groupId>org.ops4j.pax.logging.karaf</groupId>
            <artifactId>karaf-base</artifactId>
            <type>kar</type>
            <scope>compile</scope>
        </dependency>

        <!--
            dependencies with "features" classifier will be used as startup (scope=compile), boot (scope=runtime) or
            installed (scope=provided) repositories in karaf-maven-plugin
            there's no need to explicitly add feature repositories that are found in kar
        -->

        <!-- OSGi -->

        <!--
            dependencies with "bundle" or "jar" type will be used as startup (scope=compile), boot (scope=runtime) or
            installed (scope=provided) bundles in karaf-maven-plugin
            Apache Karaf takes the fundamental bundles from org.apache.karaf.features:base:jar
            Here we will specify these bundles at distro level
            (distro = maven artifact with karaf-maven-plugin:assembly goal)
            Only "provided" scope doesn't configure karaf-maven-plugin to generate special feature file in etc/
            as we only want these bundles to be copied to system/ directory
        -->
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.framework</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Logging -->

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <scope>provided</scope>
        </dependency>

    </dependencies>

</project>
