<?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.exoplatform.ecms</groupId>
    <artifactId>exo-ecms-packaging-workflow</artifactId>
    <version>2.3.1</version>
  </parent>
  <artifactId>exo-ecms-packaging-workflow-ear</artifactId>
  <packaging>ear</packaging>
  <name>eXo WORKFLOW Extension configuration ear</name>
  <dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>exo-ecms-packaging-workflow-config</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.jbpm.jbpm3</groupId>
      <artifactId>jbpm-jpdl</artifactId>
      <version>${org.jbpm.jbpm3}</version>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.ecms</groupId>
      <artifactId>exo-ecms-ext-workflow-facade-${workflowEngine}</artifactId>
      <version>${project.version}</version>
    </dependency>

    <dependency>
      <groupId>org.exoplatform.ecms</groupId>
      <artifactId>exo-ecms-ext-workflow-bp-content-plugin</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.ecms</groupId>
      <artifactId>exo-ecms-ext-workflow-bp-content-publication</artifactId>
      <version>${project.version}</version>
    </dependency>		
    <dependency>
      <groupId>org.exoplatform.ecms</groupId>
      <artifactId>exo-ecms-ext-workflow-bp-content-webui</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.ecms</groupId>
      <artifactId>exo-ecms-ext-workflow-bp-${workflowEngine}-content</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.ecms</groupId>
      <artifactId>exo-ecms-ext-workflow-bp-${workflowEngine}-holiday</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.ecms</groupId>
      <artifactId>exo-ecms-ext-workflow-bp-${workflowEngine}-payraise</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.ecms</groupId>
      <artifactId>exo-ecms-ext-workflow-facade-${workflowEngine}</artifactId>
      <version>${project.version}</version>
    </dependency>
		
    <dependency>
      <groupId>org.exoplatform.ecms</groupId>
      <artifactId>exo-ecms-ext-workflow-webui</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>exo-ecms-packaging-workflow-webapp</artifactId>
      <version>${project.version}</version>
      <type>war</type>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>exo-ecms-ext-workflow-portlet-administration</artifactId>
      <version>${project.version}</version>
      <type>war</type>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.ecms</groupId>
      <artifactId>exo-ecms-apps-resources-static</artifactId>
      <version>${project.version}</version>
      <type>war</type>
    </dependency>
		
  </dependencies>
  <build>
    <finalName>gatein-workflow-extension-${project.version}</finalName>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-ear-plugin</artifactId>
        <configuration>
          <displayName>workflow-extension</displayName>
          <defaultLibBundleDir>lib</defaultLibBundleDir>
          <modules>
            <jarModule>
              <groupId>${project.groupId}</groupId>
              <artifactId>exo-ecms-packaging-workflow-config</artifactId>
              <includeInApplicationXml>true</includeInApplicationXml>
            </jarModule>
						<jarModule>
              <groupId>org.jbpm.jbpm3</groupId>
              <artifactId>jbpm-jpdl</artifactId>
              <includeInApplicationXml>true</includeInApplicationXml>
            </jarModule>
						
						<jarModule>
              <groupId>${project.groupId}</groupId>
              <artifactId>exo-ecms-ext-workflow-facade-${workflowEngine}</artifactId>
              <includeInApplicationXml>true</includeInApplicationXml>
            </jarModule>
						
						<jarModule>
              <groupId>${project.groupId}</groupId>
              <artifactId>exo-ecms-ext-workflow-bp-content-plugin</artifactId>
              <includeInApplicationXml>true</includeInApplicationXml>
            </jarModule>
						
						<jarModule>
              <groupId>${project.groupId}</groupId>
              <artifactId>exo-ecms-ext-workflow-bp-content-publication</artifactId>
              <includeInApplicationXml>true</includeInApplicationXml>
            </jarModule>
						
						<jarModule>
              <groupId>${project.groupId}</groupId>
              <artifactId>exo-ecms-ext-workflow-bp-content-webui</artifactId>
              <includeInApplicationXml>true</includeInApplicationXml>
            </jarModule>
						
						<jarModule>
              <groupId>${project.groupId}</groupId>
              <artifactId>exo-ecms-ext-workflow-bp-${workflowEngine}-content</artifactId>
              <includeInApplicationXml>true</includeInApplicationXml>
            </jarModule>
						
						<jarModule>
              <groupId>${project.groupId}</groupId>
              <artifactId>exo-ecms-ext-workflow-bp-${workflowEngine}-holiday</artifactId>
              <includeInApplicationXml>true</includeInApplicationXml>
            </jarModule>
						
						<jarModule>
              <groupId>${project.groupId}</groupId>
              <artifactId>exo-ecms-ext-workflow-bp-${workflowEngine}-payraise</artifactId>
              <includeInApplicationXml>true</includeInApplicationXml>
            </jarModule>
						
						<jarModule>
              <groupId>${project.groupId}</groupId>
              <artifactId>exo-ecms-ext-workflow-webui</artifactId>
              <includeInApplicationXml>true</includeInApplicationXml>
            </jarModule>
            <webModule>
              <groupId>${project.groupId}</groupId>
              <artifactId>exo-ecms-packaging-workflow-webapp</artifactId>
              <contextRoot>ecmworkflow-extension</contextRoot>
              <bundleFileName>ecmworkflow-extension.war</bundleFileName>
            </webModule>
						<webModule>
              <groupId>${project.groupId}</groupId>
              <artifactId>exo-ecms-ext-workflow-portlet-administration</artifactId>
              <contextRoot>workflow</contextRoot>
              <bundleFileName>workflow.war</bundleFileName>
            </webModule>
						
          </modules>
        </configuration>
      </plugin>
      <!-- ########################################### -->
      <!-- HORRIBLE AND DIRTY STEP TO CLEANUP EAR LIBS --> 
      <!-- ########################################### -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>cleanup-deps</id>
            <phase>verify</phase>
            <configuration>
              <tasks>
                <echo>HORRIBLE CLEANUP IN EAR LIBS BECAUSE WE DON'T MANAGE CORRECTLY OUR DEPENDENCIES</echo>
                <echo> 1. We extract the generated EAR because Maven adds some metadata without putting them in the working dir (and we want to keep them).</echo>
                <unjar src="${project.build.directory}/${project.build.finalName}.ear" dest="${project.build.directory}/${project.build.finalName}" />
                <echo> 2. We delete jar files we don't want </echo>
                <delete verbose="true">
                  <fileset dir="${project.build.directory}/${project.build.finalName}/lib/">
                    <exclude name="exo-ecms-ext-workflow-*.jar" />
                    <exclude name="exo-ecms-packaging-workflow-config-*.jar" />
                    <exclude name="jbpm-jpdl-*.jar" />
                  </fileset>
                </delete>
                <echo> 3. We override the EAR generated by maven </echo>
                <ear destfile="${project.build.directory}/${project.build.finalName}.ear" basedir="${project.build.directory}/${project.build.finalName}" appxml="${project.build.directory}/application.xml" />
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
			
    </plugins>
  </build>
</project>
