<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2012 JBoss Inc
  ~
  ~ Licensed 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.
  -->

<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.jboss.dashboard-builder</groupId>
        <artifactId>modules</artifactId>
        <version>6.2.0.Beta2</version>
    </parent>

    <artifactId>dashboard-showcase</artifactId>
    <packaging>war</packaging>
    <name>Dashboard Builder Showcase Web App</name>
    <description>Dashboard Builder web application containing some sample dashboards</description>

    <dependencies>
        <dependency>
            <groupId>org.jboss.dashboard-builder</groupId>
            <artifactId>dashboard-webapp</artifactId>
            <type>war</type>
        </dependency>
        <dependency>
            <groupId>org.jboss.dashboard-builder</groupId>
            <artifactId>dashboard-samples</artifactId>
            <type>war</type>
        </dependency>
    </dependencies>

    <build>
        <finalName>dashboard-showcase</finalName>

        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <!-- the overlays configuration lets establish the order to copy the resources to the main web application
                        the criteria is "the first win", it means that when a given resource already exists in the destination
                        application it will not be overwritten -->
                    <overlays>

                        <overlay>
                            <!-- empty groupId/artifactId represents the current build -->
                            <!-- this empty overlay also let us define the order to copy current web application resources -->
                            <!-- in this case the current web application resources will be copied first -->
                            <!-- if this empty overlay is omitted current web application resources will be copied first by default -->
                        </overlay>
                        <overlay>
                            <groupId>org.jboss.dashboard-builder</groupId>
                            <artifactId>dashboard-samples</artifactId>
                        </overlay>
                        <overlay>
                            <groupId>org.jboss.dashboard-builder</groupId>
                            <artifactId>dashboard-webapp</artifactId>
                        </overlay>

                    </overlays>

                </configuration>
            </plugin>
        </plugins>

        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>

    </build>

    <profiles>
        <!-- profiles below are intended for development purposes -->

        <profile>
            <id>postgres</id>
            <dependencies>
                <dependency>
                    <groupId>postgresql</groupId>
                    <artifactId>postgresql</artifactId>
                    <scope>compile</scope>
                </dependency>
            </dependencies>
            <properties>
                <db.driverClass>org.jboss.dashboard.database.NonPooledDataSource</db.driverClass>
                <db.url>jdbc:postgresql://localhost:5432/dashbuilder</db.url>
                <db.user>dashbuilder</db.user>
                <db.password>dashbuilder</db.password>
                <db.driver>org.postgresql.Driver</db.driver>
                <db.hibernate.use_second_level_cache>false</db.hibernate.use_second_level_cache>
                <db.isolation>2</db.isolation>
            </properties>
        </profile>

        <profile>
            <id>h2</id>
            <dependencies>
                <dependency>
                    <groupId>com.h2database</groupId>
                    <artifactId>h2</artifactId>
                    <scope>compile</scope>
                </dependency>
            </dependencies>
            <properties>
                <db.driverClass>org.jboss.dashboard.database.NonPooledDataSource</db.driverClass>
                <db.url>jdbc:h2:~/dashbuilder</db.url>
                <db.user>dashbuilder</db.user>
                <db.password>dashbuilder</db.password>
                <db.driver>org.h2.Driver</db.driver>
                <db.isolation>2</db.isolation>
                <db.hibernate.use_second_level_cache>false</db.hibernate.use_second_level_cache>
            </properties>
        </profile>

        <profile>
            <id>oracle</id>
            <dependencies>
                <dependency>
                    <groupId>com.oracle</groupId>
                    <artifactId>ojdbc14</artifactId>
                </dependency>
            </dependencies>
            <properties>
                <db.driverClass>org.jboss.dashboard.database.NonPooledDataSource</db.driverClass>
                <db.url>jdbc:oracle:thin:@localhost:1521:orcl</db.url>
                <db.user>dashbuilder</db.user>
                <db.password>dashbuilder</db.password>
                <db.hibernate.use_second_level_cache>true</db.hibernate.use_second_level_cache>
                <db.driver>oracle.jdbc.driver.OracleDriver</db.driver>
                <db.isolation>2</db.isolation>
            </properties>
        </profile>

        <profile>
            <id>mysql</id>
            <dependencies>
                <dependency>
                    <groupId>mysql</groupId>
                    <artifactId>mysql-connector-java</artifactId>
                </dependency>
            </dependencies>
            <properties>
                <db.driverClass>org.jboss.dashboard.database.NonPooledDataSource</db.driverClass>
                <db.url>jdbc:mysql://localhost:3306/dashbuilder</db.url>
                <db.user>dashbuilder</db.user>
                <db.password>dashbuilder</db.password>
                <db.hibernate.use_second_level_cache>true</db.hibernate.use_second_level_cache>
                <db.driver>com.mysql.jdbc.Driver</db.driver>
                <db.isolation>2</db.isolation>
            </properties>
        </profile>

        <!-- NOTE that IBM DB2 JDBC driver is not present in public maven repositories due to copyright issues. -->
        <profile>
            <id>db2</id>
            <properties>
                <db.driverClass>org.jboss.dashboard.database.NonPooledDataSource</db.driverClass>
                <db.url>jdbc:db2://localhost:50000/dashb</db.url>
                <db.user>dashbuilder</db.user>
                <db.password>dashbuilder</db.password>
                <db.hibernate.use_second_level_cache>true</db.hibernate.use_second_level_cache>
                <db.driver>com.ibm.db2.jcc.DB2Driver</db.driver>
                <db.isolation>2</db.isolation>
            </properties>
            <!--
            In order to use the DB2 profile, as DB2 driver is IBM proprietary and not available in public repositories,
            uou must download it, put the jar in "lib" directory and enable this profile dependency and build.
            @See lib/.readme

            <dependencies>
                <dependency>
                    <groupId>com.ibm</groupId>
                    <artifactId>db2</artifactId>
                    <version>9.7</version>
                    <scope>system</scope>
                    <systemPath>${basedir}/lib/db2jcc.jar</systemPath>
                </dependency>
            </dependencies>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-war-plugin</artifactId>
                        <configuration>
                            <webResources combine.children="append">
                                <resource>
                                    <directory>${basedir}/lib/</directory>
                                    <includes>
                                        <include>db2jcc.jar</include>
                                    </includes>
                                    <targetPath>WEB-INF/lib</targetPath>
                                </resource>
                            </webResources>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            -->
        </profile>

        <profile>
            <id>sqlserver</id>
            <dependencies>
                <dependency>
                    <groupId>org.tranql</groupId>
                    <artifactId>tranql-connector-sqlserver2005</artifactId>
                </dependency>
            </dependencies>
            <properties>
                <db.driverClass>org.jboss.dashboard.database.NonPooledDataSource</db.driverClass>
                <db.url>jdbc:sqlserver://localhost:1433;DatabaseName=dashbuilder</db.url>
                <db.user>dashbuilder</db.user>
                <db.password>dashbuilder</db.password>
                <db.hibernate.use_second_level_cache>true</db.hibernate.use_second_level_cache>
                <db.driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</db.driver>
                <db.isolation>2</db.isolation>
            </properties>
        </profile>

        <profile>
            <id>jetty</id>

            <dependencies>
                <dependency>
                    <groupId>ch.qos.logback</groupId>
                    <artifactId>logback-classic</artifactId>
                </dependency>
                <dependency>
                    <groupId>ch.qos.logback</groupId>
                    <artifactId>logback-core</artifactId>
                </dependency>
                <dependency>
                    <groupId>org.jboss.weld</groupId>
                    <artifactId>weld-spi</artifactId>
                </dependency>
                <dependency>
                    <groupId>org.jboss.weld</groupId>
                    <artifactId>weld-core</artifactId>
                </dependency>
                <dependency>
                    <groupId>org.jboss.weld.se</groupId>
                    <artifactId>weld-se-core</artifactId>
                </dependency>
                <dependency>
                    <groupId>org.jboss.weld.servlet</groupId>
                    <artifactId>weld-servlet-core</artifactId>
                </dependency>

                <!-- The following deps are required in order to enable the CDI injection in servlets. If not the following error is thrown: -->
                <!-- SEVERE: Unable to create JettyWeldInjector. CDI injection will not be available in Servlets, Filters or Listeners       -->
                <!--java.lang.IllegalArgumentException: Cannot load class for org.jboss.weld.environment.jetty.WeldDecorator                 -->

                <dependency>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-server</artifactId>
                    <exclusions>
                        <exclusion>
                            <groupId>org.eclipse.jetty</groupId>
                            <artifactId>jetty-continuation</artifactId>
                        </exclusion>
                        <exclusion>
                            <groupId>org.eclipse.jetty</groupId>
                            <artifactId>jetty-http</artifactId>
                        </exclusion>
                        <exclusion>
                            <groupId>org.eclipse.jetty</groupId>
                            <artifactId>jetty-io</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>

                <dependency>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-servlet</artifactId>
                    <exclusions>
                        <exclusion>
                            <groupId>org.eclipse.jetty</groupId>
                            <artifactId>jetty-security</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>

                <dependency>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-util</artifactId>
                </dependency>
            </dependencies>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.mortbay.jetty</groupId>
                        <artifactId>jetty-maven-plugin</artifactId>
                        <version>${version.org.eclipse.jetty}</version>
                        <configuration>
                            <scanIntervalSeconds>3</scanIntervalSeconds>
                            <stopPort>9966</stopPort>
                            <stopKey>stop</stopKey>
                            <webApp>
                                <contextPath>/</contextPath>
                                <jettyEnvXml>${project.build.directory}/dashboard-showcase/WEB-INF/jetty-env.xml</jettyEnvXml>
                                <descriptor>${project.build.directory}/dashboard-showcase/WEB-INF/web.xml</descriptor>
                                <resourceBases>
                                    <resourcesAsCSV>${project.basedir}/src/main/webapp</resourcesAsCSV>
                                    <resourcesAsCSV>${project.basedir}/target/dashboard-showcase</resourcesAsCSV>
                                </resourceBases>
                            </webApp>
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-war-plugin</artifactId>
                        <configuration>
                            <webResources>
                                <resource>
                                    <filtering>true</filtering>
                                    <directory>src/test/resources/config</directory>
                                    <includes>
                                        <include>**/*</include>
                                    </includes>
                                </resource>
                                <resource>
                                    <directory>${basedir}/src/main/webapp/WEB-INF</directory>
                                    <filtering>true</filtering>
                                    <targetPath>WEB-INF</targetPath>
                                    <includes>
                                        <include>**/web.xml</include>
                                    </includes>
                                </resource>
                            </webResources>
                        </configuration>
                    </plugin>

                </plugins>
            </build>
        </profile>

    </profiles>

</project>
