<?xml version="1.0" encoding="UTF-8"?>

<!--
 *
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 *
-->

<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>
  <parent>
    <groupId>org.xwiki.contrib</groupId>
    <artifactId>parent-platform</artifactId>
    <version>6.2.5</version>
  </parent>
  <artifactId>application-ckeditor-pom</artifactId>
  <packaging>pom</packaging>
  <name>CKEditor Integration Parent POM</name>
  <version>1.20</version>
  <description>Adds support for editing wiki pages using CKEditor.</description>
  <developers>
    <developer>
      <id>mflorea</id>
      <name>Marius Dumitru Florea</name>
    </developer>
  </developers>
  <scm>
    <connection>scm:git:git://github.com/xwiki-contrib/application-ckeditor.git</connection>
    <developerConnection>scm:git:git@github.com:xwiki-contrib/application-ckeditor.git</developerConnection>
    <url>https://github.com/xwiki-contrib/application-ckeditor/tree/master</url>
    <tag>application-ckeditor-1.20</tag>
  </scm>
  <properties>
    <ckeditor.version>4.7.3</ckeditor.version>
    <!-- The path to the folder where we clone the CKEditor sources. -->
    <ckeditor.path>${project.build.directory}/ckeditor-dev-${ckeditor.version}</ckeditor.path>
    <ckeditor.builder.path>${ckeditor.path}/dev/builder</ckeditor.builder.path>
    <ckeditor.plugins.path>${ckeditor.path}/plugins</ckeditor.plugins.path>
    <!-- Follow the specifications regarding the WebJar content path.
      (this property is defined in platform-core pom; remove this when the CKEditor is integrated in platform)-->
    <webjar.contentDirectory>${project.build.outputDirectory}/META-INF/resources/webjars/${project.artifactId}/${project.version}</webjar.contentDirectory>
    <xwiki.issueManagement.jira.id>CKEDITOR</xwiki.issueManagement.jira.id>
  </properties>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.webjars</groupId>
        <artifactId>requirejs</artifactId>
        <!-- RequireJS is a core extension in the default XWiki distribution and so it's not easy to upgrade it.
          Don't increase the version unless we also increase the required XWiki platform version. -->
        <version>2.1.15</version>
        <scope>runtime</scope>
      </dependency>
      <dependency>
        <groupId>org.webjars</groupId>
        <artifactId>jquery</artifactId>
        <!-- jQuery is a core extension in the default XWiki distribution and so it's not easy to upgrade it.
          Don't increase the version unless we also increase the required XWiki platform version. -->
        <version>1.11.1</version>
        <scope>runtime</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>com.googlecode.maven-download-plugin</groupId>
          <artifactId>download-maven-plugin</artifactId>
          <version>1.4.0</version>
          <executions>
            <!-- Download the CKEditor sources for the version (tag) we want to use. -->
            <execution>
              <id>download-ckeditor-sources</id>
              <!-- Make sure this execution is not used by default (you need to call it explicitly in your pom). -->
              <phase>none</phase>
              <goals>
                <goal>wget</goal>
              </goals>
              <configuration>
                <url>https://github.com/ckeditor/ckeditor-dev/archive/${ckeditor.version}.zip</url>
                <unpack>true</unpack>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <executions>
            <!-- Copy the build configuration to the CKEditor sources. -->
            <execution>
              <id>copy-ckeditor-build-config</id>
              <!-- Make sure this execution is not used by default (you need to call it explicitly in your pom). -->
              <phase>none</phase>
              <goals>
                <goal>copy-resources</goal>
              </goals>
              <configuration>
                <outputDirectory>${ckeditor.builder.path}</outputDirectory>
                <resources>
                  <resource>
                    <directory>src/main/config</directory>
                  </resource>
                </resources>
              </configuration>
            </execution>
            <!-- Copy the output of the CKEditor builder to the expected WebJar location. -->
            <execution>
              <id>copy-ckeditor-resources</id>
              <!-- Make sure this execution is not used by default (you need to call it explicitly in your pom). -->
              <phase>none</phase>
              <goals>
                <goal>copy-resources</goal>
              </goals>
              <configuration>
                <outputDirectory>${webjar.contentDirectory}</outputDirectory>
                <resources>
                  <resource>
                    <directory>${ckeditor.builder.path}/release/ckeditor</directory>
                  </resource>
                </resources>
              </configuration>
            </execution>
          </executions>
          <configuration>
            <overwrite>true</overwrite>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>exec-maven-plugin</artifactId>
          <executions>
            <!-- Build the CKEditor. -->
            <execution>
              <id>build-ckeditor</id>
              <!-- Use a phase after compile because the Clirr Maven Plugin executes all the phases up to compile twice. -->
              <phase>process-classes</phase>
              <goals>
                <goal>exec</goal>
              </goals>
              <configuration>
                <executable>${ckeditor.builder.path}/build.sh</executable>
                <arguments>
                  <argument>-s</argument>
                </arguments>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
  <modules>
    <module>base</module>
    <module>plugins</module>
    <module>test</module>
    <module>ui</module>
    <module>webjar</module>
  </modules>
</project>
