<?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-usermgr</artifactId>
    <packaging>bundle</packaging>

    <name>Composum Nodes User Managmenent</name>
    <description>a console module to manage users via JCR API</description>

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

    <build>
        <plugins>

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

            <plugin>
                <!-- Minify the JS-Resources - needs the build-helper-maven-plugin -->
                <groupId>com.samaxes.maven</groupId>
                <artifactId>minify-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>minify-javascripts</id>
                        <goals>
                            <goal>minify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <!-- Needed for the minify-maven-plugin. -->
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-minified-resource</id>
                        <goals>
                            <goal>add-resource</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.sling</groupId>
                <artifactId>sling-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>generate-adapter-metadata</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>generate-adapter-metadata</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- FIXME why do I need to exclude junit and why is org.apache.sling.api.resource neccessary? -->
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <exportScr>true</exportScr>
                    <instructions>
                        <_dsannotations>*</_dsannotations>
                        <_metatypeannotations>*</_metatypeannotations>
                        <Bundle-Category>${bundle.category}</Bundle-Category>
                        <Bundle-SymbolicName>${bundle.name}</Bundle-SymbolicName>
                        <Include-Resource>
                            {maven-resources}
                        </Include-Resource>
                        <Import-Package>
                            org.apache.sling.api.resource.*;version="[2.10,3)",
                            org.apache.sling.serviceusermapping.*;version="[1.3,2)",
                            *
                        </Import-Package>
                        <Export-Package>
                            !com.composum.sling.core.usermanagement.*.impl.*,
                            com.composum.sling.core.usermanagement.*
                        </Export-Package>
                        <Sling-Initial-Content>
                            root/libs/composum/nodes/usermgnt;path:=/libs/composum/nodes/usermgnt;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>

    <dependencies>

        <!-- OSGi, Felix -->
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.cmpn</artifactId>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.annotation</artifactId>
        </dependency>

        <!-- Composum -->
        <dependency>
            <groupId>com.composum.nodes</groupId>
            <artifactId>composum-nodes-console</artifactId>
        </dependency>
        <dependency>
            <groupId>com.composum.nodes</groupId>
            <artifactId>composum-nodes-commons</artifactId>
        </dependency>
        <dependency>
            <groupId>com.composum.nodes</groupId>
            <artifactId>composum-nodes-jslibs</artifactId>
        </dependency>

        <!-- Apache Sling -->
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.scripting.jsp</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.scripting.jsp.taglib</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.jcr.api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.xss</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.serviceusermapper</artifactId>
        </dependency>

        <!-- JCR API, Jackrabbit -->
        <dependency>
            <groupId>javax.jcr</groupId>
            <artifactId>jcr</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>jackrabbit-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>jackrabbit-jcr-commons</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>jackrabbit-core</artifactId>
        </dependency>

        <!-- JSON -->
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
        </dependency>

        <!-- Apache Commons -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
        </dependency>


        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>

    </dependencies>
    <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>
