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

    <parent>
        <groupId>com.composum.nodes</groupId>
        <artifactId>composum-nodes</artifactId>
        <version>3.2.2</version>
    </parent>

    <artifactId>composum-nodes-config</artifactId>
    <packaging>bundle</packaging>

    <name>Composum Nodes Configuration</name>
    <description>the set of necessary OSGi configuration fragments</description>

    <properties>
        <bundle.name>com.composum.nodes.config</bundle.name>
    </properties>

    <build>
        <plugins>

            <plugin>
                <groupId>pl.project13.maven</groupId>
                <artifactId>git-commit-id-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-Category>${bundle.category}</Bundle-Category>
                        <Bundle-SymbolicName>${bundle.name}</Bundle-SymbolicName>
                        <Include-Resource>
                            {maven-resources}
                        </Include-Resource>
                        <Sling-Initial-Content>
                            root/libs/composum/nodes/install/org.apache.sling.jcr.base.internal.LoginAdminWhitelist.fragment-composum_core_v2.config;path:=/libs/composum/nodes/install;overwrite:=true,
                            root/libs/composum/nodes/install/com.composum.sling.nodes.servlet.ServletResourceType~cpm-clientlibs.config;path:=/libs/composum/nodes/install;overwrite:=true,
                            root/libs/composum/nodes/install/com.composum.sling.nodes.servlet.ServletResourceType~cpm-servicegraph.config;path:=/libs/composum/nodes/install;overwrite:=true,
                            root/libs/composum/nodes/install/com.composum.sling.nodes.servlet.ServletResourceType~runtime-threaddump.config;path:=/libs/composum/nodes/install;overwrite:=true,
                            root/libs/composum/nodes/install/com.composum.sling.nodes.servlet.ServletResourceType~sling-adapters.config;path:=/libs/composum/nodes/install;overwrite:=true,
                            root/libs/composum/nodes/install/com.composum.sling.nodes.servlet.ServletResourceType~sling-jobs.config;path:=/libs/composum/nodes/install;overwrite:=true,
                            root/libs/composum/nodes/install/com.composum.sling.nodes.servlet.ServletResourceType~sling-requests.config;path:=/libs/composum/nodes/install;overwrite:=true,
                            root/libs/composum/nodes/install/com.composum.sling.nodes.servlet.ServletResourceType~sling-resolver.config;path:=/libs/composum/nodes/install;overwrite:=true,
                            root/libs/composum/nodes/install/com.composum.sling.nodes.servlet.ServletResourceType~sling-servlets.config;path:=/libs/composum/nodes/install;overwrite:=true
                        </Sling-Initial-Content>
                    </instructions>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.sling</groupId>
                <artifactId>slingfeature-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <jarStartOrder>20</jarStartOrder>
                </configuration>
                <executions>
                    <execution>
                        <id>features</id>
                        <phase>package</phase>
                        <goals>
                            <goal>include-artifact</goal>
                            <goal>attach-features</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>
    <profiles>

        <profile>
            <!-- install bundles via Sling installer (REST API: /system/console/install) -->
            <id>installBundle</id>
            <activation>
                <property>
                    <name>install.bundle</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.sling</groupId>
                        <artifactId>sling-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>install-bundle</id>
                                <phase>install</phase>
                                <goals>
                                    <goal>install</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <!-- install bundles via upload (WebDAV) to 'install' path (/libs/composum/nodes/install) -->
            <id>uploadBundle</id>
            <activation>
                <property>
                    <name>upload.bundle</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.sling</groupId>
                        <artifactId>sling-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>upload-bundle</id>
                                <phase>install</phase>
                                <goals>
                                    <goal>install</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

    </profiles>
</project>
