<?xml version="1.0"?>
<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>net.disy.wps</groupId>
  <artifactId>wps-scripts</artifactId>
  <packaging>jar</packaging>
  <name>WPS Scripts</name>

  <parent>
    <groupId>net.disy.wps</groupId>
    <artifactId>wps-parent</artifactId>
    <version>1.0</version>
    <relativePath>../wps-parent/pom.xml</relativePath>
  </parent>

  <dependencies>
    <dependency>
      <groupId>net.disy.legato</groupId>
      <artifactId>legato-scripts</artifactId>
      <version>${legato-core.version}</version>
    </dependency>
    <dependency>
      <groupId>net.jsunit</groupId>
      <artifactId>jsunit-testRunner</artifactId>
      <version>2.1.4</version>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <groupId>jetty</groupId>
          <artifactId>jetty</artifactId>
        </exclusion>
        <exclusion>
          <groupId>jetty</groupId>
          <artifactId>start</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>net.disy.legato</groupId>
      <artifactId>legato-testing</artifactId>
      <version>${legato-core.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>net.disy.legato</groupId>
      <artifactId>legato-tools</artifactId>
      <version>${legato-core.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>net.disy.prototype</groupId>
      <artifactId>prototype</artifactId>
      <version>1.6.0.3</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
      <resource>
        <directory>src/main/javascript</directory>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>src/test/resources</directory>
      </testResource>
    </testResources>
    <plugins>
      <plugin>
        <groupId>net.alchim31.maven</groupId>
        <artifactId>yuicompressor-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>compress</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
              <nosuffix>true</nosuffix>
              <outputDirectory>${project.build.directory}/compressed-scripts</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>net.disy.legato</groupId>
        <artifactId>legato-maven-plugin</artifactId>
        <version>1.2</version>
        <extensions>true</extensions>
        <executions>
          <execution>
            <id>aggregate-scripts</id>
            <phase>process-resources</phase>
            <goals>
              <goal>concatenate</goal>
            </goals>
            <configuration>
              <fileSetDescriptors>
                <fileSetDescriptor>src/main/resources/net/disy/wps/SingleFile.scripts</fileSetDescriptor>
                <fileSetDescriptor>src/main/resources/net/disy/wps/WPS.scripts</fileSetDescriptor>
              </fileSetDescriptors>
              <sourceDirectory>src/main/javascript</sourceDirectory>
              <targetDirectory>${project.build.outputDirectory}</targetDirectory>
              <targetFile>net/disy/wps/aggregated/WPS.js</targetFile>
              <addResource>true</addResource>
            </configuration>
          </execution>
          <execution>
            <id>aggregate-scripts-compressed</id>
            <phase>process-resources</phase>
            <goals>
              <goal>concatenate</goal>
            </goals>
            <configuration>
              <fileSetDescriptors>
                <fileSetDescriptor>src/main/resources/net/disy/wps/SingleFile.scripts</fileSetDescriptor>
                <fileSetDescriptor>src/main/resources/net/disy/wps/WPS.scripts</fileSetDescriptor>
              </fileSetDescriptors>
              <sourceDirectory>${project.build.directory}/compressed-scripts</sourceDirectory>
              <targetDirectory>${project.build.outputDirectory}</targetDirectory>
              <targetFile>net/disy/wps/aggregated/WPS.min.js</targetFile>
              <addResource>true</addResource>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.jvnet.mcvp</groupId>
        <artifactId>maven-css-validator-plugin</artifactId>
        <version>1.0.0</version>
        <executions>
          <execution>
            <phase>test</phase>
            <goals>
              <goal>validate</goal>
            </goals>
            <configuration>
              <includes>
                <include>src/main/resources/**/*.css</include>
              </includes>
              <cssValidationFailureIgnore>true</cssValidationFailureIgnore>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>jslint</id>
            <phase>test</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <tasks>
                <taskdef name="jslint" classname="com.googlecode.jslint4java.ant.JSLintTask" classpathref="maven.plugin.classpath" />
                <jslint encoding="UTF-8" options="indent=4,evil,laxbreak">
                  <formatter type="plain" />
                  <fileset dir="${basedir}/src/main/javascript" includes="**/*.js" />
                </jslint>
              </tasks>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.mycila.maven-license-plugin</groupId>
        <artifactId>maven-license-plugin</artifactId>
        <executions>
          <execution>
            <id>license-checkheaders</id>
            <phase>test</phase>
            <goals>
              <goal>check</goal>
            </goals>
            <configuration>
              <excludes>
                <exclude>**/*.bat</exclude>
                <exclude>**/*.scripts</exclude>
                <exclude>src/site/naturaldocs/**</exclude>
                <exclude>src/test/resources/**</exclude>
                <exclude>target-eclipse/**</exclude>
              </excludes>
            </configuration>
          </execution>
          <execution>
            <id>license-formatheaders</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>format</goal>
            </goals>
            <configuration>
              <includes>
                <include>**/*.min.js</include>
              </includes>
              <useDefaultExcludes>false</useDefaultExcludes>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <id>naturaldocs</id>
      <activation>
        <property>
          <name>performRelease</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
              <execution>
                <id>naturaldocs-initialize</id>
                <phase>initialize</phase>
              </execution>
              <execution>
                <id>naturaldocs-package</id>
                <phase>package</phase>
              </execution>
              <execution>
                <id>naturaldocs-pre-site</id>
                <phase>pre-site</phase>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>naturaldocs-process-sources</id>
                <phase>process-sources</phase>
              </execution>
              <execution>
                <id>naturaldocs-site</id>
                <phase>site</phase>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <inherited>true</inherited>
            <executions>
              <execution>
                <id>naturaldocs-install</id>
                <phase>package</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
