<?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 aem-global-parent POM supports the following AEM versions: AEM 6.0 and above.
  -->

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

  <groupId>io.wcm.maven</groupId>
  <artifactId>io.wcm.maven.aem-global-parent</artifactId>
  <version>1.2.26</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>

    <!-- versions -->
    <sling.maven-sling-plugin.version>2.3.6</sling.maven-sling-plugin.version>

  </properties>

  <dependencies>

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

    <!-- OSGi DS and metatype annotations -->
    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>org.osgi.service.component.annotations</artifactId>
      <version>1.4.0</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>org.osgi.service.metatype.annotations</artifactId>
      <version>1.4.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>

      <!-- Keep dependency for backward compatibility (earlier osgi-mock version declared it as transitive dependency with an outdated version) -->
      <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>
      <!-- Keep dependency for backward compatibility (it is recommended to use the null-check annotations from findbugs namespace instead) -->
      <dependency>
        <groupId>com.google.code.findbugs</groupId>
        <artifactId>jsr305</artifactId>
        <!-- Downgrade to 3.0.0 because 3.0.2 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>

  <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>
          <includes>
            <include>**/*.html</include>
          </includes>
          <failOnWarnings>true</failOnWarnings>
        </configuration>
      </plugin>

    </plugins>
    <pluginManagement>
      <plugins>

        <plugin>
          <groupId>org.apache.felix</groupId>
          <artifactId>maven-bundle-plugin</artifactId>
          <version>3.5.1</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.9.0</version>
            </dependency>
            <dependency>
              <groupId>org.apache.felix</groupId>
              <artifactId>org.apache.felix.scr.generator</artifactId>
              <version>1.18.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>${sling.maven-sling-plugin.version}</version>
          <!-- Default configuration for deploying bundles into running AEM 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.14</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.8</version>
                  </bundle>
                </bundles>
              </bundlePrerequisite>
            </deployFsResourceBundlePrerequisites>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.sling</groupId>
          <artifactId>htl-maven-plugin</artifactId>
          <version>1.1.8-1.4.0</version>
        </plugin>

        <plugin>
          <groupId>com.adobe.granite.maven</groupId>
          <artifactId>xgettext-maven-plugin</artifactId>
          <version>1.4</version>
        </plugin>

        <plugin>
          <groupId>org.apache.jackrabbit</groupId>
          <artifactId>filevault-package-maven-plugin</artifactId>
          <version>1.0.1</version>
          <configuration>
            <filterSource>META-INF/vault/filter.xml</filterSource>
            <thumbnailImage>META-INF/vault/definition/thumbnail.png</thumbnailImage>
            <failOnDependencyErrors>true</failOnDependencyErrors>
            <failOnEmptyFilter>true</failOnEmptyFilter>
            <failOnMissingEmbed>true</failOnMissingEmbed>
          </configuration>
        </plugin>

        <plugin>
          <groupId>com.day.jcr.vault</groupId>
          <artifactId>content-package-maven-plugin</artifactId>
          <!-- Stick with version 0.5.1 because 0.5.24 contains new validation - and it's recommended to switch to filevault-package-maven-plugin -->
          <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.6.16</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>jcr\:isCheckedOut</exclude>
              <exclude>cq\:lastModified</exclude>
              <exclude>cq\:lastModifiedBy</exclude>
              <exclude>cq\:lastReplicated</exclude>
              <exclude>cq\:lastReplicatedBy</exclude>
              <exclude>cq\:lastReplicationAction</exclude>
              <exclude>cq\:lastRolledout</exclude>
              <exclude>cq\:lastRolledoutBy</exclude>
              <exclude>dam\:extracted</exclude>
              <exclude>dam\:sha1</exclude>
              <exclude>dam\:Comments</exclude>
              <exclude>dam\:assetState</exclude>
              <exclude>dam\:relativePath</exclude>
              <exclude>dc\:modified</exclude>
            </excludeProperties>
            <excludeMixins>
              <exclude>mix\:versionable</exclude>
              <exclude>mix\:referenceable</exclude>
              <exclude>cq\:Taggable</exclude>
              <exclude>cq\:ReplicationStatus</exclude>
            </excludeMixins>
            <unpackDeleteDirectories>
              <directory>jcr_root</directory>
            </unpackDeleteDirectories>
            <failOnMissingEmbed>true</failOnMissingEmbed>
          </configuration>
        </plugin>

        <plugin>
          <groupId>io.wcm.maven.plugins</groupId>
          <artifactId>cq-maven-plugin</artifactId>
          <version>1.0.4</version>
          <configuration>
            <slingPluginVersion>${sling.maven-sling-plugin.version}</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.10.2</version>
          <extensions>true</extensions>
          <dependencies>
            <dependency>
              <groupId>io.wcm.devops.conga.plugins</groupId>
              <artifactId>io.wcm.devops.conga.plugins.sling</artifactId>
              <version>1.2.4</version>
            </dependency>
            <dependency>
              <groupId>io.wcm.devops.conga.plugins</groupId>
              <artifactId>io.wcm.devops.conga.plugins.aem</artifactId>
              <version>1.8.10</version>
            </dependency>
            <dependency>
              <groupId>io.wcm.devops.conga.plugins</groupId>
              <artifactId>io.wcm.devops.conga.plugins.ansible</artifactId>
              <version>1.3.0</version>
            </dependency>
          </dependencies>
        </plugin>
        <plugin>
          <groupId>io.wcm.devops.conga.plugins</groupId>
          <artifactId>conga-aem-maven-plugin</artifactId>
          <version>1.8.10</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-profile</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.8</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>

  </profiles>

</project>
