<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.12.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>

  <properties>
        <!-- dependency versions -->
    <gwt.version>2.5.0</gwt.version>
    <smartgwt.version>3.0</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 -Xmx1300M -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.5.0, the recognized agents (defined in
         gwt-user.jar:com/google/gwt/user/UserAgent.gwt.xml) are as follows:

           ie9: IE9 (although for smartgwt we fallback to IE8)
           ie8: IE8
           gecko1_8: FF2 and later
           safari: Safari/Chrome

         *NOTE*: Since we specify the meta "X-UA-Compatible: IE=IE8" HTTP header in CoreGUI.html, IE9 and later
                 will emulate IE8.
         Multiple agents can be specified as a comma-delimited list, as demonstrated by the default
         value below.
        -->
    <gwt.userAgent>ie8,ie9,gecko1_8,safari</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>

        <!-- Change this to "true" via the mvn command line or your ~/.m2/settings.xml to generate report -->
    <gwt.soyc>false</gwt.soyc>

        <!-- Change this to "DETAILED" via the mvn command line or your ~/.m2/settings.xml to
             make sure GWT-generated JavaScript code is not obfuscated. -->
    <gwt.style>PRETTY</gwt.style>

        <!-- 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/coregui/client/. For example, the "ja" locale has
             Messages_ja.properties and MessageConstants_ja.properties. -->
    <gwt.locale>en,de,ja,pt,zh,ru,cs,ko</gwt.locale>

        <!-- The locale that GWT should fallback to if the user specified an unsupported locale via the 'locale' query
             string parameter. -->
    <gwt.fallback.locale>en</gwt.fallback.locale>

    <enable.tags>true</enable.tags>
  </properties>

  <dependencies>

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

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

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

    <!-- by rhq.ear -->
    <dependency>
      <groupId>org.rhq</groupId>
      <artifactId>rhq-core-util</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
    </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.smartgwt</groupId>
      <artifactId>smartgwt</artifactId>
      <version>${smartgwt.version}</version>
      <scope>provided</scope>
    </dependency>

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


        <!-- for file uploads -->
    <dependency>
      <groupId>commons-fileupload</groupId>
      <artifactId>commons-fileupload</artifactId>
    </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>
    </dependency>

    <dependency>
      <groupId>org.opensymphony.quartz</groupId>
      <artifactId>quartz</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.hibernate.javax.persistence</groupId>
      <artifactId>hibernate-jpa-2.0-api</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.jboss.spec.javax.ejb</groupId>
      <artifactId>jboss-ejb-api_3.1_spec</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.jboss.spec.javax.servlet</groupId>
      <artifactId>jboss-servlet-api_3.0_spec</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.jboss.resteasy</groupId>
      <artifactId>resteasy-jaxrs</artifactId>
      <version>${resteasy.version}</version>
      <scope>provided</scope>
    </dependency>

  </dependencies>


  <build>
    <finalName>coregui</finalName>

    <resources>
      <resource>
        <targetPath>${project.build.directory}/generated-sources/gwt</targetPath>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
                <!--
                  Do NOT include java files here, because otherwise the java files from
                  resources would end up in WEB-INF/classes which definitely not something
                  we want. The java files in resources are used for providing alternate,
                  gwt-compatible, implementations of domain classes and we do not want
                  those implementations to "spoil" the server-side classpath.

                  Actually, I'm not even sure we need the properties in the generated
                  sources (but we definitely DO need the gwt.xml in there, because we
                  need to replace the ${...} place-holders with the build-provided values
                  in there.
                -->
        <includes>
          <include>**/*.gwt.xml</include>
          <include>**/*.properties</include>
        </includes>
      </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>${gwt.version}</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>
          <soyc>${gwt.soyc}</soyc>
          <buildOutputDirectory>target/gwtclasses</buildOutputDirectory>
          <hostedWebapp>target/hostedWar</hostedWebapp>
          <debugSuspend>false</debugSuspend>
          <servicePattern>**/gwt/*GWTService.java</servicePattern>
          <i18nMessagesBundle>org.rhq.coregui.client.Messages</i18nMessagesBundle>
          <i18nConstantsWithLookupBundle>org.rhq.coregui.client.MessageConstants</i18nConstantsWithLookupBundle>
          <compileSourcesArtifact>org.rhq:rhq-core-domain</compileSourcesArtifact>
          <style>${gwt.style}</style>
          <strict>true</strict>
                    <!-- compiles gwt artifacts like symbolMap outside of war so it doesnt get packaged -->
          <deploy>${project.build.directory}/gwt-deploy</deploy>
        </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.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>
              <excludes>
                <exclude>login</exclude>
              </excludes>
            </resource>
            <resource>
              <directory>${basedir}/src/main/webapp</directory>
              <!-- enable filtering for login page -->
              <filtering>true</filtering>
              <includes>
                <include>login</include>
              </includes>
            </resource>
          </webResources>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>add-gwt-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${basedir}/target/generated-sources/gwt</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- remove unnecessary client .class files to reduce the size of the webapp and avoid long path names on windows -->
      <plugin>
         <artifactId>maven-clean-plugin</artifactId>
         <executions>
           <execution>
            <id>remove-gwt-client-classes</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>clean</goal>
            </goals>
            <configuration>
              <verbose>true</verbose>
              <excludeDefaultDirectories>true</excludeDefaultDirectories>
              <filesets>
                <fileset>  <!-- remove the class files of client-only code -->
                  <directory>${project.build.directory}/classes/org/rhq/coregui/client</directory>
                  <includes>
                    <include>**</include>
                  </includes>
                  <!-- keep the RPC-Service interface, and the entry- point class -->
                  <excludes>
                    <exclude>CoreGUI*.class</exclude>
                    <exclude>gwt/**</exclude>
                  </excludes>
                </fileset>
              </filesets>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Override root pom, we don't want to check the client classes because they have been removed after
           generating the javascript  -->
      <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>animal-sniffer-maven-plugin</artifactId>
          <executions>
              <execution>
                  <id>java-api-check</id>
                  <configuration>
                      <signature>
                         <groupId>${animal.sniffer.java.signature.groupId}</groupId>
                         <artifactId>${animal.sniffer.java.signature.artifactId}</artifactId>
                         <version>${animal.sniffer.java.signature.version}</version>
                      </signature>
                      <ignores>
                         <ignore>org.rhq.coregui.client.*</ignore>
                      </ignores>
                  </configuration>
                  <phase>verify</phase>
                  <goals>
                      <goal>check</goal>
                  </goals>
              </execution>
          </executions>
      </plugin>

    </plugins>

  </build>


  <profiles>
    <profile>
      <id>dev</id>

      <properties>
        <rhq.rootDir>../../../..</rhq.rootDir>
        <rhq.containerDir>${rhq.rootDir}/${rhq.devContainerServerPath}</rhq.containerDir>
        <rhq.deploymentName>${project.build.finalName}.war</rhq.deploymentName>
        <rhq.deploymentDir>${rhq.containerDir}/${rhq.earDeployDir}/${rhq.deploymentName}</rhq.deploymentDir>
      </properties>

      <build>
        <plugins>

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

              <execution>
                <id>deploy-classes</id>
                <phase>compile</phase>
                <configuration>
                  <target>
                    <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>
                  </target>
                </configuration>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>

              <execution>
                <id>deploy</id>
                <phase>package</phase>
                <configuration>
                  <target>
                    <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>
                  </target>
                </configuration>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>

              <execution>
                <id>undeploy</id>
                <phase>clean</phase>
                <configuration>
                  <target>
                    <property name="deployment.dir" location="${rhq.deploymentDir}"/>
                    <echo>*** Deleting ${deployment.dir}${file.separator}...</echo>
                    <delete dir="${deployment.dir}"/>
                  </target>
                </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/coregui/client/Messages*.java</include>
              </includes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>disable-tags</id>
      <activation>
        <property>
          <name>brew</name>
        </property>
      </activation>
      <properties>
        <enable.tags>false</enable.tags>
      </properties>
    </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>
