<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-coregui</artifactId>
    <packaging>war</packaging>

    <name>RHQ Enterprise Core GUI</name>
    <description>the RHQ Enterprise Core GUI webapp</description>

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


    <properties>
        <!-- dependency versions -->
        <gwt.version>2.0.4</gwt.version>
        <smartgwt.version>2.4</smartgwt.version>

        <!--  If this is too much memory to allocate to your gwt:debug process then override this property in
              in your settings.xml -->
        <gwt-plugin.extraJvmArgs>-Xms512M -Xmx512M -XX:PermSize=128M -XX:MaxPermSize=256M</gwt-plugin.extraJvmArgs>
        <gwt-plugin.localWorkers>2</gwt-plugin.localWorkers>
        
        <coreGuiParams />
        <coreGuiRunTarget>'http://localhost:7080/coregui/CoreGUI.html${coreGuiParams}'</coreGuiRunTarget>

        <!--
         This property is substituted, by the resource plugin during the resources phase, as the
         value of the user.agent property in RHQDomain.gwt.xml and CoreGUI.gwt.xml. The default
         value results in these GWT modules being compiled into JavaScript for all supported
         browsers. To speed up compile time by only compiling for your preferred browser(s),
         specify the gwt.userAgent property on the mvn command line (e.g. -Dgwt.userAgent=gecko1_8)
         or in your ~/.m2/settings.xml

         As of GWT 2.0.4, the recognized agents (defined in
         gwt-user.jar:com/google/gwt/user/UserAgent.gwt.xml) are as follows:

           ie6: IE6/IE7
           ie8: IE8 and later
           gecko: FF1 (NOTE: Support for this was dropped in GWT 2.1.)
           gecko1_8: FF2 and later
           safari: Safari/Chrome
           opera: Opera

         *NOTE*: Since we specify the meta "X-UA-Compatible: IE=EmulateIE7" HTTP header in CoreGUI.html, IE8 and later
                 will emulate IE7, and so in order to run on IE8 and later, "ie6" must be specified, rather than "ie8".

         Multiple agents can be specified as a comma-delimited list, as demonstrated by the default
         value below.
        -->
        <gwt.userAgent>ie6,ie8,gecko1_8,safari,opera</gwt.userAgent>

        <!-- Change this to "true" via the mvn command line or your ~/.m2/settings.xml to speed 
             up gwt compilation. -->
        <gwt.draftCompile>false</gwt.draftCompile>
        
        <!-- Comma-separated list of the locales that should be included during GWT compilation. The specified locales
             should each have two corresponding message bundle properties files under
             src/main/resources/org/rhq/enterprise/gui/coregui/client/. For example, the "ja" locale has
             Messages_ja.properties and MessageConstants_ja.properties. -->
        <gwt.locale>en,de,ja,pt,zh</gwt.locale>
    </properties>


    <dependencies>

        <!-- ============= Internal Deps ============= -->

        <dependency>
            <groupId>org.rhq</groupId>
            <artifactId>rhq-core-domain</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
            <!-- by rhq.ear (as ejb-jar) -->
        </dependency>

        <dependency>
            <groupId>org.rhq</groupId>
            <artifactId>rhq-enterprise-server</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
            <!-- by rhq.ear (as ejb-jar) -->
        </dependency>

        <dependency>
            <groupId>org.rhq</groupId>
            <artifactId>rhq-core-util</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
            <!-- by rhq.ear -->
        </dependency>

        
        <!-- =============== 3rd Party Deps =============== -->

        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <version>${gwt.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>${gwt.version}</version>
            <scope>provided</scope>
        </dependency>
        <!-- This is so we can compile custom GWT Generators to be called during gwt compilation.
             Is is not needed at runtime and so is not included in the WAR. -->
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-dev</artifactId>
            <version>${gwt.version}</version>
            <scope>provided</scope>
        </dependency>

        <!--<dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-incubator</artifactId>
            <scope>provided</scope>
            <version>2.0</version>
        </dependency>-->

        <dependency>
            <groupId>com.smartgwt</groupId>
            <artifactId>smartgwt</artifactId>
            <version>${smartgwt.version}</version>
        </dependency>
        <!--
        <dependency>
            <groupId>com.smartgwt</groupId>
            <artifactId>smartgwt-skins</artifactId>
            <version>${smartgwt.version}</version>
        </dependency>
        -->

        <!-- the GWT graphing library (note, this provides jquery 1.3.2. If we get rid of GFlot we will need
             to provide jquery explcitly for jquery.sparkline support. See CoreGUI.gwt.xml for the jquery.sparkline
             declaration and coregui/webapp/js for the lib inclusion.) -->
        <dependency>
            <groupId>ca.nanometrics</groupId>
            <artifactId>gflot</artifactId>
            <version>1.0.0</version>
        </dependency>

        <dependency>
            <groupId>com.google.code.gwt-log</groupId>
            <artifactId>gwt-log</artifactId>
            <version>3.0.4</version>
        </dependency>

        <!-- for file uploads -->
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.2</version>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>1.3.1</version>
        </dependency>

        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.0.4</version>
            <scope>provided</scope>
            <!-- by JBossAS -->
        </dependency>

        <dependency>
            <groupId>org.opensymphony.quartz</groupId>
            <artifactId>quartz</artifactId>
            <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
            <scope>provided</scope>
            <!-- by JBossAS itself, which the container buildNodes has packaged with 1.6.5 -->
        </dependency>

        <!-- needed for referenced domain entities that use Hibernate annotations (due to JDK5 bug) -->
        <dependency>
            <groupId>hibernate-annotations</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
            <scope>provided</scope>
            <!-- by JBossAS -->
        </dependency>

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

        <!-- needed for referenced domain entities that use JPA annotations (due to JDK5 bug) -->
        <dependency>
            <groupId>javax.persistence</groupId>
            <artifactId>persistence-api</artifactId>
            <version>1.0</version>
            <scope>provided</scope>
            <!-- by JBossAS -->
        </dependency>

        <!-- needed for EJB3 annotations (e.g. ApplicationException) -->
        <dependency>
            <groupId>jboss</groupId>
            <artifactId>jboss-ejb3x</artifactId>
            <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
            <scope>provided</scope>
            <!-- by JBossAS -->
        </dependency>

        <!-- Needed due to JDK 1.5 bug. -->
        <dependency>
            <groupId>jboss</groupId>
            <artifactId>jboss-annotations-ejb3</artifactId>
            <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
            <scope>provided</scope>
            <!-- by JBossAS -->
        </dependency>

        <dependency>
           <groupId>jboss.jbossws</groupId>
           <artifactId>jboss-jaxws</artifactId>
           <version>3.0.1-native-2.0.4.GA</version>
           <scope>provided</scope> <!-- by JBossAS -->
        </dependency>

    </dependencies>


    <build>
        <finalName>coregui</finalName>

        <resources>
            <resource>
                <targetPath>${project.build.directory}/generated-sources/gwt</targetPath>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>            
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.java</include>
                </includes>
            </resource>
        </resources>


        <plugins>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>1.2</version>
                <configuration>
                    <noServer>true</noServer>
                    <inplace>false</inplace>
                    <!-- <logLevel>INFO' -bindAddress 0.0.0.0 -logLevel 'INFO</logLevel> -->
                    <logLevel>INFO</logLevel>
                    <runTarget>${coreGuiRunTarget}</runTarget>
                    <extraJvmArgs>${gwt-plugin.extraJvmArgs}</extraJvmArgs>
                    <localWorkers>${gwt-plugin.localWorkers}</localWorkers>
                    <draftCompile>${gwt.draftCompile}</draftCompile>
                    <buildOutputDirectory>target/gwtclasses</buildOutputDirectory>
                    <hostedWebapp>target/hostedWar</hostedWebapp>
                    <debugSuspend>false</debugSuspend>
                    <servicePattern>**/gwt/*GWTService.java</servicePattern>
                    <i18nMessagesBundle>org.rhq.enterprise.gui.coregui.client.Messages</i18nMessagesBundle>
                    <i18nConstantsWithLookupBundle>org.rhq.enterprise.gui.coregui.client.MessageConstants</i18nConstantsWithLookupBundle>                    
                    <compileSourcesArtifact>org.rhq:rhq-core-domain</compileSourcesArtifact>
                    <style>DETAILED</style>
                </configuration>

                <executions>
                    <execution>
                        <id>gwt-goals</id>
                        <goals>
                            <goal>compile</goal>
                            <goal>generateAsync</goal>
                            <goal>i18n</goal>
                        </goals>
                    </execution>
                    <execution>
                        <!-- This id is what does the trick, don't change it. For this to work maven 2.2.0 and later is needed. -->
                        <id>default-cli</id>
                        <goals>
                            <goal>debug</goal>
                        </goals>
                        <configuration>
                            <module>org.rhq.enterprise.gui.coregui.CoreGUI</module>
                        </configuration>    
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                        <manifestEntries>
                            <Build-Number>${buildNumber}</Build-Number>
                        </manifestEntries>
                    </archive>
                    <webResources>
                        <resource>
                            <filtering>false</filtering>
                            <directory>${basedir}/src/main/webapp</directory>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>

            <!--
               <plugin>
                  <artifactId>maven-antrun-plugin</artifactId>
                  <executions>
                     <execution>
                        <id>Generate I18N Resource Bundles</id>
                        <phase>process-classes</phase>
                        <configuration>
                           <tasks>
                              <taskdef name="i18n" classpathref="maven.runtime.classpath" classname="mazz.i18n.ant.I18NAntTask" />
                              <i18n outputdir="${project.buildNodes.outputDirectory}" defaultlocale="en" verbose="false" append="false" verify="true">
                                 <classpath refid="maven.runtime.classpath" />
                                 <classfileset dir="${project.buildNodes.outputDirectory}">
                                    <include name="**/*I18NResourceKeys.class" />
                                 </classfileset>
                              </i18n>
                           </tasks>
                        </configuration>
                        <goals>
                           <goal>run</goal>
                        </goals>
                     </execution>
                     <execution>
                        <id>Maintain an unfiltered copy of i18n properties files</id>
                        <phase>process-classes</phase>
                        <configuration>
                           <tasks>
                              <copy todir="${project.buildNodes.outputDirectory}">
                                 <fileset dir="src/main/webapp-filtered/WEB-INF/classes">
                                    <include name="ApplicationResources.properties" />
                                 </fileset>
                                 <mapper type="glob" from="*" to="*.unfiltered" />
                              </copy>
                           </tasks>
                        </configuration>
                        <goals>
                           <goal>run</goal>
                        </goals>
                     </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.earName}/${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/${project.buildNodes.finalName}/WEB-INF/classes to ${classes.dir}...</echo>
                                        <copy todir="${classes.dir}" verbose="${rhq.verbose}">
                                           <fileset dir="war/WEB-INF/classes" />
                                        </copy>
                                        -->
                                        <property name="deployment.dir" location="${rhq.deploymentDir}" />
                                        <echo>*** Copying updated files from
                                            src${file.separator}main${file.separator}webapp${file.separator} to
                                            ${deployment.dir}${file.separator}...
                                        </echo>
                                        <copy todir="${deployment.dir}" verbose="${rhq.verbose}">
                                            <fileset dir="${basedir}/src/main/webapp" />
                                        </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>
                                    </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>

        <!--  Change the runTarget to not have single quotes. The quotes work for linux but not win -->
        <profile>
            <id>windows</id>
            <activation>
               <os>
                  <family>Windows</family>
               </os>
            </activation>
            <properties>
               <coreGuiRunTarget>http://localhost:7080/coregui/CoreGUI.html${coreGuiParams}</coreGuiRunTarget>
            </properties>         
        </profile>

        <profile>
            <id>msg</id>
            <build>
                <plugins>
                  <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                       <includes>
                           <include>org/rhq/enterprise/gui/coregui/client/Messages*.java</include>
                       </includes>
                    </configuration>
                  </plugin>
                </plugins>
              </build>
        </profile>
        
    </profiles>


    <repositories>
        <repository>
            <id>smartgwt</id>
            <name>SmartGWT Releases</name>
            <url>http://www.smartclient.com/maven2/</url>
            <snapshots>
               <enabled>false</enabled>
            </snapshots>
        </repository>

        <repository>
            <id>codehaus</id>
            <name>Codehaus Releases</name>
            <url>http://repository.codehaus.org/</url>
            <snapshots>
               <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

</project>
