<?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>

    <groupId>be.orbinson.sling</groupId>
    <artifactId>sling-observability-weavinghooks</artifactId>
    <version>1.0.0</version>

    <name>Sling Observability Weaving Hooks</name>
    <description>Library of weaving hooks to ease the process of observability in out-of-the-box code</description>

    <url>https://github.com/orbinson/sling-observability-weavinghooks</url>

    <developers>
        <developer>
            <name>Barry d'Hoine</name>
            <email>barrydhoine@gmail.com</email>
            <id>bdhoine</id>
        </developer>
        <developer>
            <name>Roy Teeuwen</name>
            <email>roy@orbinson.be</email>
            <id>royteeuwen</id>
        </developer>
    </developers>

    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <scm>
        <connection>scm:git:https://github.com/orbinson/sling-observability-weavinghooks.git</connection>
        <developerConnection>scm:git:https://github.com/orbinson/sling-observability-weavinghooks.git</developerConnection>
        <url>https://github.com/orbinson/sling-observability-weavinghooks.git</url>
    </scm>

    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/orbinson/sling-observability-weavinghooks/issues</url>
    </issueManagement>

    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <name>Central Repository OSSRH - Snapshots</name>
            <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>ossrh</id>
            <name>Central Repository OSSRH</name>
            <url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <properties>
        <sling.host>localhost</sling.host>
        <sling.port>8080</sling.port>
        <sling.user>admin</sling.user>
        <sling.password>admin</sling.password>

        <sonar.organization>orbinson</sonar.organization>
        <sonar.projectKey>${sonar.organization}_${project.artifactId}</sonar.projectKey>
        <sonar.host.url>https://sonarcloud.io</sonar.host.url>
        <sonar.coverage.jacoco.xmlReportPaths>**/target/site/jacoco</sonar.coverage.jacoco.xmlReportPaths>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>3.0.1</version>
                <configuration>
                    <scmCommentPrefix>[maven-scm] :</scmCommentPrefix>
                    <preparationGoals>clean install</preparationGoals>
                    <goals>install</goals>
                    <releaseProfiles>release</releaseProfiles>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.3.0</version>
                <inherited>true</inherited>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.12.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>biz.aQute.bnd</groupId>
                <artifactId>bnd-maven-plugin</artifactId>
                <version>6.4.0</version>
                <executions>
                    <execution>
                        <id>bnd-process</id>
                        <goals>
                            <goal>bnd-process</goal>
                        </goals>
                        <configuration>
                            <bnd><![CDATA[
                -includeresource:asm-9.7.jar;lib:=true,asm-util-9.7.jar;lib:=true,asm-tree-9.7.jar;lib:=true,asm-analysis-9.7.jar;lib:=true
                                ]]></bnd>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.3.0</version>
                <configuration>
                    <archive>
                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.sonatype.plugins</groupId>
                    <artifactId>nexus-staging-maven-plugin</artifactId>
                    <version>1.6.13</version>
                    <extensions>true</extensions>
                    <configuration>
                        <serverId>ossrh</serverId>
                        <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
                        <autoReleaseAfterClose>true</autoReleaseAfterClose>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>1.6</version>
                    <executions>
                        <execution>
                            <phase>deploy</phase>
                            <goals>
                                <goal>sign</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <!-- prevent gpg from using pinentry programs -->
                        <gpgArguments>
                            <arg>--pinentry-mode</arg>
                            <arg>loopback</arg>
                        </gpgArguments>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>3.4.1</version>
                    <executions>
                        <execution>
                            <id>attach-javadocs</id>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>3.2.1</version>
                    <executions>
                        <execution>
                            <id>attach-sources</id>
                            <goals>
                                <goal>jar-no-fork</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>


    <profiles>
        <profile>
            <id>auto-deploy</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.sling</groupId>
                        <artifactId>sling-maven-plugin</artifactId>
                        <version>2.4.0</version>
                        <configuration>
                            <slingUrl>
                                http://${sling.host}:${sling.port}/apps/sling-observability-weaving-hooks/install/1
                            </slingUrl>
                            <deploymentMethod>SlingPostServlet</deploymentMethod>
                            <user>${sling.user}</user>
                            <password>${sling.password}</password>
                        </configuration>
                        <executions>
                            <execution>
                                <id>install-bundle</id>
                                <goals>
                                    <goal>install</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>it</id>
            <build>
                <plugins>
                    <!-- Test Jar that will be deployed to test feature. Feature model only use a new version if the project succesfully compiled (so -DskipTests might be required) -->
                    <plugin>
                        <groupId>biz.aQute.bnd</groupId>
                        <artifactId>bnd-maven-plugin</artifactId>
                        <version>6.4.0</version>
                        <extensions>true</extensions>
                        <executions>
                            <execution>
                                <id>test-jar</id>
                                <goals>
                                    <goal>test-jar</goal>
                                </goals>
                                <configuration>
                                    <bnd><![CDATA[
                Import-Package: *;resolution:=optional
]]></bnd>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>3.2.0</version>
                        <executions>
                            <execution>
                                <id>reserve-network-port</id>
                                <goals>
                                    <goal>reserve-network-port</goal>
                                </goals>
                                <phase>process-resources</phase>
                                <configuration>
                                    <portNames>
                                        <portName>http.port</portName>
                                    </portNames>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- We have to install the main and test jar to local repo so that the feature plugin can use it in the feature model -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-install-plugin</artifactId>
                        <version>3.1.2</version>
                        <executions>
                            <execution>
                                <id>install-to-local-repo</id>
                                <goals>
                                    <goal>install</goal>
                                </goals>
                                <phase>pre-integration-test</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.sling</groupId>
                        <artifactId>slingfeature-maven-plugin</artifactId>
                        <version>1.8.4</version>
                        <extensions>true</extensions>
                        <configuration>
                            <attachTestFeatures>true</attachTestFeatures>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>attach-features</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.sling</groupId>
                        <artifactId>feature-launcher-maven-plugin</artifactId>
                        <version>0.1.6</version>
                        <configuration>
                            <launches>
                                <launch>
                                    <id>model</id>
                                    <skip>${skipTests}</skip>
                                    <feature>
                                        <groupId>${project.groupId}</groupId>
                                        <artifactId>${project.artifactId}</artifactId>
                                        <version>${project.version}</version>
                                        <classifier>test</classifier>
                                        <type>slingosgifeature</type>
                                    </feature>

                                    <launcherArguments>
                                        <frameworkProperties>
                                            <org.osgi.service.http.port>${http.port}</org.osgi.service.http.port>
                                        </frameworkProperties>
                                        <!-- Uncomment to enable debugging of IT tests -->
                                        <!--                                        <vmOptions>-->
                                        <!--                                            <value>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5000</value>-->
                                        <!--                                        </vmOptions>-->
                                    </launcherArguments>
                                    <startTimeoutSeconds>180</startTimeoutSeconds>
                                </launch>
                            </launches>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>start</goal>
                                    <goal>stop</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>3.3.1</version>
                        <configuration>
                            <systemPropertyVariables>
                                <HTTP_PORT>${http.port}</HTTP_PORT>
                                <build.log.file>${project.build.directory}/../build.log</build.log.file>
                            </systemPropertyVariables>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <dependencies>
        <!-- OSGi -->
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.core</artifactId>
            <version>7.0.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.cmpn</artifactId>
            <version>7.0.0</version>
            <scope>provided</scope>
        </dependency>

        <!-- Bytecode transformation -->
        <dependency>
            <groupId>org.ow2.asm</groupId>
            <artifactId>asm</artifactId>
            <version>9.7</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.ow2.asm</groupId>
            <artifactId>asm-util</artifactId>
            <version>9.7</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.ow2.asm</groupId>
            <artifactId>asm-tree</artifactId>
            <version>9.7</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.ow2.asm</groupId>
            <artifactId>asm-analysis</artifactId>
            <version>9.7</version>
            <scope>provided</scope>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.36</version>
            <scope>provided</scope>
        </dependency>

        <!-- Testing -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.10.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.14</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>test</scope>
        </dependency>


    </dependencies>
</project>
