<?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>application-ckeditor-pom</artifactId>
    <version>1.18</version>
  </parent>
  <packaging>jar</packaging>
  <artifactId>application-ckeditor-plugins</artifactId>
  <name>CKEditor Integration Plugins</name>
  <description>Custom plugins that help the integration of the CKEditor in XWiki.</description>
  <properties>
    <!-- Name to display by the Extension Manager -->
    <xwiki.extension.name>CKEditor Plugins for XWiki</xwiki.extension.name>
    <!-- Explicitely indicate it's a webjar -->
    <xwiki.extension.jar.type>webjar</xwiki.extension.jar.type>
    <!-- No Java code here -->
    <xwiki.clirr.skip>true</xwiki.clirr.skip>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.webjars</groupId>
      <artifactId>requirejs</artifactId>
    </dependency>
    <dependency>
      <groupId>org.webjars</groupId>
      <artifactId>jquery</artifactId>
    </dependency>
    <dependency>
      <groupId>org.webjars.npm</groupId>
      <artifactId>bootstrap-3-typeahead</artifactId>
      <version>4.0.2</version>
      <scope>runtime</scope>
    </dependency>
    <!-- Test dependencies -->
    <dependency>
      <groupId>org.xwiki.contrib</groupId>
      <artifactId>application-ckeditor-base</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>com.cj.jshintmojo</groupId>
        <artifactId>jshint-maven-plugin</artifactId>
        <version>1.6.0</version>
        <executions>
          <execution>
            <goals>
              <goal>lint</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <globals>CKEDITOR</globals>
          <!-- See https://github.com/jshint/jshint/blob/master/examples/.jshintrc -->
          <options>camelcase,maxparams:5,maxdepth:3,maxstatements:20,maxcomplexity:10,maxlen:120</options>
        </configuration>
      </plugin>
      <plugin>
        <groupId>com.github.searls</groupId>
        <artifactId>jasmine-maven-plugin</artifactId>
        <!-- We want a more recent version of Jasmine and we want to use the PhantomJS driver-->
        <version>2.2</version>
        <executions>
          <execution>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <phantomjs>
            <version>2.1.1</version>
          </phantomjs>
          <jsSrcDir>${project.basedir}/src/main/resources</jsSrcDir>
          <jsTestSrcDir>${project.basedir}/src/test/resources</jsTestSrcDir>
          <preloadSources>
            <source>webjars/require.min.js</source>
            <source>require-config.js</source>
            <source>webjars/jquery.min.js</source>
            <!-- We need the full path here because ckeditor.js loads other resources using relative paths. -->
            <source>webjars/application-ckeditor-base/${project.version}/ckeditor.js</source>
          </preloadSources>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <!-- Copy the WebJar resources to the right path before packing the jar. -->
            <id>copy-webjar-resources</id>
            <phase>validate</phase>
            <goals>
              <goal>resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${webjar.contentDirectory}</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>net.alchim31.maven</groupId>
        <artifactId>yuicompressor-maven-plugin</artifactId>
        <version>1.5.1</version>
        <executions>
          <execution>
            <!-- Minify the WebJar resources before packing the jar. -->
            <id>minify-webjar-resources</id>
            <phase>process-resources</phase>
            <goals>
              <goal>compress</goal>
            </goals>
            <configuration>
              <sourceDirectory>${webjar.contentDirectory}</sourceDirectory>
              <outputDirectory>${webjar.contentDirectory}</outputDirectory>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <aggregations>
            <!-- Aggregate the Resource Picker modules. -->
            <aggregation>
              <insertNewLine>true</insertNewLine>
              <output>${webjar.contentDirectory}/xwiki-resource/resourcePicker.bundle.js</output>
              <includes>
                <include>*.js</include>
              </includes>
              <excludes>
                <exclude>plugin.js</exclude>
              </excludes>
            </aggregation>
            <!-- Aggregate the Macro Wizard modules. -->
            <aggregation>
              <insertNewLine>true</insertNewLine>
              <output>${webjar.contentDirectory}/xwiki-macro/macroWizard.bundle.js</output>
              <includes>
                <include>*.js</include>
              </includes>
              <excludes>
                <exclude>plugin.js</exclude>
              </excludes>
            </aggregation>
          </aggregations>
          <!-- We prefer to use the JSHint Maven Plugin because it gives us more control over the validation rules. -->
          <jswarn>false</jswarn>
          <!-- The default suffix uses the dash as separator (-min) but we prefer the dot (.min) because it is
            currently more widely used in the JavaScript world. -->
          <suffix>.min</suffix>
          <nosuffix>false</nosuffix>
          <preProcessAggregates>true</preProcessAggregates>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <includes>
            <!-- Include only the WebJar content -->
            <include>META-INF/**</include>
          </includes>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
