<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.rhq</groupId>
    <artifactId>rhq-parent</artifactId>
    <version>4.2.0</version>
    <relativePath>../../../../pom.xml</relativePath>
  </parent>

  <groupId>org.rhq</groupId>
  <artifactId>rhq-installer</artifactId>
  <packaging>war</packaging>

  <name>RHQ Enterprise Installer War</name>
  <description>The RHQ Enterprise Installer webapp</description>

  <scm>
    <connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/enterprise/gui/installer-war/</connection>
    <developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/enterprise/gui/installer-war/</developerConnection>
  </scm>

  <properties>
    <scm.module.path>modules/enterprise/gui/installer-war/</scm.module.path>
    <war.dir>${basedir}/target/${final.name}</war.dir>

    <!-- plugin versions -->
    <jetty-jspc-maven-plugin.version>7.0.1.v20091125</jetty-jspc-maven-plugin.version>

    <product.shortName>RHQ</product.shortName>
    <product.name>RHQ</product.name>
    <product.fullName>RHQ</product.fullName>
    <product.url.domain>rhq-project.org</product.url.domain>
    <product.sales.email>sales@rhq-project.org</product.sales.email>
    <product.support.email>info@rhq-project.org</product.support.email>
    <product.version>${project.version}</product.version>
    <product.help.doc.root>http://support.rhq-project.org/display/JOPR2/</product.help.doc.root>
    <product.help.installation>Installation</product.help.installation>
    <product.help.guide.server>Running+the+RHQ+Server</product.help.guide.server>
    <product.help.guide.agent>Running+the+RHQ+Agent</product.help.guide.agent>
    <product.help.FAQ>FAQ</product.help.FAQ>
    <product.help.config.props>http://support.rhq-project.org/display/JOPR2/Startup+Properties#ConfiguringtheServer</product.help.config.props>
  </properties>

  <dependencies>

    <dependency>
      <groupId>org.rhq</groupId>
      <artifactId>rhq-core-util</artifactId>
      <version>${project.version}</version>
    </dependency>

    <dependency>
      <groupId>org.rhq</groupId>
      <artifactId>rhq-core-dbutils</artifactId>
      <version>${project.version}</version>
    </dependency>

    <dependency>
      <!-- need this solely for SecurityUtils -->
      <groupId>org.rhq</groupId>
      <artifactId>rhq-enterprise-comm</artifactId>
      <version>${project.version}</version>
    </dependency>

    <dependency>
      <groupId>ant</groupId>
      <artifactId>ant</artifactId>
      <version>1.6.5</version>
    </dependency>

    <dependency>
      <groupId>ant</groupId>
      <artifactId>ant-launcher</artifactId>
      <version>1.6.5</version>
    </dependency>

    <dependency>
      <groupId>i18nlog</groupId>
      <artifactId>i18nlog</artifactId>
    </dependency>

    <dependency>
      <groupId>jboss</groupId>
      <artifactId>jboss-jmx</artifactId>
      <version>${jboss.version}</version>
      <scope>provided</scope> <!-- by JBossAS -->
    </dependency>

    <dependency>
      <groupId>jboss</groupId>
      <artifactId>jboss-system</artifactId>
      <version>${jboss.version}</version>
      <scope>provided</scope> <!-- by JBossAS -->
    </dependency>

    <dependency>
      <groupId>jboss</groupId>
      <artifactId>jbosssx</artifactId>
      <version>4.2.3.GA</version>
      <scope>provided</scope> <!-- by JBossAS -->
    </dependency>

    <dependency>
      <groupId>jboss.jbossas.core-libs</groupId>
      <artifactId>jboss-jca</artifactId>
      <version>4.2.2.GA</version>
      <scope>provided</scope> <!-- by JBossAS -->
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.4</version>
        <scope>provided</scope> <!-- by JBossAS -->
    </dependency>

    <dependency>
      <groupId>javax.faces</groupId>
      <artifactId>jsf-api</artifactId>
      <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
      <scope>provided</scope> <!-- by JBossAS -->
    </dependency>

    <!-- NOTE: The below dep is needed so that the Jetty JSP compiler can find the JSF tld files. -->
    <dependency>
      <groupId>javax.faces</groupId>
      <artifactId>jsf-impl</artifactId>
      <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
      <scope>provided</scope> <!-- by JBossAS -->
    </dependency>

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

  </dependencies>

  <build>
    <finalName>rhq-installer</finalName>

    <plugins>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <systemPropertyVariables>
            <rhq.test.ds.type-mapping>${rhq.test.ds.type-mapping}</rhq.test.ds.type-mapping>
            <rhq.test.ds.server-name>${rhq.test.ds.server-name}</rhq.test.ds.server-name>
            <rhq.test.ds.db-name>${rhq.test.ds.db-name}</rhq.test.ds.db-name>
            <rhq.test.ds.connection-url>${rhq.test.ds.connection-url}</rhq.test.ds.connection-url>
            <rhq.db.admin.username>${rhq.db.admin.username}</rhq.db.admin.username>
            <rhq.db.admin.password>${rhq.db.admin.password}</rhq.db.admin.password>
            <rhq.test.ds.user-name>${rhq.test.ds.user-name}</rhq.test.ds.user-name>
            <rhq.test.ds.password>${rhq.test.ds.password}</rhq.test.ds.password>
          </systemPropertyVariables>
        </configuration>
      </plugin>

      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <webResources>
            <resource>
              <filtering>true</filtering>
              <directory>${basedir}/src/main/webapp</directory>
              <includes>
                <include>**/*.properties</include>
              </includes>
            </resource>
            <resource>
                <filtering>true</filtering>
                <directory>${basedir}/target/resources</directory>
                <includes>
                  <include>**/*.properties</include>
                </includes>
            </resource>
          </webResources>
        </configuration>
      </plugin>

      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>Generate I18N Resource Bundles</id>
            <phase>process-classes</phase>
            <configuration>
              <tasks>
                <!-- generate the I18N resource bundles -->
                <taskdef name="i18n" classpathref="maven.runtime.classpath" classname="mazz.i18n.ant.I18NAntTask" />
                <!--<i18n outputdir="${project.build.outputDirectory}" defaultlocale="en" verbose="false" append="false" verify="true">-->
                <i18n outputdir="${basedir}/target/resources/WEB-INF/classes" defaultlocale="en" verbose="${i18nlog.verbose}" append="false" verify="true">
                  <classpath refid="maven.runtime.classpath" />
                  <classfileset dir="${project.build.outputDirectory}">
                    <include name="**/*I18NResourceKeys.class" />
                  </classfileset>
                </i18n>
                <copy todir="${project.build.outputDirectory}" encoding="${project.build.sourceEncoding}" outputencoding="${project.build.sourceEncoding}">
                  <fileset dir="${basedir}/target/resources/WEB-INF/classes">
                    <include name="InstallerMessages*.properties" />
                  </fileset>
                  <mapper type="glob" from="*" to="*.unfiltered" />
                </copy>
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-resources</id>
            <!-- here the phase you need -->
            <phase>validate</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.outputDirectory}</outputDirectory>
              <resources>
                <resource>
                  <directory>src/main/resources</directory>
                  <filtering>true</filtering>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>

    </plugins>

  </build>

  <profiles>

      <profile>
         <id>dev</id>

         <properties>
            <rhq.rootDir>../../../..</rhq.rootDir>
            <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
            <rhq.deploymentName>${project.build.finalName}.war</rhq.deploymentName>
            <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.deploymentName}</rhq.deploymentDir>
         </properties>

         <build>
            <plugins>

               <plugin>
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>

                     <execution>
                        <id>deploy-classes</id>
                        <phase>compile</phase>
                        <configuration>
                          <tasks>
                            <property name="classes.dir" location="${rhq.deploymentDir}/WEB-INF/classes" />
                            <echo>*** Copying updated files from target/classes to ${classes.dir}...</echo>
                            <copy todir="${classes.dir}" verbose="${rhq.verbose}">
                               <fileset dir="target/classes" />
                            </copy>
                          </tasks>
                        </configuration>
                        <goals>
                          <goal>run</goal>
                        </goals>
                     </execution>

                     <execution>
                        <id>deploy</id>
                        <phase>package</phase>
                        <configuration>
                          <tasks>
                            <property name="deployment.dir" location="${rhq.deploymentDir}" />
                            <echo>*** Copying updated files from target${file.separator}${project.build.finalName}${file.separator} to ${deployment.dir}${file.separator}...</echo>
                            <copy todir="${deployment.dir}" verbose="${rhq.verbose}">
                               <fileset dir="${basedir}/target/${project.build.finalName}" />
                            </copy>
                            <delete dir="${deployment.dir}.rej" /> <!-- need to remove any residual backups -->
                          </tasks>
                        </configuration>
                        <goals>
                          <goal>run</goal>
                        </goals>
                     </execution>

                     <execution>
                        <id>undeploy</id>
                        <phase>clean</phase>
                        <configuration>
                          <tasks>
                            <property name="deployment.dir" location="${rhq.deploymentDir}" />
                            <echo>*** Deleting ${deployment.dir}${file.separator}...</echo>
                            <delete dir="${deployment.dir}" />
                          </tasks>
                        </configuration>
                        <goals>
                          <goal>run</goal>
                        </goals>
                     </execution>

                  </executions>
               </plugin>

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

      <profile>
         <id>dist</id>

         <build>
            <plugins>
               <plugin>
                  <!-- See http://jetty.mortbay.org/jspc-maven-plugin/ -->
                  <groupId>org.mortbay.jetty</groupId>
                  <artifactId>jetty-jspc-maven-plugin</artifactId>
                  <version>${jetty-jspc-maven-plugin.version}</version>
                  <configuration>
                     <keepSources>false</keepSources>
                     <validateXml>false</validateXml>
                     <generatedClasses>${project.build.outputDirectory}</generatedClasses>
                  </configuration>
                  <executions>
                     <execution><goals><goal>jspc</goal></goals></execution>
                  </executions>
               </plugin>

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

      <profile>
         <id>oracle</id>
         <activation>
           <property>
             <name>rhq.test.db.type</name>
             <value>oracle</value>
           </property>
         </activation>
         <build>
            <plugins>
               <plugin>
                  <artifactId>maven-surefire-plugin</artifactId>
                     <configuration>
                        <excludes>
                           <exclude>**/DBInstallatonTest.java</exclude>
                        </excludes>
                     </configuration>
               </plugin>
            </plugins>
         </build>
      </profile>
   </profiles>
</project>

