<?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.3.2.Final</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <properties>
        <gwt.maven>2.3.0</gwt.maven>
        <console.profile>jboss</console.profile>
        <product.version>7.1</product.version>
        <gwt.bindAddress>127.0.0.1</gwt.bindAddress>
    </properties>

    <!--  Dependencies -->
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.jboss.as</groupId>
                <artifactId>jboss-as-console-bom</artifactId>
                <type>pom</type>
                <version>${project.version}</version>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>

        <dependency>
            <groupId>org.jboss.ballroom</groupId>
            <artifactId>widgets</artifactId>
        </dependency>

        <dependency>
            <groupId>org.jboss.as</groupId>
            <artifactId>console-spi</artifactId>
        </dependency>

        <dependency>
            <groupId>org.jboss.as</groupId>
            <artifactId>console-spi</artifactId>
            <classifier>sources</classifier>
        </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>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <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>ERROR</logLevel>
                    <runTarget>App.html</runTarget>
                    <warSourceDirectory>war</warSourceDirectory>
                    <extraJvmArgs>-server -Xmx512m -XX:MaxPermSize=256M</extraJvmArgs>
                    <servicePattern>**/*Service.java</servicePattern>
                    <style>OBF</style>
                    <hostedWebapp>war</hostedWebapp>
                    <localWorkers>2</localWorkers>
                    <compileReport>false</compileReport>
                    <optimizationLevel>9</optimizationLevel>
                </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>
                        <descriptor>scripts/export.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>
                    <debug>false</debug>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.bsc.maven</groupId>
                <artifactId>maven-processor-plugin</artifactId>
                <version>2.0.6-redhat</version>
                <executions>
                    <execution>
                        <id>process</id>
                        <goals>
                            <goal>process</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <outputDiagnostics>false</outputDiagnostics>
                            <processors>
                                <processor>org.jboss.as.console.spi.ExtensionProcessor</processor>
                                <processor>org.jboss.as.console.spi.ExtensionBindingProcessor</processor>
                                <processor>org.jboss.as.console.spi.BeanFactoryProcessor</processor>
                                <processor>org.jboss.as.console.spi.SubsystemProcessor</processor>
                            </processors>
                        </configuration>
                    </execution>
                </executions>
            </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}" />

                                    <!-- only used in hosted mode, see BootstrapContext -->
                                    <property name="dev.host" value="${gwt.bindAddress}" />
                                </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-sources</phase>
                        <configuration>
                            <tasks>

                                <!-- the App.gwt.xml -->
                                <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"/>


                                <!-- development proxy settings -->
                                <copy file="src/main/templates/gwt-proxy.properties" tofile="src/main/java/gwt-proxy.properties" overwrite="true" verbose="true"/>
                                <copy file="src/main/templates/upload-proxy.properties" tofile="src/main/java/upload-proxy.properties" overwrite="true" verbose="true"/>

                                <replace file="src/main/java/gwt-proxy.properties" token="@bindAddress@" value="${gwt.bindAddress}" summary="yes"/>
                                <replace file="src/main/java/upload-proxy.properties" token="@bindAddress@" value="${gwt.bindAddress}" 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>${basedir}/target/generated-sources/apt</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>true</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>dev</id>
            <properties>
                <skipTests>true</skipTests>
            </properties>
            <build>
                <plugins>


                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>gwt-maven-plugin</artifactId>
                        <version>${gwt.maven}</version>
                        <configuration>
                            <extraJvmArgs>-server -Xmx512m -XX:MaxPermSize=256M</extraJvmArgs>
                            <optimizationLevel>9</optimizationLevel>
                            <!--disableCastChecking>true</disableCastChecking>
                            <disableClassMetadata>true</disableClassMetadata-->
                        </configuration>
                    </plugin>

                    <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.dev.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>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <skipTests>true</skipTests>
                        </configuration>
                    </plugin>
                </plugins>
            </build>

        </profile>


        <profile>
            <id>compile-report</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>gwt-maven-plugin</artifactId>
                        <version>${gwt.maven}</version>
                        <configuration>
                            <compileReport>true</compileReport>
                        </configuration>
                    </plugin>
                </plugins>

            </build>

            <reporting>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>gwt-maven-plugin</artifactId>
                        <reportSets>
                            <reportSet>
                                <reports>
                                    <report>compile-report</report>
                                </reports>
                            </reportSet>
                        </reportSets>
                    </plugin>
                </plugins>
            </reporting>
        </profile>

        <profile>
            <id>eap</id>
            <properties>
                <console.profile>eap</console.profile>
                <product.version>6</product.version>
            </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>


        <profile>
            <id>i18n</id>
            <build>
                <plugins>
                    <plugin>
                        <!--
                           see also ant executions
                        -->
                        <groupId>org.zanata</groupId>
                        <artifactId>zanata-maven-plugin</artifactId>
                        <version>1.5.0</version>
                        <configuration>
                            <projectType>properties</projectType>
                            <includes>UIConstants.properties,UIMessages.properties</includes>
                            <projectVersion>master</projectVersion>
                            <srcDir>${project.build.directory}/i18n</srcDir>
                            <transDir>${project.build.directory}/i18n</transDir>
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.7</version>
                        <executions>
                            <execution>
                                <id>prepare.zanata</id>
                                <phase>initialize</phase>
                                <configuration>
                                    <tasks>
                                        <mkdir dir="${project.build.directory}/i18n"/>
                                        <copy file="./src/main/java/org/jboss/as/console/client/core/UIConstants_en.properties"
                                              tofile="${project.build.directory}/i18n/UIConstants.properties" overwrite="true"/>
                                        <copy file="./src/main/java/org/jboss/as/console/client/core/UIMessages.properties"
                                              todir="${project.build.directory}/i18n" overwrite="true"/>

                                        <copy todir="${project.build.directory}/i18n">
                                            <fileset dir="./src/main/java/org/jboss/as/console/client/core/">
                                                <include name="UIConstants_de.properties"/>
                                                <include name="UIConstants_es.properties"/>
                                                <include name="UIConstants_fr.properties"/>
                                                <include name="UIConstants_ja.properties"/>
                                                <include name="UIConstants_pt_BR.properties"/>
                                                <include name="UIConstants_zh_Hans.properties"/>
                                            </fileset>
                                        </copy>

                                        <copy todir="${project.build.directory}/i18n">
                                            <fileset dir="./src/main/java/org/jboss/as/console/client/core/">
                                                <include name="UIMessages_de.properties"/>
                                                <include name="UIMessages_es.properties"/>
                                                <include name="UIMessages_fr.properties"/>
                                                <include name="UIMessages_ja.properties"/>
                                                <include name="UIMessages_pt_BR.properties"/>
                                                <include name="UIMessages_zh_Hans.properties"/>
                                            </fileset>
                                        </copy>
                                    </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>
