<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.
-->
<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.apache.myfaces.tobago</groupId>
    <artifactId>tobago</artifactId>
    <version>3.0.4</version>
  </parent>
  <packaging>pom</packaging>
  <name>Tobago Themes</name>
  <artifactId>tobago-theme</artifactId>

  <properties>
    <bootstrap.version>4.0.0-alpha.5</bootstrap.version>
  </properties>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>exec-maven-plugin</artifactId>
          <version>1.4.0</version>
        </plugin>
        <plugin>
          <groupId>net.alchim31.maven</groupId>
          <artifactId>yuicompressor-maven-plugin</artifactId>
          <version>1.5.1</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <modules>
    <module>tobago-theme-standard</module>
    <!--<module>tobago-theme-scarborough</module>-->
    <module>tobago-theme-speyside</module>
    <!--<module>tobago-theme-richmond</module>-->
    <!--<module>tobago-theme-charlotteville</module>-->
  </modules>

  <dependencies>
    <dependency>
      <groupId>org.apache.myfaces.core</groupId>
      <artifactId>myfaces-api</artifactId>
      <optional>true</optional>
    </dependency>
  </dependencies>

  <profiles>

    <profile>
      <id>all-modules</id>
      <modules>
        <module>tobago-theme-scarborough</module>
        <module>tobago-theme-richmond</module>
        <module>tobago-theme-charlotteville</module>
      </modules>
    </profile>

    <profile>
      <id>rebuild-theme</id>
      <build>
        <plugins>

          <plugin>
            <artifactId>maven-scm-plugin</artifactId>
            <version>1.9.5</version>
            <executions>
              <execution>
                <!--load Bootstrap sources via git to target/checkout -->
                <id>step #1: copy-bootstrap</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>checkout</goal>
                </goals>
                <configuration>
                  <connectionUrl>scm:git:https://github.com/twbs/bootstrap</connectionUrl>
                  <skipCheckoutIfExists>true</skipCheckoutIfExists>
                  <scmVersion>v${bootstrap.version}</scmVersion>
                  <scmVersionType>branch</scmVersionType>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.7</version>
            <executions>
              <execution>
                <!-- copy Bootstrap to target/bootstrap -->
                <id>step #2: copy-bootstrap</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>copy-resources</goal>
                </goals>
                <configuration>
                  <outputDirectory>${project.build.directory}/bootstrap</outputDirectory>
                  <resources>
                    <resource>
                      <directory>${project.build.directory}/checkout</directory>
                      <exclude>scss/_custom.scss</exclude>
                    </resource>
                  </resources>
                </configuration>
              </execution>
              <execution>
                <!-- copy customization to target/bootstrap -->
                <id>step #3: copy-custom</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>copy-resources</goal>
                </goals>
                <configuration>
                  <outputDirectory>${project.build.directory}/bootstrap</outputDirectory>
                  <resources>
                    <resource>
                      <directory>src/main
                      </directory>
                      <includes>
                        <include>scss/*</include>
                      </includes>
                    </resource>
                  </resources>
                </configuration>
              </execution>
              <execution>
                <!-- copy the result to target/classes -->
                <id>step #8: copy-bootstrap-dist</id>
                <phase>process-resources</phase>
                <goals>
                  <goal>copy-resources</goal>
                </goals>
                <configuration>
                  <outputDirectory>
                    ${basedir}/src/main/resources/META-INF/resources/tobago/${theme.name}/bootstrap/${bootstrap.version}
                  </outputDirectory>
                  <resources>
                    <resource>
                      <directory>${project.build.directory}/bootstrap/dist</directory>
                    </resource>
                  </resources>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>com.github.eirslett</groupId>
            <artifactId>frontend-maven-plugin</artifactId>
            <version>1.0</version>

            <!-- optional -->
            <configuration>
              <nodeVersion>v6.5.0</nodeVersion>
              <npmVersion>3.10.8</npmVersion>
              <!-- optional: where to download node and npm from. Defaults to https://nodejs.org/dist/ -->
              <!--<downloadRoot>http://myproxy.example.org/nodejs/dist/</downloadRoot>-->
              <!-- optional: where to install node and npm. Defaults to the working directory -->
              <installDirectory>${project.build.directory}/frontend</installDirectory>
              <workingDirectory>${project.build.directory}/bootstrap</workingDirectory>
            </configuration>

            <executions>

              <execution>
                <!-- install "node" and "npm" -->
                <id>step #4: install node and npm</id>
                <goals>
                  <goal>install-node-and-npm</goal>
                </goals>
                <phase>generate-resources</phase>
              </execution>

              <execution>
                <!-- install "grunt-cli" -->
                <id>step #5: npm install grunt-cli</id>
                <goals>
                  <goal>npm</goal>
                </goals>
                <phase>generate-resources</phase>
                <configuration>
                  <arguments>install grunt-cli</arguments>
                </configuration>
              </execution>

              <execution>
                <!-- install all other required stuff for "bootstrap" -->
                <id>step #6: npm install</id>
                <goals>
                  <goal>npm</goal>
                </goals>
                <phase>generate-resources</phase>
                <configuration>
                  <arguments>install</arguments>
                </configuration>
              </execution>

              <execution>
                <!-- build "bootstrap" with "grunt" -->
                <id>step #7: grunt build</id>
                <goals>
                  <goal>grunt</goal>
                </goals>
                <phase>generate-resources</phase>
                <configuration>
                  <arguments>dist</arguments>
                </configuration>
              </execution>

            </executions>
          </plugin>

        </plugins>
      </build>
    </profile>
  </profiles>

</project>
