<?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.
  
  $Id: pom.xml 1179123 2011-10-05 09:40:26Z ate $
-->
<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>
  <prerequisites>
    <maven>2.0.9</maven>
  </prerequisites>

  <artifactId>jetspeed</artifactId>
  <name>Jetspeed-2 Portal Application</name>
  <description>Jetspeed-2 Portal Application</description>
  <parent>
    <groupId>org.apache.portals.jetspeed-2</groupId>
    <artifactId>applications</artifactId>
    <version>2.2.2</version>
  </parent>
  <packaging>war</packaging>

  <dependencies/>
  
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <configuration>
          <attach>false</attach>
        </configuration>
      </plugin>
      <plugin>
        <!-- only include this in top level project poms -->
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
          <skipAssembly>true</skipAssembly>
        </configuration>
      </plugin>
      <plugin>
        <!--
          workaround for war processing of m-r-r-plugin causing the generated
          NOTICE and LICENSE file to be put under WEB-INF/classes/META-INF
        -->
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-remote-resources-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>process</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/${project.build.finalName}</outputDirectory>
              <attached>false</attached>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>${project.groupId}</groupId>
        <artifactId>jetspeed-unpack-maven-plugin</artifactId>
        <version>${project.version}</version>
        <executions>
          <execution>
            <id>unpack-dojo</id>
            <goals>
              <goal>unpack</goal>
            </goals>
            <phase>process-resources</phase>
            <configuration>
              <unpack>
                <file>${basedir}/src/main/javascript/dojo/dojo.zip</file>
                <targetDirectory>${project.build.directory}/${project.build.finalName}/javascript/dojo</targetDirectory>
              </unpack>
            </configuration>
          </execution>
          <execution>
            <id>unpack-yui</id>
            <goals>
              <goal>unpack</goal>
            </goals>
            <phase>process-resources</phase>
            <configuration>
              <unpack>
                <file>${basedir}/src/main/javascript/yui/yui-build.zip</file>
                <targetDirectory>${project.build.directory}/${project.build.finalName}/javascript/yui</targetDirectory>
              </unpack>
            </configuration>
          </execution>
          <execution>
            <id>unpack-portal-resources</id>
            <goals>
              <goal>unpack</goal>
            </goals>
            <phase>process-resources</phase>
            <configuration>
              <unpack>
                <artifact>${project.groupId}:jetspeed-portal-resources:jar</artifact>
                <targetDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF</targetDirectory>
                <resources>
                  <resource>
                    <path>assembly</path>
                    <destination>assembly</destination>
                  </resource>
                  <resource>
                    <path>conf/jetspeed</path>
                    <destination>conf</destination>
                  </resource>
                  <resource>
                    <path>db-ojb</path>
                    <destination>classes</destination>
                  </resource>
                </resources>
              </unpack>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>jetspeed-portal-resources</artifactId>
            <version>${project.version}</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.2</version>
        <executions>
          <execution>
            <id>compress-js</id>
            <phase>process-resources</phase>
            <configuration>
              <tasks>
                <echo>Compressing JS files</echo>
                <property name="compressor.jar" 
                          value="${settings.localRepository}/org/dojotoolkit/custom_rhino/0.4.3/custom_rhino-0.4.3.jar"/>
                <mkdir dir="${project.build.directory}/${project.build.finalName}/javascript/jetspeed"/>
                <copy todir="${project.build.directory}/${project.build.finalName}/javascript/jetspeed">
                  <fileset dir="${basedir}/src/main/webapp/javascript/jetspeed">
                    <include name="**/*.src.js" />
                  </fileset>
                </copy>
                <apply executable="${java.home}/bin/java"
                       dir="${project.build.directory}/${project.build.finalName}/javascript/jetspeed">
                  <!-- Needs to prepend custom_rhino jar of dojotoolkit in the boot classpath 
                  because some JVMs such as OpenJDK 1.6 may embed another rhino jar. -->
                  <arg value="-Xbootclasspath/p:${compressor.jar}"/>
                  <arg value="-jar"/>
                  <arg value="${compressor.jar}"/>
                  <arg value="-strict"/>
                  <arg value="-opt"/>
                  <arg value="-1"/>
                  <arg value="-c"/>
                  <fileset dir="${project.build.directory}/${project.build.finalName}/javascript/jetspeed">
                    <patternset>
                      <include name="**/*.src.js"/>
                    </patternset>
                  </fileset>
                  <redirector>
                    <outputmapper id="out" type="glob"
                                  from="*.src.js" 
                                  to="${project.build.directory}${file.separator}${project.build.finalName}${file.separator}javascript${file.separator}jetspeed${file.separator}*.js" />
                  </redirector>
                </apply>
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.dojotoolkit</groupId>
            <artifactId>custom_rhino</artifactId>
            <version>0.4.3</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>

</project>
