<?xml version="1.0"?>
<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.gatein.portal</groupId>
      <artifactId>exo.portal.packaging.jboss7</artifactId>
      <version>3.5.0.Beta01</version>
   </parent>

   <artifactId>exo.portal.packaging.jboss7.pkg</artifactId>
   <packaging>pom</packaging>

   <name>GateIn for JBoss AS 7.x.x packaging</name>

   <properties>
      <jbossas.dist.version>${version.jboss.as}</jbossas.dist.version>

      <!--servers.dir>${project.basedir}/../../servers</servers.dir-->
      <jbossas.dir>${servers.dir}/${server.name}</jbossas.dir>
      <gatein.working.dir>${project.build.directory}/jboss</gatein.working.dir>
      <jbossas.target.dir>${gatein.working.dir}</jbossas.target.dir>
   </properties>

   <dependencies>
      <dependency>
         <groupId>org.gatein.portal</groupId>
         <artifactId>jboss-as7-integration-extension</artifactId>
      </dependency>
      <dependency>
         <groupId>org.gatein.portal</groupId>
         <artifactId>jboss-as7-integration-modules</artifactId>
      </dependency>

      <!--                    -->
      <!-- Deployment Modules -->
      <!--                    -->

      <!-- Default Portal -->
      <dependency>
         <groupId>org.gatein.portal</groupId>
         <artifactId>exo.portal.web.eXoResources</artifactId>
         <type>war</type>
      </dependency>
      <dependency>
         <groupId>org.gatein.portal</groupId>
         <artifactId>exo.portal.web.portal</artifactId>
         <type>war</type>
      </dependency>
      <dependency>
         <groupId>org.gatein.portal</groupId>
         <artifactId>exo.portal.gadgets-server</artifactId>
         <type>war</type>
      </dependency>
      <dependency>
         <groupId>org.gatein.portal</groupId>
         <artifactId>exo.portal.eXoGadgets</artifactId>
         <type>war</type>
      </dependency>
      <dependency>
         <groupId>org.gatein.portal</groupId>
         <artifactId>exo.portal.gwtGadgets</artifactId>
         <type>war</type>
      </dependency>
      <dependency>
         <groupId>org.gatein.portal</groupId>
         <artifactId>exo.portal.portlet.web</artifactId>
         <type>war</type>
      </dependency>
      <dependency>
         <groupId>org.gatein.portal</groupId>
         <artifactId>exo.portal.web.rest</artifactId>
         <type>war</type>
      </dependency>
      <dependency>
         <groupId>org.gatein.portal</groupId>
         <artifactId>exo.portal.portlet.exoadmin</artifactId>
         <type>war</type>
      </dependency>
      <dependency>
         <groupId>org.gatein.portal</groupId>
         <artifactId>exo.portal.portlet.dashboard</artifactId>
         <type>war</type>
      </dependency>

      <!--         -->
      <!-- WSRP    -->
      <!--         -->
      <dependency>
         <groupId>org.gatein.integration</groupId>
         <artifactId>extension-war</artifactId>
         <version>${project.version}</version>
         <type>war</type>
      </dependency>
      <dependency>
         <groupId>org.gatein.wsrp</groupId>
         <artifactId>wsrp-producer</artifactId>
         <version>${org.gatein.wsrp.version}</version>
         <type>war</type>
      </dependency>
      <dependency>
         <groupId>org.gatein.wsrp</groupId>
         <artifactId>wsrp-admin-gui</artifactId>
         <version>${org.gatein.wsrp.version}</version>
         <type>war</type>
      </dependency>
      <dependency>
         <groupId>org.gatein.wsrp</groupId>
         <artifactId>wsrp-wss-jboss7</artifactId>
         <version>${org.gatein.wsrp.version}</version>
      </dependency>

      <!--         -->
      <!-- Samples -->
      <!--         -->

      <!-- Sample Portal -->
      <!--dependency>
         <groupId>org.gatein.portal</groupId>
         <artifactId>gatein-sample-portal</artifactId>
         <type>ear</type>
         <version>${project.version}</version>
      </dependency-->
      <dependency>
        <groupId>org.gatein.portal</groupId>
        <artifactId>exo.portal.sample.portal.config</artifactId>
         <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>org.gatein.portal</groupId>
        <artifactId>exo.portal.sample.portal.jar</artifactId>
         <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>org.gatein.portal</groupId>
        <artifactId>exo.portal.sample.portal.war</artifactId>
         <version>${project.version}</version>
        <type>war</type>
      </dependency>
      <dependency>
        <groupId>org.gatein.portal</groupId>
        <artifactId>exo.portal.sample.portal.rest-war</artifactId>
         <version>${project.version}</version>
        <type>war</type>
      </dependency>


      <!-- Sample Extension -->
      <!--dependency>
         <groupId>org.gatein.portal</groupId>
         <artifactId>gatein-sample-extension</artifactId>
         <type>ear</type>
         <version>${project.version}</version>
      </dependency-->
      <dependency>
         <groupId>org.gatein.portal</groupId>
         <artifactId>exo.portal.sample.extension.config</artifactId>
         <version>${project.version}</version>
       </dependency>
       <dependency>
         <groupId>org.gatein.portal</groupId>
         <artifactId>exo.portal.sample.extension.jar</artifactId>
          <version>${project.version}</version>
       </dependency>
       <dependency>
         <groupId>org.gatein.portal</groupId>
         <artifactId>exo.portal.sample.extension.war</artifactId>
          <version>${project.version}</version>
         <type>war</type>
       </dependency>

      <!-- Sample Skin -->
      <dependency>
         <groupId>org.gatein.portal.examples.skins</groupId>
         <artifactId>gatein-sample-skin</artifactId>
         <type>war</type>
      </dependency>

      <!-- Site Redirection Portlet -->
      <dependency>
         <groupId>org.gatein.portal.portlet</groupId>
         <artifactId>redirect</artifactId>
         <type>war</type>
      </dependency>

      <!-- Need to declare this artifact to have access to its path from package.xml -->
      <dependency>
        <groupId>org.gatein.portal</groupId>
        <artifactId>exo.portal.packaging.common</artifactId>
      </dependency>

   </dependencies>

   <build>
      <plugins>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-enforcer-plugin</artifactId>
            <executions>
               <execution>
                  <id>check-servers-dir-specified</id>
                  <goals>
                     <goal>enforce</goal>
                  </goals>
                  <configuration>
                     <rules>
                        <requireProperty>
                           <property>servers.dir</property>
                           <message>"
