<?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">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.adobexp.loki</groupId>
        <artifactId>aem-loki-integrator</artifactId>
        <version>1.0.3</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>aem-loki-integrator.loki4j</artifactId>
    <packaging>jar</packaging>
    <name>AEM Loki Integrator - loki4j Fragment Bundle</name>
    <description>
        Repackages the loki-logback-appender (loki4j) as an OSGi fragment of
        org.apache.sling.commons.log. Attaching it to the Sling log host
        bundle makes the loki4j classes (and their ch.qos.logback.* references)
        visible to the Logback context without the loki4j classes ever being
        loaded by our own customer bundles.
    </description>

    <dependencies>
        <dependency>
            <groupId>com.github.loki4j</groupId>
            <artifactId>loki-logback-appender</artifactId>
        </dependency>

        <!-- Optional runtime dependencies of loki-logback-appender. Declared
             here so bnd can see them while building the fragment's
             Import-Package, but they are all imported with
             resolution:=optional. -->
        <dependency>
            <groupId>org.xerial.snappy</groupId>
            <artifactId>snappy-java</artifactId>
            <version>1.1.10.5</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-core</artifactId>
            <version>1.11.0</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
            <version>3.21.12</version>
            <optional>true</optional>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>biz.aQute.bnd</groupId>
                <artifactId>bnd-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>bnd-process</id>
                        <goals>
                            <goal>bnd-process</goal>
                        </goals>
                        <configuration>
                            <bnd><![CDATA[
Bundle-SymbolicName: ${project.artifactId}
Bundle-Name: ${project.name}
Bundle-Version: ${project.version}
Fragment-Host: org.apache.sling.commons.log
Export-Package: com.github.loki4j.logback,\
 com.github.loki4j.pkg.*,\
 com.github.loki4j.util.*
Import-Package: org.xerial.snappy;resolution:=optional,\
 io.micrometer.core.instrument.*;resolution:=optional,\
 com.google.protobuf;resolution:=optional,\
 com.github.loki4j.pkg.google.protobuf;resolution:=optional,\
 com.github.loki4j.pkg.loki.protobuf;resolution:=optional,\
 *
Embed-Dependency: loki-logback-appender;scope=compile|runtime
-includeresource: @loki-logback-appender-${loki4j.version}.jar
]]></bnd>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>
