<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2012 Red Hat, Inc. and/or its affiliates.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~       http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" 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.kie</groupId>
    <artifactId>kie-wb-distributions</artifactId>
    <version>7.4.0.Final</version>
  </parent>

  <artifactId>kie-wb-parent</artifactId>

  <packaging>pom</packaging>
  <name>KIE Workbench Parent</name>
  <description>KIE Workbench Parent</description>

  <modules>
    <module>kie-wb-monitoring-webapp</module>
    <module>kie-wb-webapp</module>
    <module>kie-wb-distribution-wars</module>
  </modules>

  <properties>
    <!-- Add the absolute path for $JBOSS_HOME below to manage another instance -->
    <errai.jboss.home>${project.build.directory}/wildfly-${version.org.wildfly.gwt.sdm}</errai.jboss.home>
    <gwt.compiler.localWorkers>1</gwt.compiler.localWorkers>
    <gwt.memory.settings>-Xmx5g -Xms1g -Xss1M</gwt.memory.settings>
    <login.bundle.name>org.kie.workbench.client.resources.i18n.LoginConstants</login.bundle.name>
    <login.page>kie-wb.jsp</login.page>
  </properties>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>findbugs-maven-plugin</artifactId>
          <configuration>
            <excludeFilterFile>${project.basedir}/../../src/main/findbugs/findbugs-exclude.xml</excludeFilterFile>
          </configuration>
        </plugin>
        <plugin>
          <!-- Default configuration used for FastCompiled build. Includes the common GWT source artifacts and plugin
               config. Product X community specific artifacts (e.g. home page) are specified using
               profiles "productized" and "notProductized".

               Keep the configuration here (pluginManagement) instead of directly in <plugins>. -->
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>gwt-maven-plugin</artifactId>
          <configuration>
            <deploy>${project.build.directory}/gwt-symbols-deploy</deploy>
            <localWorkers>${gwt.compiler.localWorkers}</localWorkers>
            <extraJvmArgs>${gwt.memory.settings} -XX:CompileThreshold=7000 -Derrai.jboss.home=${errai.jboss.home} -Derrai.server.classOutput=${project.build.outputDirectory} -Derrai.dynamic_validation.enabled=true -Dorg.kie.demo=true -Dorg.kie.clean.onstartup=true -Dorg.uberfire.nio.git.ssh.enabled=false -Djava.util.prefs.syncInterval=2000000 -Dorg.uberfire.async.executor.safemode=true</extraJvmArgs>
            <draftCompile>true</draftCompile>
            <module>org.kie.workbench.FastCompiledKIEWebapp</module>
            <logLevel>INFO</logLevel>
            <noServer>false</noServer>
            <server>org.jboss.errai.cdi.server.gwt.EmbeddedWildFlyLauncher</server>
            <disableCastChecking>true</disableCastChecking>
            <runTarget>kie-wb.jsp</runTarget>
          </configuration>
          <executions>
            <execution>
              <id>gwt-clean</id>
              <phase>clean</phase>
              <goals>
                <goal>clean</goal>
              </goals>
            </execution>
            <execution>
              <id>gwt-compile</id>
              <goals>
                <!-- Do not use 'resources' goal as it does not play well with resource filtering and is adding Java
                     source files into the build output directory (and they then end up in the WAR). -->
                <goal>compile</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-war-plugin</artifactId>
          <configuration>
            <packagingExcludes>
              WEB-INF/classes/javax/**/*.*,
              WEB-INF/classes/org/kie/workbench/client/**/*.class,
              WEB-INF/classes/org/kie/workbench/client/resources/i18n/App*.properties,
              WEB-INF/classes/org/kie/workbench/client/docks/**,
              WEB-INF/classes/org/kie/workbench/client/navbar/**,
              WEB-INF/classes/org/kie/workbench/client/perspectives/**,

              WEB-INF/classes/**/public/**,
              WEB-INF/classes/logback.xml,
              **/*.gwt.xml,
              **/*.symbolMap
            </packagingExcludes>
            <archive>
              <addMavenDescriptor>false</addMavenDescriptor>
            </archive>
            <overlays>
              <overlay>
                <groupId>org.kie</groupId>
                <artifactId>kie-wb-webapp-common</artifactId>
                <filtered>true</filtered>
              </overlay>
            </overlays>
          </configuration>
          <executions>
            <execution>
              <id>unpack-overlay</id>
              <phase>process-resources</phase>
              <goals>
                <goal>exploded</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <configuration>
            <filesets>
              <fileset>
                <directory>${basedir}</directory>
                <includes>
                  <include>src/main/webapp/org.kie.workbench.KIEWebapp/</include>
                  <include>src/main/webapp/formModeler/</include>
                  <include>src/main/webapp/WEB-INF/deploy/</include>
                  <include>src/main/webapp/WEB-INF/classes/</include>
                  <include>src/main/webapp/WEB-INF/lib/</include>
                  <include>src/main/webapp/WEB-INF/tlds/</include>
                  <include>repositories/</include>
                  <include>.errai/</include>
                  <include>.niogit/**</include>
                  <include>.index/**</include>
                </includes>
              </fileset>
            </filesets>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <executions>
            <execution>
              <id>copy-resources</id>
              <phase>process-resources</phase>
              <goals>
                <goal>copy-resources</goal>
              </goals>
              <configuration>
                <outputDirectory>${errai.jboss.home}/standalone/configuration</outputDirectory>
                <overwrite>true</overwrite>
                <resources>
                  <resource>
                    <directory>src/main/config</directory>
                    <filtering>false</filtering>
                  </resource>
                </resources>
              </configuration>
            </execution>
          </executions>
        </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>${version.org.wildfly.gwt.sdm}</version>
                    <type>zip</type>
                    <overWrite>false</overWrite>
                    <outputDirectory>${project.build.directory}</outputDirectory>
                  </artifactItem>
                </artifactItems>
              </configuration>
            </execution>
            <execution>
              <id>copy-files-to-webapp-directory</id>
              <phase>process-resources</phase>
              <goals>
                <goal>unpack</goal>
              </goals>
              <configuration>
                <artifactItems>
                  <artifactItem>
                    <groupId>org.jbpm</groupId>
                    <artifactId>jbpm-form-modeler-request-dispatcher</artifactId>
                    <type>jar</type>
                    <overWrite>true</overWrite>
                    <outputDirectory>src/main/webapp</outputDirectory>
                    <includes>**/*.tld, **/*.gif, **/*.jpg, **/*.js, **/*.jsp, **/*.css, **/*.png</includes>
                  </artifactItem>
                  <artifactItem>
                    <groupId>org.jbpm</groupId>
                    <artifactId>jbpm-form-modeler-form-editor</artifactId>
                    <type>jar</type>
                    <overWrite>true</overWrite>
                    <outputDirectory>src/main/webapp</outputDirectory>
                    <includes>**/*.tld, **/*.gif, **/*.jpg, **/*.js, **/*.jsp, **/*.css, **/*.png</includes>
                  </artifactItem>
                  <artifactItem>
                    <groupId>org.jbpm</groupId>
                    <artifactId>jbpm-form-modeler-static-resources</artifactId>
                    <type>jar</type>
                    <overWrite>true</overWrite>
                    <outputDirectory>src/main/webapp</outputDirectory>
                    <includes>**/*.tld, **/*.gif, **/*.jpg, **/*.js, **/*.jsp, **/*.css, **/*.png</includes>
                  </artifactItem>
                  <artifactItem>
                    <groupId>org.jbpm</groupId>
                    <artifactId>jbpm-form-modeler-ui</artifactId>
                    <type>jar</type>
                    <overWrite>true</overWrite>
                    <outputDirectory>src/main/webapp</outputDirectory>
                    <includes>**/*.tld, **/*.gif, **/*.jpg, **/*.js, **/*.jsp, **/*.css, **/*.png</includes>
                  </artifactItem>
                </artifactItems>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.wildfly.swarm</groupId>
          <artifactId>wildfly-swarm-plugin</artifactId>
          <configuration>
            <fractionDetectMode>never</fractionDetectMode>
            <fractions>
              <fraction>logging</fraction>
              <fraction>undertow</fraction>
              <fraction>cdi</fraction>
              <fraction>ejb</fraction>
              <fraction>jaxrs</fraction>
              <fraction>ee</fraction>
              <fraction>security</fraction>
              <fraction>management</fraction>
              <fraction>datasources</fraction>
            </fractions>
          </configuration>
          <executions>
            <execution>
              <goals>
                <goal>package</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>

  </build>

  <profiles>
    <!-- Community Home Page -->
    <profile>
      <id>notProductizedProfile</id>
      <activation>
        <property>
          <name>!productized</name>
        </property>
      </activation>
      <modules>
        <module>kie-wb-home-page-community</module>
      </modules>

      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>gwt-maven-plugin</artifactId>
              <configuration>
                <compileSourcesArtifacts combine.children="append">
                  <!-- Community Theme -->
                  <compileSourcesArtifact>org.kie:kie-wb-theme-community</compileSourcesArtifact>
                  <!-- Community Home Page -->
                  <compileSourcesArtifact>org.kie:kie-wb-home-page-community</compileSourcesArtifact>
                  <compileSourcesArtifact>org.kie.workbench.screens:kie-wb-common-home-api</compileSourcesArtifact>
                  <compileSourcesArtifact>org.kie.workbench.screens:kie-wb-common-home-client</compileSourcesArtifact>
                </compileSourcesArtifacts>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>

    <!-- Product Home Page -->
    <profile>
      <id>productizedProfile</id>
      <activation>
        <property>
          <name>productized</name>
        </property>
      </activation>
      <modules>
        <module>kie-wb-home-page-product</module>
      </modules>

      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>gwt-maven-plugin</artifactId>
              <configuration>
                <compileSourcesArtifacts combine.children="append">
                  <!-- Product Theme -->
                  <compileSourcesArtifact>org.kie:kie-wb-theme-product</compileSourcesArtifact>
                  <!-- Product Home Page -->
                  <compileSourcesArtifact>org.kie:kie-wb-home-page-product</compileSourcesArtifact>
                  <compileSourcesArtifact>org.kie.workbench.screens:kie-wb-common-home-api</compileSourcesArtifact>
                  <compileSourcesArtifact>org.kie.workbench.screens:kie-wb-common-home-client</compileSourcesArtifact>
                </compileSourcesArtifacts>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>

    <!-- Full profile builds all GWT permutations -->
    <profile>
      <id>fullProfile</id>
      <activation>
        <property>
          <name>full</name>
        </property>
      </activation>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>gwt-maven-plugin</artifactId>
              <configuration>
                <module>org.kie.workbench.KIEWebapp</module>
                <draftCompile>false</draftCompile>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>

  </profiles>

</project>
