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

  <parent>
    <groupId>io.wcm</groupId>
    <artifactId>io.wcm.caconfig.parent</artifactId>
    <version>1.1.10</version>
    <relativePath>../../parent/pom.xml</relativePath>
  </parent>

  <groupId>io.wcm</groupId>
  <artifactId>io.wcm.caconfig.editor</artifactId>
  <version>1.6.0</version>
  <packaging>bundle</packaging>

  <name>Context-Aware Configuration Editor</name>
  <description>Context-Aware Configuration Editor Template for AEM.</description>
  <url>${site.url}/caconfig/editor/</url>

  <properties>
    <site.url.module.prefix>caconfig/editor/bundle</site.url.module.prefix>
  </properties>

  <dependencies>

    <dependency>
      <groupId>org.apache.sling</groupId>
      <artifactId>org.apache.sling.models.api</artifactId>
      <scope>compile</scope>
    </dependency>

    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <scope>compile</scope>
    </dependency>

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.geronimo.specs</groupId>
      <artifactId>geronimo-atinject_1.0_spec</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.sling</groupId>
      <artifactId>org.apache.sling.caconfig.api</artifactId>
      <version>1.1.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.sling</groupId>
      <artifactId>org.apache.sling.caconfig.spi</artifactId>
      <version>1.3.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.sling</groupId>
      <artifactId>org.apache.sling.caconfig.impl</artifactId>
      <version>1.4.0</version>
      <scope>compile</scope>
    </dependency>

    <dependency>
      <groupId>io.wcm</groupId>
      <artifactId>io.wcm.sling.commons</artifactId>
      <version>1.2.2</version>
      <scope>compile</scope>
      <optional>true</optional>
    </dependency>

    <dependency>
      <groupId>org.skyscreamer</groupId>
      <artifactId>jsonassert</artifactId>
      <version>1.5.0</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.sling</groupId>
      <artifactId>org.apache.sling.testing.caconfig-mock-plugin</artifactId>
      <version>1.3.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.wcm</groupId>
      <artifactId>io.wcm.caconfig.extensions</artifactId>
      <version>1.6.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.wcm</groupId>
      <artifactId>io.wcm.caconfig.extensions</artifactId>
      <version>1.6.0</version>
      <classifier>tests</classifier>
      <scope>test</scope>
    </dependency>

    <!-- For build compatibility with Java 11 -->
    <dependency>
      <groupId>org.apache.geronimo.specs</groupId>
      <artifactId>geronimo-annotation_1.3_spec</artifactId>
      <scope>provided</scope>
    </dependency>

  </dependencies>

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>false</filtering>
        <excludes>
          <!-- those resources are processed by the i18n-maven-plugin -->
          <exclude>i18n/**</exclude>
          <!-- processed by grund html2js -->
          <exclude>angularjs-partials/**</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>

      <plugin>
        <groupId>io.wcm.devops.maven.plugins</groupId>
        <artifactId>eclipse-maven-plugin</artifactId>
        <configuration>
          <addVersionToProjectName>false</addVersionToProjectName>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <configuration>
          <instructions>
            <Sling-Initial-Content>
              SLING-INF/app-root;overwrite:=true;ignoreImportProviders:=xml;path:=/apps/wcm-io/caconfig/editor,
              SLING-INF/clientlibs-root;overwrite:=true;ignoreImportProviders:=xml;path:=/etc/clientlibs/wcm-io/caconfig/editor
            </Sling-Initial-Content>
            <Sling-Model-Packages>
              io.wcm.caconfig.editor.model
            </Sling-Model-Packages>

            <!-- Make compatible with different AEM versions -->
            <Import-Package>
              javax.annotation;version="[0.0,2)",
              *
            </Import-Package>

          </instructions>
        </configuration>
      </plugin>

      <!-- Nodejs Maven Plugin to run the templates compilation and tests -->
      <plugin>
        <groupId>io.wcm.maven.plugins</groupId>
        <artifactId>nodejs-maven-plugin</artifactId>
        <executions>
          <execution>
            <phase>compile</phase>
            <goals><goal>run</goal></goals>
          </execution>
        </executions>
        <configuration>
          <nodeJsVersion>6.11.2</nodeJsVersion>
          <tasks>
            <npmInstallTask>
              <workingDirectory>${project.basedir}</workingDirectory>
            </npmInstallTask>
            <nodeJsTask>
              <workingDirectory>${project.basedir}</workingDirectory>
              <moduleName>grunt-cli</moduleName>
              <executableName>grunt</executableName>
              <arguments>
                <argument>build</argument>
              </arguments>
            </nodeJsTask>
          </tasks>
        </configuration>
      </plugin>

      <plugin>
        <groupId>io.wcm.maven.plugins</groupId>
        <artifactId>i18n-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>transform</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- Apply maven filtering to clientlib definitions (cache key) -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>add-resource</goal>
            </goals>
            <phase>process-resources</phase>
            <configuration>
              <resources>
                <resource>
                  <directory>src/main/webapp</directory>
                  <targetPath>SLING-INF</targetPath>
                  <filtering>true</filtering>
                  <includes>
                    <include>clientlibs-root/*.json</include>
                  </includes>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>

    </plugins>
    <pluginManagement>
      <plugins>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <configuration>
            <excludePackageNames>*.impl,*.model</excludePackageNames>
          </configuration>
        </plugin>

      </plugins>
    </pluginManagement>
  </build>

  <distributionManagement>
    <site>
      <id>${site.deploy.id}</id>
      <url>${site.deploy.url}${site.url.module.prefix}</url>
    </site>
  </distributionManagement>

</project>
