<?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>com.exoplatform.platform.cloud</groupId>
    <artifactId>exo.platform.cloud.packaging</artifactId>
    <version>3.5.0-Beta3</version>
  </parent>
  <artifactId>exo.platform.packaging.tomcat</artifactId>
  <packaging>pom</packaging>
  <name>eXo Platform - Cloud Packaging Tomcat</name>
  <dependencies>
    <dependency>
      <groupId>org.exoplatform.tool</groupId>
      <artifactId>exopackage</artifactId>
      <version>${org.exoplatform.exopackage.version}</version>
      <type>zip</type>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.platform</groupId>
      <artifactId>exo.platform.packaging.tomcat</artifactId>
      <version>${project.version}</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.platform</groupId>
      <artifactId>platform.packaging.module</artifactId>
      <version>${project.version}</version>
      <type>js</type>
    </dependency>

    <!-- eXo Cloud -->
    <dependency>
      <groupId>com.exoplatform.platform.cloud</groupId>
      <artifactId>exo.platform.cloud.server.tomcat.patch</artifactId>
      <version>${project.version}</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>com.exoplatform.platform.cloud</groupId>
      <artifactId>platform.cloud.packaging.module</artifactId>
      <version>${project.version}</version>
      <type>js</type>
    </dependency>
    <dependency>
      <groupId>com.exoplatform.platform.cloud</groupId>
      <artifactId>platform.cloud.packaging.product</artifactId>
      <version>${project.version}</version>
      <type>js</type>
    </dependency>
    <dependency>
      <groupId>com.exoplatform.platform.cloud</groupId>
      <artifactId>exo.platform.cloud.extension.config</artifactId>
      <version>${project.version}</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>com.exoplatform.platform.cloud</groupId>
      <artifactId>exo.platform.cloud.extension.webapp</artifactId>
      <version>${project.version}</version>
      <type>war</type>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.cloud-management</groupId>
      <artifactId>cloud-agent</artifactId>
      <version>${org.exoplatform.cloud-management.version}</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.cloud-management</groupId>
      <artifactId>cloud-admin-valve</artifactId>
      <version>${org.exoplatform.cloud-management.version}</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.cloud-management</groupId>
      <artifactId>cloud-instrument</artifactId>
      <version>${org.exoplatform.cloud-management.version}</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.cloud-management</groupId>
      <artifactId>cloud-multitenancy</artifactId>
      <version>${org.exoplatform.cloud-management.version}</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.cloud-management</groupId>
      <artifactId>cloud-services-common</artifactId>
      <version>${org.exoplatform.cloud-management.version}</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.cloud-management</groupId>
      <artifactId>cloud-rest</artifactId>
      <version>${org.exoplatform.cloud-management.version}</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.cloud-management</groupId>
      <artifactId>cloud-rest-groovy</artifactId>
      <version>${org.exoplatform.cloud-management.version}</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.cloud-management</groupId>
      <artifactId>cloud-security</artifactId>
      <version>${org.exoplatform.cloud-management.version}</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.cloud-management</groupId>
      <artifactId>cloud-statistic</artifactId>
      <version>${org.exoplatform.cloud-management.version}</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.cloud-management</groupId>
      <artifactId>cloud-tomcat-valve</artifactId>
      <version>${org.exoplatform.cloud-management.version}</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.cloud-management</groupId>
      <artifactId>cloud-multitenant-rest-services</artifactId>
      <version>${org.exoplatform.cloud-management.version}</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.cloud-management</groupId>
      <artifactId>cloud-instrument-runtime</artifactId>
      <version>${org.exoplatform.cloud-management.version}</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.cloud-management</groupId>
      <artifactId>cloud-logback-logging</artifactId>
      <version>${org.exoplatform.cloud-management.version}</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.cloud-management</groupId>
      <artifactId>cloud-agent-war</artifactId>
      <version>${org.exoplatform.cloud-management.version}</version>
      <type>war</type>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.cloud-management</groupId>
      <artifactId>cloud-admin-war</artifactId>
      <version>${org.exoplatform.cloud-management.version}</version>
      <type>war</type>
    </dependency>
    <dependency>
      <groupId>org.exoplatform</groupId>
      <artifactId>exo-jcr-services</artifactId>
      <version>${org.exoplatform.jcr-services.version}</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>asm</groupId>
      <artifactId>asm</artifactId>
      <version>${asm.version}</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>asm</groupId>
      <artifactId>asm-commons</artifactId>
      <version>${asm.version}</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>asm</groupId>
      <artifactId>asm-util</artifactId>
      <version>${asm.version}</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>asm</groupId>
      <artifactId>asm-analysis</artifactId>
      <version>${asm.version}</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-core</artifactId>
      <version>0.9.20</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>0.9.20</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>mx4j</groupId>
      <artifactId>mx4j-tools</artifactId>
      <version>3.0.1</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>${commons-io.version}</version>
    </dependency>
    <!-- for Cloud distro -->
    <dependency>
      <groupId>org.exoplatform.jcr</groupId>
      <artifactId>exo.jcr.applications.backupconsole.dist</artifactId>
      <version>${org.exoplatform.jcr.version}</version>
      <type>zip</type>
    </dependency>
   <dependency><groupId>org.apache.tomcat</groupId><artifactId>tomcat-catalina-jmx-remote</artifactId><version>${org.apache.tomcat.version}</version><type>jar</type></dependency><!-- 6.0.32-->
    <dependency><groupId>org.slf4j</groupId><artifactId>jul-to-slf4j</artifactId><version>${org.slf4j.version}</version><type>jar</type></dependency><!-- 1.5.8-->
    <dependency><groupId>org.slf4j</groupId><artifactId>jcl-over-slf4j</artifactId><version>${org.slf4j.version}</version><type>jar</type></dependency><!-- 1.5.8-->
  </dependencies>

  <profiles>
    <profile>
      <id>cloud</id>
      <build>
        <finalName>Platform-Cloud-${project.version}</finalName>
        <plugins>
          <!-- check-out exobuild -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>unpack-dependencies</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <configuration>
                  <overWriteSnapshots>true</overWriteSnapshots>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.exoplatform.tool</groupId>
                      <artifactId>exopackage</artifactId>
                      <type>zip</type>
                      <outputDirectory>target/exopackage</outputDirectory>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
              <execution>
                <id>unpack-backup-console</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <configuration>
                  <overWriteSnapshots>true</overWriteSnapshots>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.exoplatform.jcr</groupId>
                      <artifactId>exo.jcr.applications.backupconsole.dist</artifactId>
                      <type>zip</type>
                      <outputDirectory>target/backup_console</outputDirectory>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
              <execution>
                <id>copy-dependencies</id>
                <phase>compile</phase>
                <goals>
                  <goal>copy-dependencies</goal>
                </goals>
                <configuration>
                  <includeTypes>js</includeTypes>
                  <stripVersion>true</stripVersion>
                  <outputDirectory>${project.build.directory}/exopackage-conf</outputDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <!-- Ensure your environment is correctly setup -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-enforcer-plugin</artifactId>
            <executions>
              <execution>
                <id>check-environment-ready</id>
                <goals>
                  <goal>enforce</goal>
                </goals>
                <configuration>
                  <rules>
                    <requireProperty>
                      <property>exo.projects.directory.dependencies</property>
                      <message>You must define the property exo.projects.directory.dependencies to
                        give the path to the directory where you store your applications servers</message>
                    </requireProperty>
                    <requireProperty>
                      <property>exo.projects.app.tomcat.version</property>
                      <message>You must define the property exo.projects.app.tomcat.version to
                        give the name of the directory where is stored tomcat</message>
                    </requireProperty>
                    <requireFilesExist>
                      <files>
                        <file>${exo.projects.directory.dependencies}/${exo.projects.app.tomcat.version}/</file>
                      </files>
                      <message>The following Tomcat directory doesn't exist :
                        ${exo.projects.directory.dependencies}/${exo.projects.app.tomcat.version}</message>
                    </requireFilesExist>
                  </rules>
                  <fail>true</fail>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <!-- run eXoBuild -->
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>tomcat-exopackage</id>
                <phase>package</phase>
                <configuration>
                  <executable>java</executable>
                  <workingDirectory>${basedir}</workingDirectory>
                  <arguments>
                    <argument>-Dexo.package.home=${basedir}/target/exopackage</argument>
                    <argument>-Dexo.current.dir=${basedir}</argument>
                    <argument>-Dexo.base.dir=${exo.projects.directory.base}</argument>
                    <argument>-Dexo.conf.dir=${basedir}/target/exopackage-conf</argument>
                    <argument>-Dexo.working.dir=${basedir}/target</argument>
                    <argument>-Dexo.dep.dir=${exo.projects.directory.dependencies}</argument>
                    <argument>-Dexo.m2.repos=file:${settings.localRepository}</argument>
                    <argument>-Dclean.server=${exo.projects.app.tomcat.version}</argument>
                    <argument>-Dexo.m2.home=${maven.home}</argument>
                    <argument>-Xshare:auto</argument>
                    <argument>-Xms128m</argument>
                    <argument>-Xmx1220m</argument>
                    <argument>-XX:MaxPermSize=128M</argument>
                    <argument>-classpath</argument>
                    <argument>${basedir}/target/exopackage/lib/js.jar</argument>
                    <argument>org.mozilla.javascript.tools.shell.Main</argument>
                    <argument>${basedir}/target/exopackage/javascript/eXo/eXo.js</argument>
                    <argument>exobuild</argument>
                    <argument>--product=platform.cloud</argument>
                    <argument>--deploy=tomcat</argument>
                    <argument>--enable-workflow=${exo.workflow.engine}</argument>
                  </arguments>
                </configuration>
                <goals>
                  <goal>exec</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
<!--
 |
 | The distrib profile is called by hudson to generate the official packages:
 |  - tomcat
 |  - ears and configuration for JBoss EAP
 |  - chatserver
 |
 -->
    <profile>
      <id>cloud-distrib</id>
      <build>
        <plugins>
          <!-- create zip archives -->
          <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
              <execution>
                <id>assembly</id>
                <phase>package</phase>
                <goals>
                  <goal>single</goal>
                </goals>
                <configuration>
                  <descriptors>
                    <descriptor>src/main/assembly/tomcat-archive.xml</descriptor>
                    <descriptor>src/main/assembly/chatserver-archive.xml</descriptor>
                  </descriptors>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
