<?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.optaweb.employeerostering</groupId>
    <artifactId>employee-rostering</artifactId>
    <version>7.20.0.Final</version>
  </parent>

  <artifactId>employee-rostering-gwtui</artifactId>
  <packaging>gwt-app</packaging>

  <name>Employee Rostering as a Service GWT UI</name>

  <dependencies>
    <!-- gwt-dev must be first so the correct JDT ECJ version is on GWT's compiler's classpath -->
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-dev</artifactId>
      <exclusions>
        <exclusion>
          <!-- Contains a ServletContainerInitializer that breaks the EmbeddedWildFlyLauncher during GWT Super Dev Mode -->
          <groupId>org.eclipse.jetty</groupId>
          <artifactId>apache-jsp</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <!-- Java EE APIs -->
    <dependency>
      <groupId>javax.enterprise</groupId>
      <artifactId>cdi-api</artifactId>
    </dependency>
    <dependency>
      <groupId>javax.inject</groupId>
      <artifactId>javax.inject</artifactId>
    </dependency>
    <dependency>
      <groupId>javax.validation</groupId>
      <artifactId>validation-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.optaplanner</groupId>
      <artifactId>optaplanner-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.optaweb.employeerostering</groupId>
      <artifactId>employee-rostering-shared</artifactId>
    </dependency>
    <dependency>
      <groupId>org.kie.soup</groupId>
      <artifactId>kie-soup-project-datamodel-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.kie.soup</groupId>
      <artifactId>kie-soup-project-datamodel-api</artifactId>
      <classifier>sources</classifier>
    </dependency>
    <dependency>
      <groupId>org.kie.soup</groupId>
      <artifactId>kie-soup-commons</artifactId>
      <classifier>sources</classifier>
    </dependency>
    <dependency>
      <groupId>org.optaweb.employeerostering</groupId>
      <artifactId>employee-rostering-shared-gwt</artifactId>
      <type>gwt-lib</type>
      <!-- Workaround for https://issues.jboss.org/browse/ERRAI-1094 -->
      <exclusions>
        <exclusion>
          <groupId>org.kie</groupId>
          <artifactId>kie-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.drools</groupId>
          <artifactId>drools-core</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.drools</groupId>
          <artifactId>drools-compiler</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <!-- GWT -->
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-user</artifactId>
    </dependency>
    <dependency>
      <groupId>com.github.nmorel.gwtjackson</groupId>
      <artifactId>gwt-jackson</artifactId>
    </dependency>
    <dependency>
      <groupId>com.github.nmorel.gwtjackson</groupId>
      <artifactId>gwt-jackson-rest-processor</artifactId>
    </dependency>
    <dependency>
      <groupId>com.github.nmorel.gwtjackson</groupId>
      <artifactId>gwt-jackson-rest-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.gwtbootstrap3</groupId>
      <artifactId>gwtbootstrap3</artifactId>
    </dependency>
    <dependency>
      <groupId>org.gwtbootstrap3</groupId>
      <artifactId>gwtbootstrap3-extras</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-ioc</artifactId>
    </dependency>
    <!-- kie-parent excludes this from errai-ioc, but it is required for GWT compile -->
    <!-- otherwise it fails with CNFE for com.google.inject.Inject -->
    <dependency>
      <groupId>com.google.inject</groupId>
      <artifactId>guice</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-bus</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-cdi-shared</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-common</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-marshalling</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.elemental2</groupId>
      <artifactId>elemental2-core</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.elemental2</groupId>
      <artifactId>elemental2-dom</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.elemental2</groupId>
      <artifactId>elemental2-promise</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.jsinterop</groupId>
      <artifactId>base</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.jsinterop</groupId>
      <artifactId>jsinterop-annotations</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-cdi-client</artifactId>
    </dependency>
    <dependency><!-- TODO Remove me, we don't use JPA on the client, but removing this gives blank screen at runtime -->
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-jpa-client</artifactId>
      <exclusions>
        <exclusion>
	      <groupId>org.hibernate.javax.persistence</groupId>
	      <artifactId>hibernate-jpa-2.1-api</artifactId>
        </exclusion>
      </exclusions> 	
    </dependency>
    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-javax-enterprise</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-navigation</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-data-binding</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-validation</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-ui</artifactId>
    </dependency>
    <dependency>
      <!-- Only used for EmbeddedWildFlyLauncher during GWT Super Dev Mode -->
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-cdi-jboss</artifactId>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-validator</artifactId>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-validator</artifactId>
      <classifier>sources</classifier>
    </dependency>

    <!-- TESTS -->
    <dependency>
      <groupId>com.google.gwt.gwtmockito</groupId>
      <artifactId>gwtmockito</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-enforcer-plugin</artifactId>
          <executions>
            <execution>
              <id>ban-duplicated-classes</id>
              <configuration>
                <rules>
                  <banDuplicateClasses>
                    <dependencies combine.children="append">
                      <!-- errai-jpa-client contains GWT-friendly implementation of JPA2 and has a compile dependency
                      on org.hibernate.javax.persistence:hibernate-jpa-2.1-api so they have many duplicate classes
                      (e.g. javax.persistence.Entity). On the other hand, hibernate-jpa-2.1-api contains some extra
                      classes that errai-jpa-client doesn't have. If we exclude hibernate-jpa-2.1-api
                      from errai-jpa-client, we get:
                      [main] ERROR org.jboss.errai.config.rebind.AsyncGenerators - Generator failed to launch
                      java.lang.NoClassDefFoundError: javax/persistence/spi/PersistenceUnitInfo
                      The best approach seems to be to keep hibernate-jpa-2.1-api and disable Enforcer.
                      -->
		      <dependency>
                        <groupId>org.jboss.errai</groupId>
                        <artifactId>errai-jpa-client</artifactId>
			<type>jar</type> 
			<ignoreClasses>
                          <ignoreClass>javax.persistence.*</ignoreClass>
		        </ignoreClasses>
	              </dependency>
	            </dependencies> 
                  </banDuplicateClasses>
                </rules>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>net.ltgt.gwt.maven</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        <configuration>
          <moduleName>org.optaweb.employeerostering.gwtui.WorkerRosteringWebapp</moduleName>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack-patternfly</id>
            <phase>process-resources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>org.webjars.bower</groupId>
                  <artifactId>patternfly</artifactId>
                  <version>${version.org.webjars.bower.org.patternfly}</version>
                  <type>jar</type>
                  <overWrite>true</overWrite>
                  <outputDirectory>${project.build.directory}/patternfly</outputDirectory>
                </artifactItem>
                <artifactItem>
                  <groupId>org.webjars</groupId>
                  <artifactId>momentjs</artifactId>
                  <version>${version.org.webjars.momentjs}</version>
                  <type>jar</type>
                  <overWrite>true</overWrite>
                  <outputDirectory>${project.build.directory}/momentjs</outputDirectory>
                </artifactItem>
                <artifactItem>
                  <groupId>org.webjars</groupId>
                  <artifactId>Eonasdan-bootstrap-datetimepicker</artifactId>
                  <version>${version.org.webjars.Eonasdan-bootstrap-datetimepicker}</version>
                  <type>jar</type>
                  <overWrite>true</overWrite>
                  <outputDirectory>${project.build.directory}/bootstrap-datetimepicker</outputDirectory>
                </artifactItem>
              </artifactItems>
              <overWriteReleases>false</overWriteReleases>
              <overWriteSnapshots>true</overWriteSnapshots>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-webjars-resources</id>
            <phase>process-resources</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.outputDirectory}/org/optaweb/employeerostering/gwtui/public/</outputDirectory>
              <resources>
                <resource>
                  <directory>
                    ${project.build.directory}/patternfly/META-INF/resources/webjars/patternfly/${version.org.webjars.bower.org.patternfly}/dist
                  </directory>
                  <includes>
                    <include>**</include>
                  </includes>
                  <excludes>
                    <exclude>tests/**</exclude>
                  </excludes>
                </resource>
                <resource>
                  <directory>
                    ${project.build.directory}/momentjs/META-INF/resources/webjars/momentjs/${version.org.webjars.momentjs}/min
                  </directory>
                  <includes>
                    <include>moment.min.js</include>
                  </includes>
                </resource>
                <resource>
                  <directory>
                    ${project.build.directory}/bootstrap-datetimepicker/META-INF/resources/webjars/Eonasdan-bootstrap-datetimepicker/${version.org.webjars.Eonasdan-bootstrap-datetimepicker}
                  </directory>
                  <includes>
                    <include>js/bootstrap-datetimepicker.js</include>
                    <include>css/bootstrap-datetimepicker.css</include>
                  </includes>
                </resource>
              </resources>
            </configuration>
          </execution>
          <execution>
            <id>copy-javascript-to-gwt</id>
            <phase>process-resources</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.outputDirectory}/org/optaplanner/openshift/employeerostering/gwtui/client/resources/js</outputDirectory>
              <resources>
                <resource>
                  <directory>
                    ${project.build.directory}/momentjs/META-INF/resources/webjars/momentjs/${version.org.webjars.momentjs}/min
                  </directory>
                  <includes>
                    <include>moment.min.js</include>
                  </includes>
                </resource>
                <resource>
                  <directory>
                    ${project.build.directory}/bootstrap-daterangepicker/META-INF/resources/webjars/Eonasdan-bootstrap-datetimepicker/${version.org.webjars.Eonasdan-bootstrap-datetimepicker}/js
                  </directory>
                  <includes>
                    <include>bootstrap-datetimepicker.js</include>
                  </includes>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
