<?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.platform</groupId>
    <artifactId>exo.platform.packaging</artifactId>
    <version>3.5.0-Beta3</version>
  </parent>
  <artifactId>exo.platform.packaging.jboss</artifactId>
  <packaging>pom</packaging>
  <name>eXo Platform - Packaging JBoss</name>

	<profiles>
	  <profile>
	  <id>pkg-jboss</id>
	  <dependencies>
		<dependency>
			<groupId>org.exoplatform.platform</groupId>
			<artifactId>exo.platform.packaging.jbossears</artifactId>
			<version>${project.version}</version>
		    <type>zip</type>
		</dependency>
	  </dependencies>
	  <build>
		<finalName>eXo-Platform-jboss-bundle-${project.version}</finalName>
		<plugins>
		  <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.jbosseap.version</property>
		              <message>You must define the property exo.projects.app.jbosseap.version to give
		                       the name of the directory where is stored JBoss EAP</message>
		            </requireProperty>
		            <requireFilesExist>
		              <files>
		                <file>${exo.projects.directory.dependencies}/${exo.projects.app.jbosseap.version}/</file>
		              </files>
		              <message>The following JBoss EAP directory doesn't exist :
		                       ${exo.projects.directory.dependencies}/${exo.projects.app.jbosseap.version}</message>
		            </requireFilesExist>
		          </rules>
		          <fail>true</fail>
		        </configuration>
		      </execution>
		    </executions>
		  </plugin>
		  <!-- JBoss Packaging -->
		  <!-- Copy the reference JBoss EAP to target -->
		  <plugin>
		    <artifactId>maven-resources-plugin</artifactId>
		    <version>2.4.3</version>
		    <executions>
		      <execution>
		        <id>01-copy-jbosseap-package</id>
		        <phase>prepare-package</phase>
		        <goals>
		          <goal>copy-resources</goal>
		        </goals>
		        <configuration>
		          <outputDirectory>${project.build.directory}/jboss</outputDirectory>
		          <includeEmptyDirs>true</includeEmptyDirs>
		          <resources>
		            <resource>
		              <directory>${exo.projects.directory.dependencies}/${exo.projects.app.jbosseap.version}/</directory>
		              <filtering>false</filtering>
		            </resource>
		          </resources>
		        </configuration>
		      </execution>
		      <execution>
		        <id>03-copy-ears-and-conf</id>
		        <phase>package</phase>
		        <goals>
		          <goal>copy-resources</goal>
		        </goals>
		        <configuration>
		          <outputDirectory>${project.build.directory}/jboss</outputDirectory>
		          <includeEmptyDirs>true</includeEmptyDirs>
	              <overwrite>true</overwrite>
		          <resources>
		            <resource>
		              <directory>${project.build.directory}/jbossears/ears</directory>
		              <filtering>false</filtering>
		            </resource>
		          </resources>
		        </configuration>
		      </execution>
		    </executions>
		  </plugin>
		  <!-- Extract the EARs package -->
		  <plugin>
		    <groupId>org.apache.maven.plugins</groupId>
		    <artifactId>maven-dependency-plugin</artifactId>
		    <executions>
		      <execution>
		         <id>02-unpack-jbosseap-ears</id>
		         <phase>prepare-package</phase>
		         <goals>
		           <goal>unpack</goal>
		         </goals>
		         <configuration>
		           <outputDirectory>${project.build.directory}/jbossears</outputDirectory>
		           <artifactItems>
					<artifactItem>
						<groupId>org.exoplatform.platform</groupId>
						<artifactId>exo.platform.packaging.jbossears</artifactId>
						<version>${project.version}</version>
						<type>zip</type>
					</artifactItem>
		           </artifactItems>
		         </configuration>
		       </execution>
		    </executions>
		  </plugin>
		</plugins>
	  </build>
    </profile>
  </profiles>
</project>
