<?xml version="1.0" encoding="UTF-8"?>
<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>com.hubspot</groupId>
    <artifactId>Singularity</artifactId>
    <version>1.1.0</version>
  </parent>

  <artifactId>SingularityUI</artifactId>

  <properties>
    <nodeVersion>v8.9.3</nodeVersion>
    <npmVersion>5.5.1</npmVersion>
  </properties>

  <profiles>
    <profile>
      <id>build-webui</id>
      <activation>
        <property>
          <name>!skipSingularityWebUI</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>com.github.eirslett</groupId>
            <artifactId>frontend-maven-plugin</artifactId>

            <executions>
              <execution>
                <id>install node and npm</id>
                <goals>
                  <goal>install-node-and-npm</goal>
                </goals>
              </execution>

              <execution>
                <id>npm install</id>
                <goals>
                  <goal>npm</goal>
                </goals>
                <configuration>
                  <arguments>install</arguments>
                </configuration>
              </execution>

              <execution>
                <id>npm test</id>
                <goals>
                  <goal>npm</goal>
                </goals>
                <configuration>
                  <arguments>test</arguments>
                </configuration>
              </execution>

              <execution>
                <id>gulp build</id>
                <goals>
                  <goal>gulp</goal>
                </goals>
                <configuration>
                  <arguments>build</arguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <executions>
              <execution>
                <id>copy-index.html-template</id>
                <goals>
                  <goal>copy-resources</goal>
                </goals>
                <phase>generate-resources</phase>
                <configuration>
                  <outputDirectory>${basedir}/target/generated-resources/com/hubspot/singularity/views</outputDirectory>
                  <resources>
                    <resource>
                      <directory>${basedir}/app/assets/</directory>
                      <includes>
                        <include>index.mustache</include>
                      </includes>
                    </resource>
                  </resources>
                </configuration>
              </execution>
              <execution>
                <id>copy-ui</id>
                <goals>
                  <goal>copy-resources</goal>
                </goals>
                <phase>generate-resources</phase>
                <configuration>
                  <outputDirectory>${basedir}/target/generated-resources/assets</outputDirectory>
                  <resources>
                    <resource>
                      <directory>${basedir}/dist</directory>
                    </resource>
                  </resources>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>add-generated-resources</id>
                <goals>
                  <goal>add-resource</goal>
                </goals>
                <phase>generate-resources</phase>
                <configuration>
                  <resources>
                    <resource>
                      <directory>${project.build.directory}/generated-resources</directory>
                    </resource>
                  </resources>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
