<?xml version="1.0" encoding="UTF-8"?>
<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.dashbuilder</groupId>
    <artifactId>dashbuilder-deps</artifactId>
    <version>0.3.2.Final</version>
    <relativePath>../dashbuilder-deps/pom.xml</relativePath>
  </parent>

  <artifactId>dashbuilder-webapp</artifactId>
  <packaging>war</packaging>

  <name>Dashbuilder WebApp</name>
  <description>Dashbuilder WebApp</description>

  <properties>
    <errai.version>${version.org.jboss.errai}</errai.version>
    <as.version>8.1.0.Final</as.version>
    <!-- Add the absolute path for $JBOSS_HOME below to manage another instance -->
    <errai.jboss.home>${project.build.directory}/wildfly-${as.version}</errai.jboss.home>
  </properties>

  <!-- NOTE: GWT client deps are needed for GWT compilation purposes (scope=provided) -->
  <dependencies>

    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
    </dependency>

    <!-- Dashbuilder -->

    <dependency>
      <groupId>org.dashbuilder</groupId>
      <artifactId>dashbuilder-server-all</artifactId>
    </dependency>

    <dependency>
      <groupId>org.dashbuilder</groupId>
      <artifactId>dashbuilder-common</artifactId>
    </dependency>

    <dependency>
      <groupId>org.dashbuilder</groupId>
      <artifactId>dashbuilder-dataset-api</artifactId>
    </dependency>

    <dependency>
      <groupId>org.dashbuilder</groupId>
      <artifactId>dashbuilder-client-all</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.dashbuilder</groupId>
      <artifactId>dashbuilder-common-client</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.dashbuilder</groupId>
      <artifactId>dashbuilder-dataset-client</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.dashbuilder</groupId>
      <artifactId>dashbuilder-displayer-api</artifactId>
    </dependency>

    <dependency>
      <groupId>org.dashbuilder</groupId>
      <artifactId>dashbuilder-displayer-client</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.dashbuilder</groupId>
      <artifactId>dashbuilder-displayer-screen</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.dashbuilder</groupId>
      <artifactId>dashbuilder-dataset-editor</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.dashbuilder</groupId>
      <artifactId>dashbuilder-displayer-editor</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.dashbuilder</groupId>
      <artifactId>dashbuilder-renderer-default</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.dashbuilder</groupId>
      <artifactId>dashbuilder-renderer-google</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.dashbuilder</groupId>
      <artifactId>dashbuilder-renderer-lienzo</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.dashbuilder</groupId>
      <artifactId>dashbuilder-renderer-chartjs</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- UberFire -->

    <dependency>
      <groupId>org.uberfire</groupId>
      <artifactId>uberfire-server-all</artifactId>
    </dependency>

    <dependency>
      <groupId>org.uberfire</groupId>
      <artifactId>uberfire-commons</artifactId>
    </dependency>

    <dependency>
      <groupId>org.uberfire</groupId>
      <artifactId>uberfire-api</artifactId>
    </dependency>

    <dependency>
      <groupId>org.uberfire</groupId>
      <artifactId>uberfire-client-api</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.uberfire</groupId>
      <artifactId>uberfire-io</artifactId>
    </dependency>

    <dependency>
      <groupId>org.uberfire</groupId>
      <artifactId>uberfire-backend-server</artifactId>
    </dependency>

    <dependency>
      <groupId>org.uberfire</groupId>
      <artifactId>uberfire-nio2-api</artifactId>
    </dependency>

    <dependency>
      <groupId>org.uberfire</groupId>
      <artifactId>uberfire-workbench-client</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.uberfire</groupId>
      <artifactId>uberfire-security-client</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.uberfire</groupId>
      <artifactId>uberfire-workbench-processors</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.uberfire</groupId>
      <artifactId>uberfire-runtime-plugins-client</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.uberfire</groupId>
      <artifactId>uberfire-runtime-plugins-backend</artifactId>
    </dependency>

    <dependency>
      <groupId>org.uberfire</groupId>
      <artifactId>uberfire-apps-client</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.uberfire</groupId>
      <artifactId>uberfire-apps-backend</artifactId>
    </dependency>

    <dependency>
      <groupId>org.uberfire</groupId>
      <artifactId>uberfire-widgets-properties-editor-client</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.uberfire</groupId>
      <artifactId>uberfire-widgets-properties-editor-backend</artifactId>
    </dependency>

    <dependency>
      <groupId>org.uberfire</groupId>
      <artifactId>uberfire-workbench-client-views-bs2</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.uberfire</groupId>
      <artifactId>uberfire-widgets-commons</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- Log -->

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-ext</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>log4j-over-slf4j</artifactId>
    </dependency>

    <!-- Errai -->

    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-common</artifactId>
    </dependency>

    <dependency>
      <groupId>de.benediktmeurer.gwt-slf4j</groupId>
      <artifactId>gwt-slf4j</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-ui</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-ioc</artifactId>
    </dependency>

    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-security-picketlink</artifactId>
    </dependency>

    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-security-server</artifactId>
    </dependency>

    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-jboss-as-support</artifactId>
    </dependency>

    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-javax-enterprise</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-weld-integration</artifactId>
    </dependency>

    <dependency>
      <groupId>org.owasp.encoder</groupId>
      <artifactId>encoder</artifactId>
    </dependency>

    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-codegen-gwt</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- Container provided dependencies -->

    <dependency>
      <groupId>javax.enterprise</groupId>
      <artifactId>cdi-api</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>javax.inject</groupId>
      <artifactId>javax.inject</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-cdi-jboss</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>xml-apis</groupId>
      <artifactId>xml-apis</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>com.sun.xml.bind</groupId>
      <artifactId>jaxb-impl</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.jboss.resteasy</groupId>
      <artifactId>jaxrs-api</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.picketlink</groupId>
      <artifactId>picketlink-api</artifactId>
    </dependency>

    <dependency>
      <groupId>org.picketlink</groupId>
      <artifactId>picketlink-idm-api</artifactId>
    </dependency>

    <dependency>
      <groupId>org.jboss.resteasy</groupId>
      <artifactId>resteasy-cdi</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.jboss.resteasy</groupId>
      <artifactId>resteasy-jaxrs</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- GWT and GWT Extensions -->

    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-user</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>com.github.gwtbootstrap</groupId>
      <artifactId>gwt-bootstrap</artifactId>
      <scope>provided</scope>
    </dependency>

  </dependencies>

  <build>
    <finalName>${project.artifactId}</finalName>
    <outputDirectory>src/main/webapp/WEB-INF/classes</outputDirectory>

    <plugins>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        <configuration>
          <deploy>${project.build.directory}/gwt-symbols-deploy</deploy>
          <localWorkers>4</localWorkers>
          <module>org.dashbuilder.FastCompiledDashbuilderShowcase</module>
          <draftCompile>true</draftCompile>
          <logLevel>INFO</logLevel>
          <strict>true</strict>
          <compileSourcesArtifacts>

            <!-- Dashbuilder -->
            <compileSourcesArtifact>org.dashbuilder:dashbuilder-widgets</compileSourcesArtifact>
            <compileSourcesArtifact>org.dashbuilder:dashbuilder-validations</compileSourcesArtifact>
            <compileSourcesArtifact>org.dashbuilder:dashbuilder-common-client</compileSourcesArtifact>
            <compileSourcesArtifact>org.dashbuilder:dashbuilder-dataset-api</compileSourcesArtifact>
            <compileSourcesArtifact>org.dashbuilder:dashbuilder-dataset-shared</compileSourcesArtifact>
            <compileSourcesArtifact>org.dashbuilder:dashbuilder-dataset-client</compileSourcesArtifact>
            <compileSourcesArtifact>org.dashbuilder:dashbuilder-displayer-api</compileSourcesArtifact>
            <compileSourcesArtifact>org.dashbuilder:dashbuilder-displayer-client</compileSourcesArtifact>
            <compileSourcesArtifact>org.dashbuilder:dashbuilder-displayer-screen</compileSourcesArtifact>
            <compileSourcesArtifact>org.dashbuilder:dashbuilder-displayer-editor</compileSourcesArtifact>
            <compileSourcesArtifact>org.dashbuilder:dashbuilder-dataset-editor</compileSourcesArtifact>
            <compileSourcesArtifact>org.dashbuilder:dashbuilder-renderer-default</compileSourcesArtifact>
            <compileSourcesArtifact>org.dashbuilder:dashbuilder-renderer-google</compileSourcesArtifact>
            <compileSourcesArtifact>org.dashbuilder:dashbuilder-renderer-chartjs</compileSourcesArtifact>
            <compileSourcesArtifact>org.dashbuilder:dashbuilder-renderer-lienzo</compileSourcesArtifact>

            <!-- Uberfire ext -->
            <compileSourcesArtifact>org.uberfire:uberfire-runtime-plugins-api</compileSourcesArtifact>
            <compileSourcesArtifact>org.uberfire:uberfire-runtime-plugins-client</compileSourcesArtifact>
            <compileSourcesArtifact>org.uberfire:uberfire-commons-editor-api</compileSourcesArtifact>
            <compileSourcesArtifact>org.uberfire:uberfire-commons-editor-client</compileSourcesArtifact>
            <compileSourcesArtifact>org.uberfire:uberfire-apps-api</compileSourcesArtifact>
            <compileSourcesArtifact>org.uberfire:uberfire-apps-client</compileSourcesArtifact>
            <compileSourcesArtifact>org.uberfire:uberfire-widgets-service-api</compileSourcesArtifact>
            <compileSourcesArtifact>org.uberfire:uberfire-widgets-commons</compileSourcesArtifact>
            <compileSourcesArtifact>org.uberfire:uberfire-widgets-properties-editor-api</compileSourcesArtifact>
            <compileSourcesArtifact>org.uberfire:uberfire-widgets-properties-editor-client</compileSourcesArtifact>

            <!-- UberFire -->
            <compileSourcesArtifact>org.uberfire:uberfire-commons</compileSourcesArtifact>
            <compileSourcesArtifact>org.uberfire:uberfire-nio2-model</compileSourcesArtifact>
            <compileSourcesArtifact>org.uberfire:uberfire-io</compileSourcesArtifact>
            <compileSourcesArtifact>org.uberfire:uberfire-api</compileSourcesArtifact>
            <compileSourcesArtifact>org.uberfire:uberfire-js</compileSourcesArtifact>
            <compileSourcesArtifact>org.uberfire:uberfire-security-api</compileSourcesArtifact>
            <compileSourcesArtifact>org.uberfire:uberfire-security-client</compileSourcesArtifact>
            <compileSourcesArtifact>org.uberfire:uberfire-client-api</compileSourcesArtifact>
            <compileSourcesArtifact>org.uberfire:uberfire-workbench-client</compileSourcesArtifact>
            <compileSourcesArtifact>org.uberfire:uberfire-workbench-client-backend</compileSourcesArtifact>
            <compileSourcesArtifact>org.uberfire:uberfire-workbench-client-views-bs2</compileSourcesArtifact>
            <compileSourcesArtifact>org.uberfire:uberfire-backend-api</compileSourcesArtifact>

          </compileSourcesArtifacts>
          <runTarget>dashbuilder.html</runTarget>
          <extraJvmArgs>-Xmx2024m -XX:CompileThreshold=7000 -XX:MaxPermSize=512M -Derrai.jboss.home=${errai.jboss.home}</extraJvmArgs>
          <noServer>false</noServer>
          <server>org.jboss.errai.cdi.server.gwt.EmbeddedWildFlyLauncher</server>
          <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
          <disableCastChecking>true</disableCastChecking>
        </configuration>
        <executions>
          <execution>
            <id>gwt-clean</id>
            <phase>clean</phase>
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
          <execution>
            <id>gwt-compile</id>
            <goals>
              <goal>resources</goal>
              <goal>compile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <packagingExcludes>**/javax/**/*.*,**/client/**/*.class,**/*.symbolMap</packagingExcludes>
          <archive>
            <addMavenDescriptor>false</addMavenDescriptor>
          </archive>
        </configuration>
      </plugin>

      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <configuration>
          <filesets>
            <fileset>
              <directory>${basedir}</directory>
              <includes>
                <include>.errai/**</include>
                <include>.niogit/**</include>
                <include>src/main/webapp/WEB-INF/classes/**</include>
                <include>src/main/webapp/WEB-INF/lib/**</include>
              </includes>
            </fileset>
          </filesets>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack</id>
            <phase>process-resources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>org.wildfly</groupId>
                  <artifactId>wildfly-dist</artifactId>
                  <version>${as.version}</version>
                  <type>zip</type>
                  <overWrite>false</overWrite>
                  <outputDirectory>${project.build.directory}</outputDirectory>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.6</version>
        <executions>
          <execution>
            <id>copy-resources</id>
            <phase>process-resources</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/wildfly-${as.version}/standalone/deployments</outputDirectory>
              <resources>
                <resource>
                  <directory>src/test/resources/datasources</directory>
                  <filtering>true</filtering>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>

    </plugins>

  </build>

  <profiles>
    <profile>
      <id>fullProfile</id>
      <activation>
        <property>
          <name>full</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin><!-- Keep in sync with soa profile -->
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>gwt-maven-plugin</artifactId>
            <configuration>
              <!-- Build all GWT permutations and optimize them -->
              <module>org.dashbuilder.DashbuilderShowcase</module>
              <draftCompile>false</draftCompile>
              <force>true</force>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