You need to specify 'servers.dir' directory where you store your application servers (-Dservers.dir=PATH).
"
                           </message>
                        </requireProperty>
                     </rules>
                  </configuration>
               </execution>

               <execution>
                  <id>check-server-dir-exists</id>
                  <goals>
                     <goal>enforce</goal>
                  </goals>
                  <configuration>
                     <rules>
                        <requireFilesExist>
                           <files>
                              <file>${servers.dir}/${server.name}/</file>
                           </files>
                           <message>"
The following JBoss AS directory doesn't exist {servers.dir}/{server.name}:
${servers.dir}/${server.name}

Make JBoss AS instance available at that location, or use -Dservers.dir=PATH to point to the correct location of servers directory
and/or -Dserver.name=NAME (alternatively use -Djboss7.name=NAME) to point to the correct directory under the servers directory.
You can also use -Ddownload to automatically provide JBoss AS instance.
"
                           </message>
                        </requireFilesExist>
                     </rules>
                  </configuration>
               </execution>

            </executions>
         </plugin>
         <plugin>
            <artifactId>maven-clean-plugin</artifactId>
            <executions>
               <execution>
                  <id>auto-clean</id>
                  <phase>initialize</phase>
                  <goals>
                     <goal>clean</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
               <execution>
                  <id>prepare-package</id>
                  <phase>prepare-package</phase>
                  <goals>
                     <goal>run</goal>
                  </goals>
                  <configuration>
                     <target>
                        <ant antfile="${project.basedir}/package.xml" inheritRefs="true">
                           <target name="package" />
                           <!-- without the next line the wrong version.jboss.ass is passed to antrun -->
                           <property name="version.jboss.as" value="${version.jboss.as}" />
                           <property name="maven.project.basedir" value="${project.basedir}" />
                           <property name="maven.project.build.directory" value="${project.build.directory}" />
                        </ant>
                     </target>
                  </configuration>
               </execution>
            </executions>
         </plugin>
      </plugins>
   </build>


   <profiles>

      <profile>
         <id>download</id>
         <activation>
            <property>
               <name>download</name>
            </property>
         </activation>
         <build>
            <plugins>
               <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-enforcer-plugin</artifactId>
                  <executions>
                     <execution>
                        <id>check-server-dir-exists</id>
                        <phase>none</phase>
                     </execution>
                  </executions>
               </plugin>
               <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-antrun-plugin</artifactId>
                  <executions>
                     <execution>
                        <id>prepare-package</id>
                        <phase>prepare-package</phase>
                        <goals>
                           <goal>run</goal>
                        </goals>
                        <configuration>
                           <target>
                              <ant antfile="${project.basedir}/package.xml" inheritRefs="true">
                                 <target name="prepare" />
                                 <!-- without the next line a wrong servers.dir value is passed to antrun -->
                                 <property name="servers.dir" value="${servers.dir}" />
                                 <property name="maven.project.basedir" value="${project.basedir}" />
                                 <property name="maven.project.build.directory" value="${project.build.directory}" />
                              </ant>
                           </target>
                        </configuration>
                     </execution>
                  </executions>
               </plugin>
            </plugins>
         </build>
      </profile>
      <profile>
         <id>bundle</id>
         <properties>
            <release.version>${project.version}</release.version>
         </properties>
         <build>
            <plugins>
               <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-antrun-plugin</artifactId>
                  <executions>
                     <execution>
                        <id>package</id>
                        <phase>package</phase>
                        <goals>
                           <goal>run</goal>
                        </goals>
                        <configuration>
                           <target>
                              <zip destfile="${project.build.directory}/GateIn-${release.version}-jbossas7.zip" basedir="${jbossas.target.dir}" />
                              <attachartifact file="${project.build.directory}/GateIn-${release.version}-jbossas7.zip" classifier="bundle" type="zip" />
                           </target>
                        </configuration>
                     </execution>
                  </executions>
               </plugin>
            </plugins>
         </build>
      </profile>
   </profiles>
</project>
