<?xml version="1.0" encoding="UTF-8"?>
<project>
    <modelVersion>4.0.0</modelVersion>
    <name>JBoss 7 - Management Console :: GUI</name>
    <groupId>org.jboss.as</groupId>
    <artifactId>jboss-as-console</artifactId>
    <packaging>war</packaging>

    <!-- Parent -->
    <parent>
        <groupId>org.jboss.as</groupId>
        <artifactId>jboss-as-console-parent</artifactId>
        <version>1.0.0.Beta20</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <properties>
        <ballroom.version>1.0.0.Beta11</ballroom.version>
        <console.profile>jboss</console.profile>
        <product.version>7.1</product.version>
    </properties>

    <!--  Dependencies -->
    <dependencies>
        <dependency>
            <groupId>org.jboss.ballroom</groupId>
            <artifactId>widgets</artifactId>
            <version>${ballroom.version}</version>
            <scope>provided</scope>
        </dependency>

        <!-- GWT -->
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-dev</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.google.code</groupId>
            <artifactId>gwt-visualization</artifactId>
        </dependency>

        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
            <classifier>sources</classifier>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.google.code.gwt-log</groupId>
            <artifactId>gwt-log</artifactId>
        </dependency>

        <dependency>
            <groupId>com.gwtplatform</groupId>
            <artifactId>gwtp-mvp-client</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
        </dependency>

        <dependency>
            <groupId>com.google.inject.extensions</groupId>
            <artifactId>guice-assistedinject</artifactId>
        </dependency>

        <dependency>
            <groupId>com.google.gwt.inject</groupId>
            <artifactId>gin</artifactId>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <!-- Plugins -->
    <build>
        <finalName>as7-console</finalName>
        <outputDirectory>war/WEB-INF/classes</outputDirectory>

        <resources>
            <resource>
                <directory>src/main/java</directory>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>${gwt.maven}</version>
                <configuration>
                    <inplace>true</inplace>
                    <logLevel>TRACE</logLevel>
                    <runTarget>App.html</runTarget>
                    <warSourceDirectory>war</warSourceDirectory>
                    <!--bindAddress>192.168.0.12</bindAddress-->
                    <extraJvmArgs>-Xmx512m -DDEBUG</extraJvmArgs>
                    <servicePattern>**/*Service.java</servicePattern>
                    <soyc>false</soyc>
                    <style>OBF</style>
                    <hostedWebapp>war</hostedWebapp>
                    <localWorkers>2</localWorkers>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>clean</goal>
                            <goal>resources</goal>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.2.1</version>
                <configuration>
                    <descriptors>
                        <descriptor>scripts/assembly.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>


            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1-beta-1</version>
                <configuration>
                    <warSourceDirectory>war</warSourceDirectory>
                    <webappDirectory>war</webappDirectory>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.2</version>
                <executions>
                    <execution>
                        <id>clean.war</id>
                        <phase>clean</phase>
                        <configuration>
                            <tasks>
                                <!--
                                    The gwt-maven-plugin use the war source folder
                                    as it's build directory. We need to cleanup after we'd run
                                    the plugin and remove all GWT related artifacts that are required
                                    to run the hosted mode.
                                -->
                                <delete dir="war/WEB-INF/classes"/>
                                <delete dir="war/WEB-INF/lib"/>
                                <delete dir="war/WEB-INF/deploy"/>
                                <!--delete file="war/WEB-INF/jboss-web.xml"/>
                                <delete file="war/WEB-INF/web.xml"/-->
                                <delete dir="war/app"/>
                                <delete dir="war/dmr_gwt"/>
                                <delete dir="war/org.jboss.as.console.App.JUnit"/>
                                <delete dir="target"/>

                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>

                    <execution>
                        <id>generate-version-class</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <tasks>
                                <!-- bump number first-->
                                <buildnumber/>

                                <ant antfile="../scripts/antrun-version.xml" inheritAll="false" inheritRefs="false">
                                    <property file="build.number"/>
                                    <property name="version" value="${project.version}"/>
                                    <property name="build.user" value="${user.name}"/>
                                    <property name="src.dir" value="${project.build.directory}/generated-sources" />
                                    <property name="console.profile" value="${console.profile}" />
                                    <property name="product.version" value="${product.version}" />
                                </ant>
                            </tasks>
                            <sourceRoot>
                                ${project.build.directory}/generated-sources
                            </sourceRoot>
                        </configuration>
                    </execution>

                    <execution>
                        <id>fake.war</id>
                        <phase>verify</phase>
                        <configuration>
                            <tasks>
                                <echo>Replace the war file with a fake.war</echo>
                                <copy file="build.number" todir="fake_war" overwrite="true"/>
                                <zip destfile="./target/fake.war" basedir="fake_war"/>
                                <copy file="./target/fake.war" tofile="./target/as7-console.war" overwrite="true" verbose="true"/>
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>


                    <execution>
                        <id>custom.styles</id>
                        <phase>process-resources</phase>
                        <configuration>
                            <tasks>
                                <copy file="src/main/templates/App.gwt.xml" tofile="src/main/java/org/jboss/as/console/App.gwt.xml" overwrite="true" verbose="true"/>
                                <replace file="src/main/java/org/jboss/as/console/App.gwt.xml" token="@ballroom_theme@" value="org.jboss.ballroom.Framework" summary="yes"/>
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <!-- Surefire setup in order to be able to run GWT unit tests, according to
                     http://mojo.codehaus.org/gwt-maven-plugin/user-guide/testing.html -->
                <!-- Note that running the unit tests produces a number of the following warnings:
                     [WARN] Template with variable in CSS context: The template code generator cannot guarantee HTML-safety of the template - please inspect manually
                     This is a known GWT bug which should be fixed in GWT 2.3 - see Issue 5962 http://code.google.com/p/google-web-toolkit/issues/detail?id=5962 -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <additionalClasspathElements>
                        <additionalClasspathElement>${basedir}/war/WEB-INF/classes/</additionalClasspathElement>
                        <additionalClasspathElement>${basedir}/target/generated-sources/</additionalClasspathElement>
                        <additionalClasspathElement>${project.build.testSourceDirectory}</additionalClasspathElement>
                    </additionalClasspathElements>
                    <includes>
                      <include>org/jboss/as/console/client/forms/**</include>
                      <!-- Do not include all of the GWT tests individually, but use a test suite
                           to run them instead. This speeds up test execution as the GWT runner only 
                           gets loaded once per suite. -->
                      <include>**/*TestSuite.java</include>
                    </includes>
                    <useManifestOnlyJar>false</useManifestOnlyJar>
                    <forkMode>always</forkMode>
                    <skipTests>false</skipTests>
                    <systemProperties>
                        <property>
                            <name>gwt.args</name>
                            <value>-out ${basedir}/target/test-war</value>
                        </property>
                    </systemProperties>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>quick-hosted-mode</id>
            <activation>
                <property>
                    <name>hosted</name>
                </property>
            </activation>
            <properties>
                <google.webtoolkit.compileSkip>true</google.webtoolkit.compileSkip>
                <o>true</o> <!-- offline -->
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>gwt-maven-plugin</artifactId>
                        <version>${gwt.maven}</version>
                        <configuration>
                            <draftCompile>true</draftCompile>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>eap</id>
            <properties>
                <console.profile>eap</console.profile>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.2</version>
                        <executions>

                            <execution>
                                <id>custom.styles</id>
                                <phase>process-resources</phase>
                                <configuration>
                                    <tasks>
                                        <copy file="src/main/templates/App.gwt.xml" tofile="src/main/java/org/jboss/as/console/App.gwt.xml" overwrite="true" verbose="true"/>
                                        <replace file="src/main/java/org/jboss/as/console/App.gwt.xml" token="@ballroom_theme@" value="org.jboss.ballroom.Framework_RH" summary="yes"/>
                                    </tasks>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

    </profiles>

    <pluginRepositories>
        <pluginRepository>
            <id>gwtplatform.plugin</id>
            <name>Gwtplatform custom plugin repository</name>
            <url>http://maven.gwt-platform.googlecode.com/hg/</url>
            <layout>default</layout>
        </pluginRepository>
    </pluginRepositories>
</project>
