<!--
  JBoss, Home of Professional Open Source
  Copyright 2013, Red Hat, Inc. and individual contributors
  by the @authors tag. See the copyright.txt in the distribution for a
  full listing of individual contributors.

  This is free software; you can redistribute it and/or modify it
  under the terms of the GNU Lesser General Public License as
  published by the Free Software Foundation; either version 2.1 of
  the License, or (at your option) any later version.

  This software is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this software; if not, write to the Free
  Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  02110-1301 USA, or see the FSF site: http://www.fsf.org.
  -->
<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>org.richfaces</groupId>
        <artifactId>richfaces-parent</artifactId>
        <version>5.0.0.Alpha1</version>
    </parent>

    <artifactId>richfaces</artifactId>
    <name>RichFaces Framework</name>

    <description>
        The RichFaces Framework and Component Suite.
        
        Contains all project specific sources.
    </description>

    <properties>
        <version.richfaces>5.0.0.Alpha1</version.richfaces>
        
        <optimized.resources.directory>${project.build.outputDirectory}/META-INF/resources/org.richfaces.optimized/${version.richfaces}</optimized.resources.directory>
        <optimized.resources.prefix>org.richfaces.optimized/${version.richfaces}</optimized.resources.prefix>
        <optimized.resources.mapping>${project.build.outputDirectory}/META-INF/richfaces/optimizedResourcesMapping</optimized.resources.mapping>
        <optimized.resources.skins>blueSky,classic,deepMarine,emeraldTown,japanCherry,ruby,wine,DEFAULT,NULL</optimized.resources.skins>
    </properties>

    <dependencies>

        <!-- Java EE Web Profile -->
        <dependency>
            <groupId>org.jboss.spec</groupId>
            <artifactId>jboss-javaee-6.0</artifactId>
            <type>pom</type>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.jboss.spec.javax.faces</groupId>
                    <artifactId>jboss-jsf-api_2.1_spec</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        
        <!-- CDK -->
        <dependency>
            <groupId>org.richfaces.cdk</groupId>
            <artifactId>annotations</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Runtime Dependencies -->
        <dependency>
            <groupId>net.sourceforge.cssparser</groupId>
            <artifactId>cssparser</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>

        <!-- Push dependencies -->
        <dependency>
            <groupId>org.atmosphere</groupId>
            <artifactId>atmosphere-runtime</artifactId>
            <optional>true</optional>
        </dependency>

        <!-- Optional dependencies -->
        <dependency>
            <groupId>org.jboss.cache</groupId>
            <artifactId>jbosscache-core</artifactId>
            <optional>true</optional>
            <exclusions>
                <exclusion>
                    <artifactId>jboss-logging-spi</artifactId>
                    <groupId>org.jboss.logging</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>net.sf.ehcache</groupId>
            <artifactId>ehcache</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>opensymphony</groupId>
            <artifactId>oscache</artifactId>
            <optional>true</optional>
        </dependency>
        
        <!-- For MyFaces specific resource loading (RF-11974) -->
        <dependency>
            <groupId>org.apache.myfaces.core</groupId>
            <artifactId>myfaces-impl</artifactId>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.myfaces.core</groupId>
                    <artifactId>myfaces-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Test Dependencies -->
        <dependency>
            <groupId>org.jboss.test-jsf</groupId>
            <artifactId>htmlunit-client</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>javax.servlet</groupId>
                    <artifactId>javax.servlet-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.jboss.test-jsf</groupId>
            <artifactId>jsf-mock</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.test-jsf</groupId>
            <artifactId>jsf-mockito</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.test-jsf</groupId>
            <artifactId>jsf-test-scriptunit</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.easymock</groupId>
            <artifactId>easymock</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.easymock</groupId>
            <artifactId>easymockclassextension</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>xmlunit</groupId>
            <artifactId>xmlunit</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- tests -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <scope>test</scope>
        </dependency>
        
        <!-- Resource Optimizer -->
        <dependency>
            <groupId>org.reflections</groupId>
            <artifactId>reflections</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>com.google.collections</groupId>
                    <artifactId>google-collections</artifactId>
                </exclusion>
            </exclusions>
            <scope>compile</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.yahoo.platform.yui</groupId>
            <artifactId>yuicompressor</artifactId>
            <scope>compile</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.beust</groupId>
            <artifactId>jcommander</artifactId>
            <scope>compile</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.jboss.el</groupId>
            <artifactId>jboss-el</artifactId>
            <scope>compile</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.richfaces</groupId>
            <artifactId>richfaces-build-resources</artifactId>
            <scope>compile</scope>
            <optional>true</optional>
        </dependency>

    </dependencies>

    <build>

        <finalName>richfaces</finalName>

        <plugins>
            <plugin>
                <artifactId>maven-checkstyle-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>buildnumber-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>create</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <doCheck>false</doCheck>
                    <doUpdate>false</doUpdate>
                    <revisionOnScmFailure>unknown</revisionOnScmFailure>
                    <timestampFormat>{0,date,MM/dd/yyyy h:mm:ss a}</timestampFormat>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-source</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>src/main/config</source>
                                <source>src/main/resource-optimizer</source>
                                <source>target/generated-sources/main/java</source>
                                <source>target/generated-sources/main/resources</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

        </plugins>

    </build>

    <profiles>
        <profile>
            <id>generate-cdk-and-resource</id>
            <activation>
                <property>
                    <name>!generation.skip</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>precompile-sources-for-cdk</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>compile</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.richfaces.cdk</groupId>
                        <artifactId>richfaces-cdk-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>cdk-generate-sources</id>
                                <phase>process-sources</phase>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <charset>UTF-8</charset>
                            <locale>en</locale>
                            <templates>
                                <fileSet>
                                    <directory>src/main/java</directory>
                                    <includes>
                                        <include>**/*.template.xml</include>
                                    </includes>
                                </fileSet>
                            </templates>
                        </configuration>
                        <dependencies>
                            <dependency>
                                <groupId>org.jboss.spec</groupId>
                                <artifactId>jboss-javaee-6.0</artifactId>
                                <version>${version.jboss-javaee}</version>
                                <type>pom</type>
                            </dependency>
                            <dependency>
                                <groupId>org.richfaces</groupId>
                                <artifactId>richfaces-build-resources</artifactId>
                                <version>${version.richfaces}</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                </plugins>
            </build>
        </profile>
        
        <profile>
            <id>generate-optimized-resources</id>
            <activation>
                <property>
                    <name>!optimization.skip</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.2.1</version>
                        <configuration>
                            <mainClass>org.richfaces.resource.optimizer.GenerateResourcesMain</mainClass>
                        </configuration>
                        <executions>
                            <!-- Static -->
                            <execution>
                                <id>static-resources</id>
                                <phase>process-classes</phase>
                                <goals>
                                    <goal>java</goal>
                                </goals>
                                <configuration>
                                    <arguments>
                                        <argument>--classpathDir</argument>
                                        <argument>${project.build.outputDirectory}</argument>
                                        <argument>--output</argument>
                                        <argument>${optimized.resources.directory}/Static/</argument>
                                        <argument>--prefix</argument>
                                        <argument>${optimized.resources.prefix}/Static/</argument>
                                        <argument>--mapping</argument>
                                        <argument>${optimized.resources.mapping}/Static.properties</argument>
                                        <argument>--skins</argument>
                                        <argument>${optimized.resources.skins}</argument>
                                        <argument>--excludeFile</argument>
                                        <argument>^javax.faces</argument>
                                        <argument>--excludeFile</argument>
                                        <argument>^org.richfaces.ui.images.*</argument>
                                        <argument>--excludeFile</argument>
                                        <argument>^org.richfaces.ui.iconimages.*</argument>
                                        <argument>--excludeFile</argument>
                                        <argument>^org.richfaces.optimized.*</argument>
                                        <argument>--excludeFile</argument>
                                        <argument>^org.richfaces.ckeditor.*</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                            <!-- Compressed -->
                            <execution>
                                <id>compressed-resources</id>
                                <phase>process-classes</phase>
                                <goals>
                                    <goal>java</goal>
                                </goals>
                                <configuration>
                                    <arguments>
                                        <argument>--classpathDir</argument>
                                        <argument>${project.build.outputDirectory}</argument>
                                        <argument>--output</argument>
                                        <argument>${optimized.resources.directory}/Compressed/</argument>
                                        <argument>--prefix</argument>
                                        <argument>${optimized.resources.prefix}/Compressed/</argument>
                                        <argument>--mapping</argument>
                                        <argument>${optimized.resources.mapping}/Compressed.properties</argument>
                                        <argument>--skins</argument>
                                        <argument>${optimized.resources.skins}</argument>
                                        <argument>--excludeFile</argument>
                                        <argument>^javax.faces</argument>
                                        <argument>--excludeFile</argument>
                                        <argument>^org.richfaces.ui.images.*</argument>
                                        <argument>--excludeFile</argument>
                                        <argument>^org.richfaces.ui.iconimages.*</argument>
                                        <argument>--excludeFile</argument>
                                        <argument>^org.richfaces.optimized.*</argument>
                                        <argument>--excludeFile</argument>
                                        <argument>^org.richfaces.ckeditor.*</argument>
                                        <argument>--compress</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                            <!-- Packed -->
                            <execution>
                                <id>packed-resources</id>
                                <phase>process-classes</phase>
                                <goals>
                                    <goal>java</goal>
                                </goals>
                                <configuration>
                                    <arguments>
                                        <argument>--classpathDir</argument>
                                        <argument>${project.build.outputDirectory}</argument>
                                        <argument>--output</argument>
                                        <argument>${optimized.resources.directory}/Packed/</argument>
                                        <argument>--prefix</argument>
                                        <argument>${optimized.resources.prefix}/Packed/</argument>
                                        <argument>--mapping</argument>
                                        <argument>${optimized.resources.mapping}/Packed.properties</argument>
                                        <argument>--skins</argument>
                                        <argument>${optimized.resources.skins}</argument>
                                        <argument>--excludeFile</argument>
                                        <argument>^javax.faces</argument>
                                        <argument>--excludeFile</argument>
                                        <argument>^org.richfaces.ui.images.*</argument>
                                        <argument>--excludeFile</argument>
                                        <argument>^org.richfaces.ui.iconimages.*</argument>
                                        <argument>--excludeFile</argument>
                                        <argument>^org.richfaces.optimized.*</argument>
                                        <argument>--excludeFile</argument>
                                        <argument>^org.richfaces.ckeditor.*</argument>
                                        <argument>--excludeFile</argument>
                                        <argument>^jquery.js$</argument>
                                        <argument>--pack</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>resources-excluded-from-packaging</id>
                                <phase>process-classes</phase>
                                <goals>
                                    <goal>java</goal>
                                </goals>
                                <configuration>
                                    <arguments>
                                        <argument>--classpathDir</argument>
                                        <argument>${project.build.outputDirectory}</argument>
                                        <argument>--output</argument>
                                        <argument>${optimized.resources.directory}/Packed/</argument>
                                        <argument>--prefix</argument>
                                        <argument>${optimized.resources.prefix}/Packed/</argument>
                                        <argument>--mapping</argument>
                                        <argument>${optimized.resources.mapping}/Packed.properties</argument>
                                        <argument>--skins</argument>
                                        <argument>${optimized.resources.skins}</argument>
                                        <argument>--includeFile</argument>
                                        <argument>^jquery.js$</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                            <!-- PackedCompressed -->
                            <execution>
                                <id>packed-compressed-resources</id>
                                <phase>process-classes</phase>
                                <goals>
                                    <goal>java</goal>
                                </goals>
                                <configuration>
                                    <arguments>
                                        <argument>--classpathDir</argument>
                                        <argument>${project.build.outputDirectory}</argument>
                                        <argument>--output</argument>
                                        <argument>${optimized.resources.directory}/PackedCompressed/</argument>
                                        <argument>--prefix</argument>
                                        <argument>${optimized.resources.prefix}/PackedCompressed/</argument>
                                        <argument>--mapping</argument>
                                        <argument>${optimized.resources.mapping}/PackedCompressed.properties</argument>
                                        <argument>--skins</argument>
                                        <argument>${optimized.resources.skins}</argument>
                                        <argument>--excludeFile</argument>
                                        <argument>^javax.faces</argument>
                                        <argument>--excludeFile</argument>
                                        <argument>^org.richfaces.ui.images.*</argument>
                                        <argument>--excludeFile</argument>
                                        <argument>^org.richfaces.ui.iconimages.*</argument>
                                        <argument>--excludeFile</argument>
                                        <argument>^org.richfaces.optimized.*</argument>
                                        <argument>--excludeFile</argument>
                                        <argument>^org.richfaces.ckeditor.*</argument>
                                        <argument>--excludeFile</argument>
                                        <argument>^jquery.js$</argument>
                                        <argument>--pack</argument>
                                        <argument>--compress</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>compressed-resources-excluded-from-packaging</id>
                                <phase>process-classes</phase>
                                <goals>
                                    <goal>java</goal>
                                </goals>
                                <configuration>
                                    <arguments>
                                        <argument>--classpathDir</argument>
                                        <argument>${project.build.outputDirectory}</argument>
                                        <argument>--output</argument>
                                        <argument>${optimized.resources.directory}/PackedCompressed/</argument>
                                        <argument>--prefix</argument>
                                        <argument>${optimized.resources.prefix}/PackedCompressed/</argument>
                                        <argument>--mapping</argument>
                                        <argument>${optimized.resources.mapping}/PackedCompressed.properties</argument>
                                        <argument>--skins</argument>
                                        <argument>blueSky,classic,deepMarine,emeraldTown,japanCherry,ruby,wine,DEFAULT,NULL</argument>
                                        <argument>--includeFile</argument>
                                        <argument>^jquery.js$</argument>
                                        <argument>--compress</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>jsf_ri</id>
            <activation>
                <property>
                    <name>!jsf_profile</name>
                </property>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.glassfish</groupId>
                    <artifactId>javax.faces</artifactId>
                    <scope>compile</scope>
                    <optional>true</optional>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>jsf_jboss</id>
            <activation>
                <property>
                    <name>jsf_profile</name>
                    <value>jboss</value>
                </property>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.jboss.spec.javax.faces</groupId>
                    <artifactId>jboss-jsf-api_2.1_spec</artifactId>
                    <scope>compile</scope>
                    <optional>true</optional>
                </dependency>
                <dependency>
                    <groupId>com.sun.faces</groupId>
                    <artifactId>jsf-impl</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>myfaces</id>
            <activation>
                <property>
                    <name>jsf_profile</name>
                    <value>myfaces</value>
                </property>
            </activation>
            <properties>
                <arquillian.richfaces.jsfProvider>myfaces</arquillian.richfaces.jsfProvider>
                <arquillian.richfaces.jsfImplementation>org.apache.myfaces.core:myfaces-impl</arquillian.richfaces.jsfImplementation>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.apache.myfaces.core</groupId>
                    <artifactId>myfaces-api</artifactId>
                    <scope>compile</scope>
                    <optional>true</optional>
                </dependency>
                <dependency>
                    <groupId>org.apache.myfaces.core</groupId>
                    <artifactId>myfaces-impl</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>

        <!-- Release -->
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <!-- JavaDoc -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>generate-javadoc</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- VDL DOC -->
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.2.1</version>
                        <executions>
                            <execution>
                                <id>generate-vdldoc</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <executable>java</executable>
                            <arguments>
                                <argument>-jar</argument>
                                <argument>${basedir}/src/main/vdldoc/vdldoc-1.0.jar</argument>
                                <argument>-d</argument>
                                <argument>${project.build.directory}/vdldoc</argument>
                                <argument>-windowtitle</argument>
                                <argument>RichFaces ${version.richfaces} VDL Documentation</argument>
                                <argument>-doctitle</argument>
                                <argument>RichFaces ${version.richfaces} VDL Documentation</argument>
                                <argument>${project.build.directory}/generated-sources/main/resources/META-INF/r.taglib.xml</argument>
                            </arguments>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>make-assembly</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <configuration>
                                    <descriptors>
                                        <descriptor>src/main/vdldoc/assembler-vdldoc.xml</descriptor>
                                    </descriptors>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- JSDoc -->
                    <plugin>
                        <groupId>gr.abiss.mvn.plugins</groupId>
                        <artifactId>maven-jstools-plugin</artifactId>
                        <version>0.7</version>
                        <executions>
                            <execution>
                                <id>jsdoc</id>
                                <configuration>
                                    <jsDir>${basedir}/src/main/resources/META-INF/resources</jsDir>
                                    <includes>**/*.js</includes>
                                    <caseSensitive>true</caseSensitive>
                                </configuration>
                                <goals>
                                    <goal>jsdoc</goal>
                                </goals>
                                <phase>process-sources</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-jar-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>pack-jsodcs</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <configuration>
                                    <classesDirectory>target/site/jsdoc</classesDirectory>
                                    <classifier>jsdoc</classifier>
                                    <excludes>
                                        <exclude>**/symbols/src/*</exclude>
                                    </excludes>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
