<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>
    <groupId>org.dspace.modules</groupId>
    <artifactId>xmlui-mirage2</artifactId>
    <packaging>war</packaging>
    <name>DSpace XML-UI Mirage2 Theme :: Local Customisations</name>
    <description>
        This project allows you to overlay your own local Mirage2 Theme customizations
        on top of the default Mirage2 Theme provided with DSpace.
    </description>

    <parent>
        <groupId>org.dspace</groupId>
        <artifactId>modules</artifactId>
        <version>6.3</version>
        <relativePath>..</relativePath>
    </parent>

    <properties>
        <!-- This is the path to the root [dspace-src] directory. -->
        <root.basedir>${basedir}/../../..</root.basedir>
        <grunt.environment>prod</grunt.environment>
        <grunt.color.scheme>classic_mirage_color_scheme</grunt.color.scheme>
        <mirage2.deps.included>true</mirage2.deps.included>
        <!-- Versions of build dependencies to be auto-installed when "mirage2.deps.included=true" -->
        <sass.version>3.3.14</sass.version>
        <compass.version>1.0.1</compass.version>
        <node.version>6.5.0</node.version>
        <npm.version>3.10.8</npm.version>
    </properties>

    <build>
        <!-- Centrally manage the versions of all plugins used below -->
        <pluginManagement>
            <plugins>
                <!-- This iterator plugin is used by all build <profiles> below -->
                <plugin>
                    <groupId>com.soebes.maven.plugins</groupId>
                    <artifactId>iterator-maven-plugin</artifactId>
                    <version>0.3</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-dependencies</id>
                        <phase>process-sources</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/mirage2-source-extracted</outputDirectory>
                            <excludes>
                                WEB-INF/**,META-INF/**
                            </excludes>
                            <includeArtifactIds>
                                dspace-xmlui-mirage2
                            </includeArtifactIds>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <phase>process-resources</phase>
                        <configuration>
                            <outputDirectory>${project.build.directory}/themes</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}/src/main/webapp/themes</directory>
                                    <excludes>
                                        <exclude>**/*.bmp</exclude>
                                        <exclude>**/*.jpg</exclude>
                                        <exclude>**/*.jpeg</exclude>
                                        <exclude>**/*.gif</exclude>
                                        <exclude>**/*.png</exclude>
                                        <exclude>**/*.ico</exclude>
                                        <exclude>**/*.svg</exclude>
                                        <exclude>**/*.ttf</exclude>
                                        <exclude>**/*.woff</exclude>
                                        <exclude>**/*.eot</exclude>
                                        <exclude>**/*.xsl</exclude>
                                    </excludes>
                                    <filtering>true</filtering>
                                </resource>
                                <resource>
                                    <directory>${basedir}/src/main/webapp/themes</directory>
                                    <includes>
                                        <include>**/*.bmp</include>
                                        <include>**/*.jpg</include>
                                        <include>**/*.jpeg</include>
                                        <include>**/*.gif</include>
                                        <include>**/*.png</include>
                                        <include>**/*.ico</include>
                                        <include>**/*.svg</include>
                                        <include>**/*.ttf</include>
                                        <include>**/*.woff</include>
                                        <include>**/*.eot</include>
                                        <include>**/*.xsl</include>
                                    </includes>
                                    <filtering>false</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <tasks>
                                <echo>PATH=${env.PATH}</echo>
                                <echo>GEM_PATH=${env.GEM_PATH}</echo>
                                <echo>GEM_HOME=${env.GEM_HOME}</echo>
                                <echo>mirage2.deps.included=${mirage2.deps.included}</echo>
                                <echo>grunt.color.scheme=${grunt.color.scheme}</echo>
                                <echo>grunt.environment=${grunt.environment}</echo>
                                <echo>source=${basedir}/src/main/webapp/themes/</echo>
                            </tasks>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <archiveClasses>false</archiveClasses>
                    <warSourceExcludes>themes/**</warSourceExcludes>
                    <!-- Filter the web.xml (needed for IDE compatibility/debugging) -->
                    <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
                    <webResources>
                        <resource>
                            <directory>${project.build.directory}/themes</directory>
                            <targetPath>themes</targetPath>
                            <excludes>
                                <exclude>**/node_modules/**</exclude>
                                <exclude>**/.sass-cache/**</exclude>
                                <exclude>**/.tmp/**</exclude>
                            </excludes>
                        </resource>
                    </webResources>
                    <overlays>
                        <!--
                           the priority of overlays is determined here
                           1.) default: anything in the current project has highest
                           2.) anything defined here has precedence in the order defined
                           3.) any war found transitively in the dependencies will be applied
                           next. the order is unpredictable.
                        -->
                        <overlay>
                            <groupId>org.dspace</groupId>
                            <artifactId>dspace-xmlui-mirage2</artifactId>
                            <type>war</type>
                            <excludes>
                                <exclude>**</exclude>
                            </excludes>
                        </overlay>
                    </overlays>
                </configuration>
                <executions>
                    <execution>
                        <phase>prepare-package</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <!-- Faster build profile (enable with -Dmirage2.deps.included=true).
         However you must manually install dependencies on your machine for this to work. -->
    <profiles>
        <profile>
            <id>mirage2-deps-preinstalled-fast</id>
            <activation>
                <property>
                    <name>mirage2.deps.included</name>
                    <value>false</value>
                </property>
            </activation>
            <build>
                <!-- Centrally manage the versions of all plugins used by this profile -->
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.codehaus.mojo</groupId>
                            <artifactId>exec-maven-plugin</artifactId>
                            <version>1.4.0</version>
                        </plugin>
                    </plugins>
                </pluginManagement>
                <plugins>
                    <plugin>
                        <groupId>com.soebes.maven.plugins</groupId>
                        <artifactId>iterator-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>iterator</goal>
                                </goals>
                                <configuration>
                                    <folder>${basedir}/src/main/webapp/themes/</folder>
                                    <pluginExecutors>
                                        <pluginExecutor>
                                            <plugin>
                                                <groupId>org.apache.maven.plugins</groupId>
                                                <artifactId>maven-resources-plugin</artifactId>
                                            </plugin>
                                            <goal>copy-resources</goal>
                                            <configuration>
                                                <outputDirectory>${project.build.directory}/themes/@item@</outputDirectory>
                                                <overwrite>false</overwrite>
                                                <resources>
                                                    <resource>
                                                        <directory>${project.build.directory}/mirage2-source-extracted</directory>
                                                        <filtering>false</filtering>
                                                        <excludes>
                                                            <exclude>sitemap.xmap</exclude>
                                                        </excludes>
                                                    </resource>
                                                </resources>
                                            </configuration>
                                        </pluginExecutor>
                                        <pluginExecutor>
                                            <plugin>
                                                <groupId>org.apache.maven.plugins</groupId>
                                                <artifactId>maven-resources-plugin</artifactId>
                                            </plugin>
                                            <goal>copy-resources</goal>
                                            <configuration>
                                                <outputDirectory>${project.build.directory}/themes/@item@</outputDirectory>
                                                <overwrite>false</overwrite>
                                                <resources>
                                                    <resource>
                                                        <directory>${project.build.directory}/mirage2-source-extracted</directory>
                                                        <filtering>true</filtering>
                                                        <includes>
                                                            <include>sitemap.xmap</include>
                                                        </includes>
                                                    </resource>
                                                </resources>
                                            </configuration>
                                        </pluginExecutor>
                                        <pluginExecutor>
                                            <plugin>
                                                <groupId>org.codehaus.mojo</groupId>
                                                <artifactId>exec-maven-plugin</artifactId>
                                            </plugin>
                                            <goal>exec</goal>
                                            <configuration>
                                                <executable>npm</executable>
                                                <arguments>
                                                    <argument>install</argument>
                                                </arguments>
                                                <workingDirectory>${project.build.directory}/themes/@item@
                                                </workingDirectory>
                                                <environmentVariables>
                                                    <PATH>${env.PATH}</PATH>
                                                </environmentVariables>
                                            </configuration>
                                        </pluginExecutor>
                                        <pluginExecutor>
                                            <plugin>
                                                <groupId>org.codehaus.mojo</groupId>
                                                <artifactId>exec-maven-plugin</artifactId>
                                            </plugin>
                                            <goal>exec</goal>
                                            <configuration>
                                                <executable>grunt</executable>
                                                <arguments>
                                                    <argument>${grunt.color.scheme}</argument>
                                                    <argument>${grunt.environment}</argument>
                                                </arguments>
                                                <workingDirectory>${project.build.directory}/themes/@item@
                                                </workingDirectory>
                                                <environmentVariables>
                                                    <PATH>${env.PATH}</PATH>
                                                    <GEM_PATH>${env.GEM_PATH}</GEM_PATH>
                                                    <GEM_HOME>${env.GEM_HOME}</GEM_HOME>
                                                    <LC_CTYPE>UTF-8</LC_CTYPE>
                                                </environmentVariables>
                                            </configuration>
                                        </pluginExecutor>
                                    </pluginExecutors>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- DEFAULT profile. Automatically installs all necessary dependencies (Node.js, etc.)
             to a temp location EVERY time project is built. This results in a slower build, but
             it doesn't require that you install these dependencies yourself. -->
        <profile>
            <id>mirage2-deps-included-slow</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <property>
                    <name>mirage2.deps.included</name>
                    <value>true</value>
                </property>
            </activation>
            <repositories>
                <repository>
                    <id>rubygems-release</id>
                    <url>http://rubygems-proxy.torquebox.org/releases</url>
                </repository>
            </repositories>
            <dependencies>
                <dependency>
                    <groupId>rubygems</groupId>
                    <artifactId>sass</artifactId>
                    <version>${sass.version}</version>
                    <type>gem</type>
                </dependency>
                <dependency>
                    <groupId>rubygems</groupId>
                    <artifactId>compass</artifactId>
                    <version>${compass.version}</version>
                    <type>gem</type>
                </dependency>
            </dependencies>
            <build>
                <!-- Centrally manage the versions of all plugins used by this profile -->
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>de.saumya.mojo</groupId>
                            <artifactId>gem-maven-plugin</artifactId>
                            <version>1.0.6</version>
                        </plugin>
                        <plugin>
                            <groupId>com.github.eirslett</groupId>
                            <artifactId>frontend-maven-plugin</artifactId>
                            <version>1.0</version>
                        </plugin>
                    </plugins>
                </pluginManagement>
                <plugins>
                    <plugin>
                        <groupId>de.saumya.mojo</groupId>
                        <artifactId>gem-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>initialize</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>com.soebes.maven.plugins</groupId>
                        <artifactId>iterator-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>iterator</goal>
                                </goals>
                                <configuration>
                                    <folder>${basedir}/src/main/webapp/themes/</folder>
                                    <pluginExecutors>

                                        <pluginExecutor>
                                            <plugin>
                                                <groupId>org.apache.maven.plugins</groupId>
                                                <artifactId>maven-resources-plugin</artifactId>
                                            </plugin>
                                            <goal>copy-resources</goal>
                                            <configuration>
                                                <outputDirectory>${project.build.directory}/themes/@item@</outputDirectory>
                                                <overwrite>false</overwrite>
                                                <resources>
                                                    <resource>
                                                        <directory>${project.build.directory}/mirage2-source-extracted</directory>
                                                        <filtering>false</filtering>
                                                        <excludes>
                                                            <exclude>sitemap.xmap</exclude>
                                                        </excludes>
                                                    </resource>
                                                </resources>
                                            </configuration>
                                        </pluginExecutor>
                                        <pluginExecutor>
                                            <plugin>
                                                <groupId>org.apache.maven.plugins</groupId>
                                                <artifactId>maven-resources-plugin</artifactId>
                                            </plugin>
                                            <goal>copy-resources</goal>
                                            <configuration>
                                                <outputDirectory>${project.build.directory}/themes/@item@</outputDirectory>
                                                <overwrite>false</overwrite>
                                                <resources>
                                                    <resource>
                                                        <directory>${project.build.directory}/mirage2-source-extracted</directory>
                                                        <filtering>true</filtering>
                                                        <includes>
                                                            <include>sitemap.xmap</include>
                                                        </includes>
                                                    </resource>
                                                </resources>
                                            </configuration>
                                        </pluginExecutor>
                                        <pluginExecutor>
                                            <!--<id>install node and npm</id>-->
                                            <plugin>
                                                <groupId>com.github.eirslett</groupId>
                                                <artifactId>frontend-maven-plugin</artifactId>
                                            </plugin>
                                            <goal>install-node-and-npm</goal>
                                            <!--<phase>process-resources</phase>-->
                                            <configuration>
                                                <workingDirectory>${project.build.directory}/themes/@item@</workingDirectory>
                                                <nodeVersion>v${node.version}</nodeVersion>
                                                <npmVersion>${npm.version}</npmVersion>
                                            </configuration>
                                        </pluginExecutor>
                                        <pluginExecutor>
                                            <!--<id>npm install &amp;&amp; bower install</id>-->
                                            <plugin>
                                                <groupId>com.github.eirslett</groupId>
                                                <artifactId>frontend-maven-plugin</artifactId>
                                            </plugin>
                                            <goal>npm</goal>
                                            <!--<phase>prepare-package</phase>-->
                                            <configuration>
                                                <arguments>install</arguments>
                                                <workingDirectory>${project.build.directory}/themes/@item@</workingDirectory>
                                            </configuration>
                                        </pluginExecutor>
                                        <pluginExecutor>
                                            <!--<id>grunt</id>-->
                                            <plugin>
                                                <groupId>com.github.eirslett</groupId>
                                                <artifactId>frontend-maven-plugin</artifactId>
                                            </plugin>
                                            <goal>grunt</goal>
                                            <!--<phase>prepare-package</phase>-->
                                            <configuration>
                                                <arguments>${grunt.color.scheme} no-compass-${grunt.environment}
                                                </arguments>
                                                <workingDirectory>${project.build.directory}/themes/@item@</workingDirectory>
                                            </configuration>
                                        </pluginExecutor>
                                        <pluginExecutor>
                                            <plugin>
                                                <groupId>de.saumya.mojo</groupId>
                                                <artifactId>gem-maven-plugin</artifactId>
                                            </plugin>
                                            <goal>exec</goal>
                                            <configuration>
                                                <launchDirectory>${project.build.directory}/themes/@item@</launchDirectory>
                                                <execArgs>${project.build.directory}/rubygems/bin/compass compile -c
                                                    config-${grunt.environment}.rb
                                                </execArgs>
                                            </configuration>
                                        </pluginExecutor>
                                    </pluginExecutors>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>mirage2_dev</id>
            <properties>
                <grunt.environment>dev</grunt.environment>
            </properties>
        </profile>
        <profile>
            <id>mirage2_bootstrap_color_scheme</id>
            <properties>
                <grunt.color.scheme>bootstrap_color_scheme</grunt.color.scheme>
            </properties>
        </profile>
    </profiles>

    <dependencies>

        <dependency>
            <groupId>org.dspace</groupId>
            <artifactId>dspace-xmlui-mirage2</artifactId>
            <version>${project.version}</version>
            <type>war</type>
        </dependency>
    </dependencies>

</project>
