<?xml version="1.0" encoding="UTF-8"?>
<!--
  #%L
  wcm.io
  %%
  Copyright (C) 2014 wcm.io
  %%
  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.
  #L%
  -->

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

  <!--
    This cq-global-parent version supports the following CQ versions:
    - AEM 6.0.x
    - AEM 6.1.x
    - AEM 6.2.x
    - AEM 6.3.x
  -->

  <parent>
    <groupId>io.wcm.maven</groupId>
    <artifactId>io.wcm.maven.global-parent</artifactId>
    <version>14</version>
    <relativePath />
  </parent>

  <groupId>io.wcm.maven</groupId>
  <artifactId>io.wcm.maven.aem-global-parent</artifactId>
  <version>1.2.2</version>
  <packaging>pom</packaging>

  <name>io.wcm.maven.aem-global-parent</name>
  <description>Global parent for Maven artifact hierarchy for AEM projects. Defines AEM-specific plugins and general Maven settings.</description>

  <scm>
    <connection>scm:git:https://github.com/wcm-io/wcm-io-tooling.git</connection>
    <developerConnection>scm:git:https://github.com/wcm-io/wcm-io-tooling.git</developerConnection>
    <url>https://github.com/wcm-io/wcm-io-tooling</url>
    <tag>HEAD</tag>
  </scm>

  <properties>

    <!-- Sling instance parameters -->
    <sling.url>http://localhost:4502</sling.url>
    <sling.user>admin</sling.user>
    <sling.password>admin</sling.password>

  </properties>

  <dependencies>

    <!-- OSGi versioning annotations -->
    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>osgi.annotation</artifactId>
      <version>6.0.1</version>
      <scope>provided</scope>
    </dependency>

    <!-- OSGi DS and metatype annotations -->
    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>org.osgi.service.component.annotations</artifactId>
      <version>1.3.0</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>org.osgi.service.metatype.annotations</artifactId>
      <version>1.3.0</version>
      <scope>provided</scope>
    </dependency>

    <!-- global dependency for static code analysis -->
    <dependency>
      <groupId>com.google.code.findbugs</groupId>
      <artifactId>annotations</artifactId>
      <!-- Downgrade to 3.0.0 because 3.0.1u2 creates an OSGi dependency to javax.annotation 3.0.1 not present in AEM -->
      <version>3.0.0</version>
      <scope>provided</scope>
    </dependency>

  </dependencies>
  
  <dependencyManagement>
    <dependencies>

      <!-- Felix SCR DS annotations supported as well, but not included as default dependency by default any longer -->
      <dependency>
        <groupId>org.apache.felix</groupId>
        <artifactId>org.apache.felix.scr.annotations</artifactId>
        <!-- Do not update to 1.12.0 yet, it marks all SCR annotations as deprecated -->
        <version>1.11.0</version>
      </dependency>

    </dependencies>  
  </dependencyManagement>

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>false</filtering>
        <excludes>
          <!-- those resources are processed by the i18n-maven-plugin -->
          <exclude>i18n/**</exclude>
        </excludes>
      </resource>
      <!-- copy webapp resources to SLING-INF/app-root -->
      <resource>
        <directory>src/main/webapp</directory>
        <targetPath>SLING-INF</targetPath>
        <filtering>false</filtering>
      </resource>
    </resources>
    <plugins>

      <!-- Do not generate site (only for this pom) -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>
        <inherited>false</inherited>
        <configuration>
          <skip>true</skip>
          <skipDeploy>true</skipDeploy>
        </configuration>
      </plugin>

      <!-- gitflow customization (only for this pom) -->
      <plugin>
        <groupId>external.atlassian.jgitflow</groupId>
        <artifactId>jgitflow-maven-plugin</artifactId>
        <inherited>false</inherited>
        <configuration>
          <!-- Prefix release numbers with artifactId for GIT repo with more than one released artifact -->
          <flowInitContext>
            <releaseBranchPrefix>release/${project.artifactId}-</releaseBranchPrefix>
            <hotfixBranchPrefix>hotfix/${project.artifactId}-</hotfixBranchPrefix>
            <versionTagPrefix>${project.artifactId}-</versionTagPrefix>
          </flowInitContext>
        </configuration>
      </plugin>

      <!-- Make sure Felix SCR Plugin is not included in build - maven-bundle-plugin with SCR plugin is used instead -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <executions>
          <execution>
            <id>ban-maven-scr-plugin</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <bannedPlugins>
                  <excludes>
                    <exclude>org.apache.felix:maven-scr-plugin</exclude>
                  </excludes>
                  <message>Please remove maven-scr-plugin from your POMs - Felix SCR annotations are now processed by maven-bundle-plugin with Felix SCR bnd plugin.</message>
                </bannedPlugins>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Validate JSON files -->
      <plugin>
        <groupId>org.apache.sling</groupId>
        <artifactId>maven-sling-plugin</artifactId>
        <executions>
          <execution>
            <id>validate-json</id>
            <goals>
              <goal>validate</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- Validate Slightly HTML scripts -->
      <plugin>
        <groupId>org.apache.sling</groupId>
        <artifactId>htl-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>validate-scripts</id>
            <goals>
              <goal>validate</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <sourceDirectory>src/main/webapp</sourceDirectory>
        </configuration>
      </plugin>

    </plugins>
    <pluginManagement>
      <plugins>

        <plugin>
          <groupId>org.apache.felix</groupId>
          <artifactId>maven-bundle-plugin</artifactId>
          <version>3.3.0</version>
          <extensions>true</extensions>
          <executions>
            <!-- Configure extra execution of 'manifest' in process-classes phase to make sure SCR metadata is generated before unit test runs -->
            <execution>
              <id>scr-metadata</id>
              <goals>
                <goal>manifest</goal>
              </goals>
              <configuration>
                <supportIncrementalBuild>true</supportIncrementalBuild>
              </configuration>
            </execution>
          </executions>
          <configuration>
            <exportScr>true</exportScr>
            <instructions>
              <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
              <Bundle-Description>${project.description} (Rev. ${buildNumber} at ${timestamp})</Bundle-Description>
              <!-- Enable processing of OSGI DS component annotations -->
              <_dsannotations>*</_dsannotations>
              <!-- Enable processing of OSGI metatype annotations -->
              <_metatypeannotations>*</_metatypeannotations>
              <_plugin>
                <!-- Support parsing of maven-scr-plugin annotations through the felix.scr.bnd plugin -->
                org.apache.felix.scrplugin.bnd.SCRDescriptorBndPlugin;destdir=${project.build.outputDirectory},
                <!-- Generate bundle header containing all configuration annotation classes -->
                org.apache.sling.caconfig.bndplugin.ConfigurationClassScannerPlugin,
                <!-- Generate bundle header for Sling Models classes -->
                org.apache.sling.bnd.models.ModelsScannerPlugin
              </_plugin>
            </instructions>
          </configuration>
          <dependencies>
            <dependency>
              <groupId>org.apache.felix</groupId>
              <artifactId>org.apache.felix.scr.bnd</artifactId>
              <version>1.7.2</version>
            </dependency>
            <dependency>
              <groupId>org.apache.felix</groupId>
              <artifactId>org.apache.felix.scr.generator</artifactId>
              <version>1.16.0</version>
            </dependency>
            <dependency>
              <groupId>org.apache.felix</groupId>
              <artifactId>org.apache.felix.scr.annotations</artifactId>
              <version>1.11.0</version>
            </dependency>
            <dependency>
              <groupId>org.apache.sling</groupId>
              <artifactId>org.apache.sling.caconfig.bnd-plugin</artifactId>
              <version>1.0.2</version>
            </dependency>
            <dependency>
              <groupId>org.apache.sling</groupId>
              <artifactId>org.apache.sling.bnd.models</artifactId>
              <version>1.0.0</version>
            </dependency>
          </dependencies>
        </plugin>

        <plugin>
          <groupId>org.apache.sling</groupId>
          <artifactId>maven-sling-plugin</artifactId>
          <version>2.3.0</version>
          <!-- Default configuration for deploying bundles into running CQ instance -->
          <configuration>
            <slingUrl>${sling.url}/system/console</slingUrl>
            <user>${sling.user}</user>
            <password>${sling.password}</password>
            <deployFsResourceBundlePrerequisites>
              <bundlePrerequisite>
                <bundles>
                  <bundle>
                    <groupId>org.apache.sling</groupId>
                    <artifactId>org.apache.sling.fsresource</artifactId>
                    <version>2.1.4</version>
                  </bundle>
                </bundles>
                <preconditions>
                  <bundle>
                    <groupId>org.apache.sling</groupId>
                    <artifactId>org.apache.sling.resourceresolver</artifactId>
                    <version>1.5.18</version>
                  </bundle>
                </preconditions>
              </bundlePrerequisite>
              <bundlePrerequisite>
                <bundles>
                  <bundle>
                    <groupId>org.apache.sling</groupId>
                    <artifactId>org.apache.sling.fsresource</artifactId>
                    <version>1.4.4</version>
                  </bundle>
                </bundles>
              </bundlePrerequisite>
            </deployFsResourceBundlePrerequisites>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.sling</groupId>
          <artifactId>htl-maven-plugin</artifactId>
          <version>1.0.6</version>
        </plugin>
      
        <plugin>
          <groupId>com.day.jcr.vault</groupId>
          <artifactId>content-package-maven-plugin</artifactId>
          <version>0.5.1</version>
          <configuration>
            <failOnError>true</failOnError>
            <failOnMissingEmbed>true</failOnMissingEmbed>
            <targetURL>${sling.url}/crx/packmgr/service.jsp</targetURL>
            <serviceURL>${sling.url}/crx/packmgr/service/.json</serviceURL>
            <userId>${sling.user}</userId>
            <password>${sling.password}</password>
            <builtContentDirectory>jcr_root</builtContentDirectory>
            <verbose>true</verbose>
          </configuration>
        </plugin>

        <plugin>
          <groupId>io.wcm.maven.plugins</groupId>
          <artifactId>wcmio-content-package-maven-plugin</artifactId>
          <version>1.5.0</version>
          <configuration>
            <serviceURL>${sling.url}/crx/packmgr/service</serviceURL>
            <userId>${sling.user}</userId>
            <password>${sling.password}</password>
            <excludeFiles>
              <exclude>^META-INF/.*</exclude>
              <!-- exclude renditions that are automatically generated -->
              <exclude>.*/cq5dam\.thumbnail\..*</exclude>
            </excludeFiles>
            <excludeProperties>
              <exclude>jcr\:created</exclude>
              <exclude>jcr\:createdBy</exclude>
              <exclude>jcr\:lastModified</exclude>
              <exclude>jcr\:lastModifiedBy</exclude>
              <exclude>jcr\:uuid</exclude>
              <exclude>cq\:lastModified</exclude>
              <exclude>cq\:lastModifiedBy</exclude>
              <exclude>cq\:lastReplicated</exclude>
              <exclude>cq\:lastReplicatedBy</exclude>
              <exclude>cq\:lastReplicationAction</exclude>
            </excludeProperties>
            <failOnMissingEmbed>true</failOnMissingEmbed>
          </configuration>
        </plugin>

        <plugin>
          <groupId>io.wcm.maven.plugins</groupId>
          <artifactId>cq-maven-plugin</artifactId>
          <version>1.0.4</version>
          <configuration>
            <slingPluginVersion>2.1.0</slingPluginVersion>
            <slingConsoleUrl>${sling.url}/system/console</slingConsoleUrl>
            <slingConsoleUser>${sling.user}</slingConsoleUser>
            <slingConsolePassword>${sling.password}</slingConsolePassword>
          </configuration>
        </plugin>

        <plugin>
          <groupId>io.wcm.maven.plugins</groupId>
          <artifactId>i18n-maven-plugin</artifactId>
          <version>1.1.0</version>
        </plugin>

        <plugin>
          <groupId>io.wcm.maven.plugins</groupId>
          <artifactId>nodejs-maven-plugin</artifactId>
          <version>2.0.4</version>
        </plugin>

        <plugin>
          <groupId>io.wcm.devops.conga</groupId>
          <artifactId>conga-maven-plugin</artifactId>
          <version>1.3.4</version>
          <extensions>true</extensions>
          <dependencies>
            <dependency>
              <groupId>io.wcm.devops.conga.plugins</groupId>
              <artifactId>io.wcm.devops.conga.plugins.sling</artifactId>            
              <version>1.2.2</version>
            </dependency>
            <dependency>
              <groupId>io.wcm.devops.conga.plugins</groupId>
              <artifactId>io.wcm.devops.conga.plugins.aem</artifactId>            
              <version>1.4.2</version>
            </dependency>
          </dependencies>
        </plugin>
        <plugin>
          <groupId>io.wcm.devops.conga.plugins</groupId>
          <artifactId>conga-aem-maven-plugin</artifactId>
          <version>1.4.2</version>
          <configuration>
            <serviceURL>${sling.url}/crx/packmgr/service</serviceURL>
            <userId>${sling.user}</userId>
            <password>${sling.password}</password>
          </configuration>
        </plugin>

      </plugins>

    </pluginManagement>

  </build>

  <profiles>

    <!-- profile used for building releases and deployment to sonatype/maven central -->
    <profile>
      <id>release</id>
      <activation>
        <property>
          <name>performRelease</name>
          <value>true</value>
        </property>
      </activation>
      <build>
        <plugins>
          <!-- sign the build -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>1.6</version>
            <inherited>false</inherited>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <!-- configure staging process at sonatype.-->
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <version>1.6.7</version>
            <inherited>false</inherited>
            <extensions>true</extensions>
            <configuration>
              <serverId>ossrh</serverId>
              <nexusUrl>https://oss.sonatype.org/</nexusUrl>
              <!-- Deployed artifacts should go to staging to be reviewed before publish -->
              <autoReleaseAfterClose>false</autoReleaseAfterClose>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. -->
    <profile>
      <id>only-eclipse</id>
      <activation>
        <property>
          <name>m2e.version</name>
        </property>
      </activation>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.eclipse.m2e</groupId>
              <artifactId>lifecycle-mapping</artifactId>
              <version>1.0.0</version>
              <configuration>
                <lifecycleMappingMetadata>
                  <pluginExecutions>
                    <pluginExecution>
                      <pluginExecutionFilter>
                        <groupId>org.apache.sling</groupId>
                        <artifactId>maven-sling-plugin</artifactId>
                        <versionRange>[2.1.0,)</versionRange>
                        <goals>
                          <goal>validate</goal>
                        </goals>
                      </pluginExecutionFilter>
                      <action>
                        <ignore />
                      </action>
                    </pluginExecution>
                  </pluginExecutions>
                </lifecycleMappingMetadata>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>

  </profiles>

</project>
