<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright 2005-2012 The Kuali Foundation

Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php

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.kuali.kfs</groupId>
    <artifactId>kfs-parent</artifactId>
    <version>4.1.1-5</version>
  </parent>
  <artifactId>kfs-web</artifactId>
  <packaging>war</packaging>

  <properties>
    <kfs.source.package.phase>package</kfs.source.package.phase>
    <build.environment>dev</build.environment>
    <env.filter>${filter.directory}/${build.environment}-build.properties</env.filter>
  </properties>

  <build>
    <finalName>${project.parent.name}-${environment}</finalName>
    <filters>
      <filter>${user.home}/kfs-build.properties</filter>
      <filter>${env.filter}</filter>
      <filter>${filter.directory}/b2b.properties</filter>
      <filter>${filter.directory}/batch.properties</filter>
      <filter>${filter.directory}/build.properties</filter>
      <filter>${filter.directory}/build-foundation.properties</filter>
      <filter>${filter.directory}/cas.properties</filter>
      <filter>${filter.directory}/database.properties</filter>
      <filter>${filter.directory}/directory.properties</filter>
      <filter>${filter.directory}/email.properties</filter>
      <filter>${filter.directory}/logging.properties</filter>
      <filter>${filter.directory}/rice.properties</filter>
      <filter>${filter.directory}/spring.properties</filter>
      <filter>${filter.directory}/springide.properties</filter>
      <filter>${filter.directory}/url.properties</filter>
      <filter>${filter.directory}/web.properties</filter>
    </filters>
    
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
        <excludes>
          <exclude>**/*.zip</exclude>
        </excludes>
      </resource>
    </resources>
    
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>${maven-antrun-plugin.version}</version>
        <executions>
          <execution>
            <id>unpack-help</id>
            <phase>generate-resources</phase>
            <configuration>
              <target>
                <unzip src="src/main/resources/help.zip" dest="src/main/webapp/static/help/" overwrite="false" />
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <webResources>
            <resource>
              <filtering>true</filtering>
              <!-- this is relative to the pom.xml directory -->
              <directory>src/main/webapp/</directory>
              <includes>
                <include>**/web.xml</include>
              </includes>
            </resource>
          </webResources>
        </configuration>
      </plugin>

      <!-- Unpacks the datadictionary because KFS has trouble accessing the datadictionary from a jar -->      
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>${maven-dependency-plugin.version}</version>
        <executions>
          <execution>
            <id>unpack-datadictionary</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>${project.groupId}</groupId>
                  <artifactId>kfs-core</artifactId>
                  <version>${project.version}</version>  
                  <type>jar</type>
                  <overWrite>true</overWrite>
                  <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                  <excludes>**/*.class</excludes>
                </artifactItem>
                <artifactItem>
                  <groupId>${project.groupId}</groupId>
                  <artifactId>kfs-module-endow</artifactId>
                  <version>${project.version}</version>  
                  <type>jar</type>
                  <overWrite>true</overWrite>
                  <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                  <excludes>**/*.class</excludes>
                </artifactItem>
                <artifactItem>
                  <groupId>${project.groupId}</groupId>
                  <artifactId>kfs-module-external</artifactId>
                  <version>${project.version}</version>  
                  <type>jar</type>
                  <overWrite>true</overWrite>
                  <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                  <excludes>**/*.class</excludes>
                </artifactItem>
                <artifactItem>
                  <groupId>${project.groupId}</groupId>
                  <artifactId>kfs-rice</artifactId>
                  <version>${project.version}</version>  
                  <type>jar</type>
                  <overWrite>true</overWrite>
                  <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                  <excludes>**/*.class</excludes>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build> 
  
  <dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>kfs-core</artifactId>
      <version>${project.version}</version>  
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>kfs-module-endow</artifactId>
      <version>${project.version}</version>  
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>kfs-module-external</artifactId>
      <version>${project.version}</version>  
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>kfs-rice</artifactId>
      <version>${project.version}</version>  
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jsp-api</artifactId>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jstl</artifactId>
    </dependency>
    <dependency>
      <groupId>taglibs</groupId>
      <artifactId>standard</artifactId>
    </dependency>
  </dependencies> 
  
  <profiles>
    <profile>
      <id>rice-web</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <build>
        <plugins>
          <!-- 
               Using dependency unpack as opposed to war overlay for a number of reasons
               1) overlay requires the packaging phase - tomcat plugin run goal does not work with overlays (used by launch files).
               2) we could force our launch files to use run-exploded or run-war but that is too slow.
               3) overlayed resources are not placed in a directory (like generated code) making
               it difficult for developers to look at the overlayed resources
               4) our unit test's jetty lifecycle assume all web content resides in src/main/webapp (see point 3)
          -->
          <!-- 
               Having unpacked resources placed in src/main/webapp as opposed to target directory for the following reasons
               1) we could configure additional web resource directories for war packaging (via the war plugin)
               (ex: target/generated/rice-web but this does not work with either the tomcat or jetty plugins' run goals.
               2) we could force our launch files to use run-exploded or run-war but that is too slow.
               3) our unit test's jetty lifecycle assume all web content resides in src/main/webapp
               
               This seems like the way to go (placing unpacked content in target like other generated code) if we could find a
               solution for the tomcat/jetty plugins used by our launch files. This rice-web content could be cleaned and unpacked again
               similar to other generated code.  If we did this we would not have to maintain a separate clean step to delete the
               unpacked rice web content.  It would also be nicer in that all unpacked generated code would be place in a single
               directory rather than merged into our source tree.  This has the added benefit that the rice content would
               automatically be excluded from svn.  Currently, we have to use svn:ignore on individual rice folders & files.
               
               Update:  for jetty support with multiple web resource directories see: 
               http://docs.codehaus.org/display/JETTY/Multiple+WebApp+Source+Directory
          -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.2</version>
            <executions>
              <execution>
                <id>unpack-rice-web</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <configuration>	              
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.kuali.rice</groupId>
                      <artifactId>rice-web</artifactId>
                      <version>${rice.snapshot.web.version}</version>
                      <type>war</type>
                      <overWrite>false</overWrite>
                      <outputDirectory>src/main/webapp</outputDirectory>
                    </artifactItem>
                  </artifactItems>
                  <includes>*/**</includes>
                  <excludes>${rice.web.excludes}</excludes>
                </configuration>
              </execution>
            </executions>
          </plugin>
          
          <!-- cleans out rice unpacked rice web content -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-clean-plugin</artifactId>
            <version>2.4.1</version>
            <executions>
              <execution>
                <id>delete-rice-web</id>
                <phase>clean</phase>
                <goals>
                  <goal>clean</goal>
                </goals>
                <configuration>
                  <filesets>
                    <fileset>
                      <directory>src/main/webapp</directory>
                      <includes>
                        <include>index.jsp</include>
                        <include>kcb/</include>
                        <include>ken/</include>
                        <include>kew/</include>
                        <include>kim/</include>
                        <include>kr/</include>
                        <include>ksb/</include>
                        <include>rice-portal</include>
                        <include>WEB-INF/jsp/dummy_login.jsp</include>
                        <include>WEB-INF/jsp/recurseCheckTabHighlight.jsp</include>
                        <include>WEB-INF/jsp/recurseRowDisplay.jsp</include>
                        <include>WEB-INF/tags/kew/</include>
                        <include>WEB-INF/tags/kim/</include>
                        <include>WEB-INF/tags/kr/</include>
                        <include>WEB-INF/tags/rice-portal/channel/administration/</include>
                        <include>WEB-INF/tags/rice-portal/channel/main/</include>
                        <include>WEB-INF/tags/rice-portal/channel/portalChannelBottom.tag</include>
                        <include>WEB-INF/tags/rice-portal/channel/portalChannelTop.tag</include>
                        <include>WEB-INF/tags/rice-portal/administrationTab.tag</include>
                        <include>WEB-INF/tags/rice-portal/iframePortletContainer.tag</include>
                        <include>WEB-INF/tags/rice-portal/immutableBar.tag</include>
                        <include>WEB-INF/tags/rice-portal/maintenanceTab.tag</include>
                        <include>WEB-INF/tags/rice-portal/portalBottom.tag</include>
                        <include>WEB-INF/tags/rice-portal/portalLink.tag</include>
                        <include>WEB-INF/tags/rice-portal/portalTop.tag</include>
                      </includes>
                      <excludes>
                        <exclude>**/.svn</exclude>
                        <exclude>**/.svn/**</exclude>
                      </excludes>
                    </fileset>
                  </filesets>
                </configuration>
              </execution>
              <execution>
                <id>delete-help</id>
                <phase>clean</phase>
                <goals>
                  <goal>clean</goal>
                </goals>
                <configuration>
                  <filesets>
                    <fileset>
                      <directory>src/main/webapp/static</directory>
                      <includes>
                        <include>help/</include>
                      </includes>
                      <excludes>
                        <exclude>**/.svn</exclude>
                        <exclude>**/.svn/**</exclude>
                      </excludes>
                    </fileset>
                  </filesets>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>


</project>