<?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright 2020 Code Distillery GmbH

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

    <groupId>net.distilledcode.aem</groupId>
    <artifactId>aem-touch-ui-support-parent</artifactId>
    <version>0.1.30</version>
    <packaging>pom</packaging>

    <name>AEM Touch UI Support :: Parent</name>
    <description>
        Parent pom for the AEM Touch UI Support project, containing mainly plugin configurations.
    </description>

    <url>https://github.com/code-distillery/aem-touch-ui-support</url>

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

    <properties>
        <!-- properties with default values; can be overwritten from the commandline -->
        <server.user>admin</server.user>
        <server.password>admin</server.password>
        <server.port>4502</server.port>
        <server.url>http://localhost:${server.port}</server.url>
        <server.install.path>/apps/distilledcode/aem-touch-ui-support/install</server.install.path>

        <!-- set correct source and report encoding -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <scm>
        <connection>scm:git:https://github.com/code-distillery/aem-touch-ui-support.git</connection>
        <developerConnection>scm:git:https://github.com/code-distillery/aem-touch-ui-support.git</developerConnection>
        <url>https://github.com/code-distillery/aem-touch-ui-support</url>
        <tag>aem-touch-ui-support-0.1.30</tag>
    </scm>

    <inceptionYear>2020</inceptionYear>

    <organization>
        <name>Code Distillery</name>
        <url>http://code-distillery.net</url>
    </organization>

    <developers>
        <developer>
            <id>jsedding</id>
            <name>Julian Sedding</name>
            <email>julian.sedding@code-distillery.net</email>
        </developer>
    </developers>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.0.0-M3</version>
                <executions>
                    <execution>
                        <id>enforce-maven</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireMavenVersion>
                                    <version>3.6</version>
                                </requireMavenVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Attach sources for all builds -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.2.1</version>
                <inherited>true</inherited>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.rat</groupId>
                <artifactId>apache-rat-plugin</artifactId>
                <version>0.13</version>
                <configuration>
                    <excludes combine.children="append">
                        <!-- Used by maven-remote-resources-plugin -->
                        <exclude>src/main/appended-resources/META-INF/*</exclude>
                        <!-- Generated by maven-remote-resources-plugin -->
                        <exclude>velocity.log</exclude>
                        <!-- Don't check anything in target -->
                        <exclude>target/*</exclude>
                        <!-- Files in markdown format -->
                        <exclude>**/*.md</exclude>
                        <!-- Ignore files generated by IDE plugins e.g. maven-eclipse-plugin -->
                        <exclude>maven-eclipse.xml</exclude>
                        <!-- Ignore "hidden" files and folders -->
                        <exclude>.*</exclude>
                        <exclude>.*/**</exclude>
                        <!-- Exclude all JSON files -->
                        <exclude>**/*.json</exclude>
                        <!-- Generated for release source archives -->
                        <exclude>DEPENDENCIES</exclude>
                        <!-- .rej files from svn/patch -->
                        <exclude>**/*.rej</exclude>
                        <!-- Exclude Java crash log files -->
                        <exclude>hs_err_*.log</exclude>
                        <!-- Lucene index details (Oak 1.6) -->
                        <exclude>**/repository/index/*/index-details.txt</exclude>
                        <!-- bnd -->
                        <exclude>bnd.bnd</exclude>
                        
                        <exclude>**/.vltignore</exclude>
                    </excludes>
                    <consoleOutput>true</consoleOutput>
                </configuration>
                <executions>
                    <execution>
                        <id>rat-check</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>3.0.0-M1</version>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.release</groupId>
                        <artifactId>maven-release-oddeven-policy</artifactId>
                        <version>3.0.0-M1</version>
                    </dependency>
                    <!-- workaround for https://issues.apache.org/jira/browse/MRELEASE-1040,
                         dependency necessary for maven-release-oddeven-policy  -->
                    <dependency>
                        <groupId>org.eclipse.aether</groupId>
                        <artifactId>aether-util</artifactId>
                        <version>1.0.0.v20140518</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <projectVersionPolicyId>OddEvenVersionPolicy</projectVersionPolicyId>
                    <tagNameFormat>aem-touch-ui-support-@{project.version}</tagNameFormat>
                    <mavenExecutorId>forked-path</mavenExecutorId>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                    <localCheckout>true</localCheckout>
                    <releaseProfiles>release</releaseProfiles>
                </configuration>
            </plugin>

        </plugins>
        <pluginManagement>
            <plugins>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.1</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>maven-bundle-plugin</artifactId>
                    <version>4.2.1</version>
                    <extensions>true</extensions>
                    <executions>
                        <execution>
                            <id>semantic-versioning</id>
                            <goals>
                                <goal>baseline</goal>
                            </goals>
                            <configuration>
                                <failOnError>true</failOnError>
                                <failOnWarning>true</failOnWarning>
                            </configuration>
                        </execution>
                    </executions>
                    <configuration>
                        <remoteOBR>NONE</remoteOBR>
                        <instructions>
                            <Bundle-Category>Code Distillery</Bundle-Category>
                            <_plugin.models>org.apache.sling.bnd.models.ModelsScannerPlugin</_plugin.models>
                        </instructions>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>org.apache.sling</groupId>
                            <artifactId>org.apache.sling.bnd.models</artifactId>
                            <version>1.0.0</version>
                        </dependency>
                    </dependencies>
                </plugin>

                <!--
                    The sling-maven-plugin provides
                    * a convenient way to install an OSGi bundle (see installBundle profile)
                -->
                <plugin>
                    <groupId>org.apache.sling</groupId>
                    <artifactId>sling-maven-plugin</artifactId>
                    <version>2.4.2</version>
                </plugin>

                <!--
                    The content-package-maven-plugin provides
                    * the packaging type content-package,
                    * convenient configuration to embed bundles and sub-packages
                    * automatically install the content-package (see installPackage profile)
                -->
                <plugin>
                    <groupId>com.day.jcr.vault</groupId>
                    <artifactId>content-package-maven-plugin</artifactId>
                    <version>0.0.24</version>
                    <extensions>true</extensions>
                    <configuration>
                        <failOnError>true</failOnError>
                        <failOnMissingEmbed>true</failOnMissingEmbed>
                        <version>${project.version}</version>
                        <group>net.distilledcode.aem</group>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>versions-maven-plugin</artifactId>
                    <version>2.8.1</version>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>3.1.0</version>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>3.0.0-M1</version>
                </plugin>

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

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.2.0</version>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.0.0-M5</version>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>3.0.0-M1</version>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>3.9.1</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>


    <!--
        The installBundle and installPackage profiles are both optional and cause
        the respective artifacts to be deployed to a running AEM instance.

        Both profiles are configured in the pluginManagement section. The plugins
        need to be included in the inheriting pom's project.build.plugins section
        in order to become active. The profiles only change the default
        configuration and thus allow keeping the poms DRY.
    -->
    <profiles>

        <!--
           Installs the OSGi bundle into the repository when the build is successful.

           Note: Install the content-package first to make sure the path
           ${server.install.path} is present in the repository. Otherwise the installation
           may fail.
       -->
        <profile>
            <id>installBundle</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.apache.sling</groupId>
                            <artifactId>sling-maven-plugin</artifactId>
                            <executions>
                                <execution>
                                    <id>install-bundle</id>
                                    <phase>package</phase>
                                    <goals>
                                        <goal>install</goal>
                                    </goals>
                                </execution>
                            </executions>
                            <configuration>
                                <slingUrl>${server.url}${server.install.path}</slingUrl>
                                <user>${server.user}</user>
                                <password>${server.password}</password>
                                <usePut>true</usePut>
                            </configuration>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>

        <!--
            Installs the content-package into the repository when the build is successful.
        -->
        <profile>
            <id>installPackage</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>com.day.jcr.vault</groupId>
                            <artifactId>content-package-maven-plugin</artifactId>
                            <executions>
                                <execution>
                                    <id>install-package</id>
                                    <phase>package</phase>
                                    <goals>
                                        <goal>install</goal>
                                    </goals>
                                    <configuration>
                                        <verbose>true</verbose>
                                        <userId>${server.user}</userId>
                                        <password>${server.password}</password>
                                        <targetURL>${server.url}/crx/packmgr/service.jsp</targetURL>
                                    </configuration>
                                </execution>
                            </executions>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>

        <profile>
            <id>release</id>
            <activation>
                <property>
                    <name>performRelease</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <dependencyManagement>
        <dependencies>

            <dependency>
                <groupId>net.distilledcode.aem</groupId>
                <artifactId>aem-touch-ui-support-bundle</artifactId>
                <version>${project.version}</version>
                <scope>provided</scope>
            </dependency>

            <dependency>
                <groupId>org.apache.sling</groupId>
                <artifactId>org.apache.sling.api</artifactId>
                <version>2.16.4</version>
                <scope>provided</scope>
            </dependency>

            <dependency>
                <groupId>org.apache.sling</groupId>
                <artifactId>org.apache.sling.scripting.jsp.taglib</artifactId>
                <version>2.4.0</version>
                <scope>provided</scope>
            </dependency>

            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>jstl</artifactId>
                <version>1.2</version>
                <scope>provided</scope>
            </dependency>

            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>servlet-api</artifactId>
                <version>2.5</version>
                <scope>provided</scope>
            </dependency>

            <dependency>
                <groupId>javax.jcr</groupId>
                <artifactId>jcr</artifactId>
                <version>2.0</version>
                <scope>provided</scope>
            </dependency>

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

            <dependency>
                <groupId>org.jetbrains</groupId>
                <artifactId>annotations</artifactId>
                <version>18.0.0</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <!-- Adobe's public repository -->
    <pluginRepositories>
        <pluginRepository>
            <id>adobe-repository</id>
            <url>http://repo.adobe.com/nexus/content/groups/public</url>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>never</updatePolicy>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

    <distributionManagement>
        <snapshotRepository>
            <id>sonatype-nexus-snapshots</id>
            <name>Sonatype Nexus Snapshots</name>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
        </snapshotRepository>
        <repository>
            <id>sonatype-nexus-staging</id>
            <name>Nexus Release Repository</name>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

</project>
