<?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>
    <artifactId>gxt-parent</artifactId>
    <groupId>com.sencha.gxt</groupId>
    <version>3.1.1</version>
  </parent>
  <artifactId>gxt-theme-neptune</artifactId>
  <name>Sencha GXT Neptune Theme</name>
  <properties>
    <bin>bin/phantomjs</bin>
  </properties>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <!-- This version should work with mvn 2.1, and doesn't emit warnings about our setup -->
        <version>2.2-beta-5</version>
        <executions>
          <execution>
            <id>make-fake-javadoc-zip</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <descriptors>
                <descriptor>javadoc-assembly.xml</descriptor>
              </descriptors>
              <classifier>javadoc</classifier>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.googlecode.maven-download-plugin</groupId>
        <artifactId>maven-download-plugin</artifactId>
        <version>1.1.0</version>
        <executions>
          <execution>
            <id>download-phantomjs-windows</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>wget</goal>
            </goals>
            <configuration>
              <url>https://phantomjs.googlecode.com/files/phantomjs-${phantomjs.version}-${platform}${archive}</url>
              <outputDirectory>${project.build.directory}/phantomjs</outputDirectory>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <unpack>true</unpack>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <executions>
          <!-- If you see an error in eclipse on this next line "An exception occurred while executing the Java class. null", 
               this indicates that there was a problem generating Neptune from the config file. Run from the command line to
               get the full error, and on fixing it the error should go away, though a clean may also be required
          -->
          <execution>
            <id>generate-theme</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>java</goal>
            </goals>
            <configuration>
              <mainClass>com.sencha.gxt.themebuilder.ThemeBuilder</mainClass>
              <arguments>
                <argument>-gen</argument>
                <argument>${project.build.directory}/classes</argument>
                <argument>-imageFile</argument>
                <argument>${project.build.directory}/snapshot.png</argument>
                <argument>-manifestFile</argument>
                <argument>${project.build.directory}/snapshot.json</argument>
                <argument>-out</argument>
                <argument>${project.build.directory}/neptune-${project.version}.jar</argument>
                <argument>-warDir</argument>
                <argument>${project.build.directory}/war</argument>
                <argument>${project.basedir}/src/main/resources/neptune.theme</argument>
              </arguments>
              <systemProperties>
                <systemProperty>
                  <key>phantomBin</key>
                  <value>${project.build.directory}/phantomjs/phantomjs-${phantomjs.version}-${platform}/${bin}</value>
                </systemProperty>
              </systemProperties>
              <includePluginDependencies>true</includePluginDependencies>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>com.sencha.gxt</groupId>
            <artifactId>gxt-themebuilder</artifactId>
            <version>${project.version}</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
    <pluginManagement>
      <plugins>
        <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>com.googlecode.maven-download-plugin</groupId>
                    <artifactId>maven-download-plugin</artifactId>
                    <versionRange>[1.1.0,)</versionRange>
                    <goals>
                      <goal>wget</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <execute>
                      <runOnConfiguration>true</runOnConfiguration>
                    </execute>
                  </action>
                </pluginExecution>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <versionRange>[1.2.1,)</versionRange>
                    <goals>
                      <goal>java</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <execute>
                      <runOnIncremental>true</runOnIncremental>
                    </execute>
                  </action>
                </pluginExecution>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <versionRange>[1.0.0,)</versionRange>
                    <goals>
                      <goal>enforce</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <ignore />
                  </action>
                </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <profiles>
    <profile>
      <id>win32</id>
      <activation>
        <os>
          <family>windows</family>
        </os>
      </activation>
      <properties>
        <platform>windows</platform>
        <bin>phantomjs.exe</bin>
        <archive>.zip</archive>
      </properties>
    </profile>

    <profile>
      <id>mac</id>
      <activation>
        <os>
          <family>mac</family>
        </os>
      </activation>
      <properties>
        <platform>macosx</platform>
        <archive>.zip</archive>
      </properties>
    </profile>
    <profile>
      <id>linux</id>
      <activation>
        <os>
          <family>unix</family>
          <name>linux</name>
        </os>
      </activation>
      <properties>
        <platform>linux-i686</platform>
        <archive>.tar.bz2</archive>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>com.googlecode.maven-download-plugin</groupId>
            <artifactId>maven-download-plugin</artifactId>
            <configuration>
              <unpack>false</unpack>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.7</version>
            <executions>
              <execution>
                <id>unpack-linux</id>
                <phase>compile</phase>
                <goals>
                  <goal>run</goal>
                </goals>
                <configuration>
                  <failOnError>true</failOnError>
                  <target>
                    <bunzip2 src="${project.build.directory}/phantomjs/phantomjs-${phantomjs.version}-${platform}.tar.bz2"/>
                    <untar src="${project.build.directory}/phantomjs/phantomjs-${phantomjs.version}-${platform}.tar" dest="${project.build.directory}/phantomjs/"/>
                  </target>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>lin64</id>
      <activation>
        <os>
          <family>unix</family>
          <arch>amd64</arch>
          <name>linux</name>
        </os>
      </activation>
      <properties>
        <platform>linux-x86_64</platform>
      </properties>
    </profile>
  </profiles>
</project>
