<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.overlord.dtgov</groupId>
    <artifactId>dtgov</artifactId>
    <version>1.2.0.Final</version>
  </parent>
  <artifactId>dtgov-installer</artifactId>
  <name>Design Time Governance: Community Installer</name>
  <description>Scripts used to install Overlord DTGov into JBoss EAP.</description>

  <dependencies>
    <!-- Overlord Commons -->
    <dependency>
      <groupId>org.overlord</groupId>
      <artifactId>overlord-commons-installer</artifactId>
      <version>${overlord-commons.version}</version>
    </dependency>
    <dependency>
      <groupId>org.overlord</groupId>
      <artifactId>overlord-commons-services</artifactId>
    </dependency>
    <dependency>
      <groupId>org.overlord</groupId>
      <artifactId>overlord-commons-auth</artifactId>
    </dependency>
    <dependency>
      <groupId>org.overlord</groupId>
      <artifactId>overlord-commons-auth-tomcat7</artifactId>
    </dependency>
    <dependency>
      <groupId>org.overlord</groupId>
      <artifactId>overlord-commons-auth-jboss7</artifactId>
    </dependency>
    <dependency>
      <groupId>org.overlord</groupId>
      <artifactId>overlord-commons-idp-eap61</artifactId>
      <version>${overlord-commons.version}</version>
      <type>war</type>
    </dependency>
    <dependency>
      <groupId>org.overlord</groupId>
      <artifactId>overlord-commons-idp-tomcat7</artifactId>
      <version>${overlord-commons.version}</version>
      <type>war</type>
    </dependency>

    <!-- DTGov -->
    <dependency>
      <groupId>org.overlord.dtgov</groupId>
      <artifactId>dtgov-war-eap61</artifactId>
      <version>${project.version}</version>
      <type>war</type>
    </dependency>
    <dependency>
      <groupId>org.overlord.dtgov</groupId>
      <artifactId>dtgov-war-tomcat7</artifactId>
      <version>${project.version}</version>
      <type>war</type>
    </dependency>
    <dependency>
      <groupId>org.overlord.dtgov</groupId>
      <artifactId>dtgov-ui-war-tomcat7</artifactId>
      <version>${project.version}</version>
      <type>war</type>
    </dependency>
    <dependency>
      <groupId>org.overlord.dtgov</groupId>
      <artifactId>dtgov-ui-war-eap61</artifactId>
      <version>${project.version}</version>
      <type>war</type>
    </dependency>
    
    <!-- Data Source and Bean Managed transactions for jBPM, goes into <tomcat>/lib -->
    <!-- See also the README.md on https://github.com/droolsjbpm/kie-wb-distributions/tree/r6.0.0.Final/kie-wb/kie-wb-distribution-wars/src/main/tomcat7 -->
    <dependency>
      <groupId>org.codehaus.btm</groupId>
      <artifactId>btm</artifactId>
      <scope>provided</scope>
    </dependency>
	<dependency>
   	  <groupId>org.codehaus.btm</groupId>
   	  <artifactId>btm-tomcat55-lifecycle</artifactId>
   	  <version>${version.org.codehaus.btm}</version>
   	  <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
      <scope>provided</scope>
	</dependency>
	<dependency>
      <groupId>javax.transaction</groupId>
      <artifactId>jta</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-jdk14</artifactId>
      <version>${version.org.slf4j}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>javax.mail</groupId>
      <artifactId>mail</artifactId>
      <scope>provided</scope>
    </dependency>
  </dependencies>

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>false</filtering>
      </resource>
      <resource>
        <directory>src/main/resources-filtered</directory>
        <filtering>true</filtering>
      </resource>
    </resources>
  </build>

  <profiles>
    <!-- ***************************************** -->
    <!-- Profile to install into EAP 6.1 -->
    <!-- ***************************************** -->
    <profile>
      <id>install-eap61</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.7</version>
            <dependencies>
              <dependency>
                <groupId>ant</groupId>
                <artifactId>ant-trax</artifactId>
                <version>1.6.5</version>
              </dependency>
            </dependencies>
            <executions>
              <execution>
                <id>install-eap61</id>
                <phase>install</phase>
                <configuration>
                  <tasks>
                    <property name="appserver.id" value="jboss-eap-6.1" />
                    <property name="dtgov.install.dir" value="${project.build.directory}" />
                    <property name="dtgov.appserver.dir" location="${dtgov.install.dir}/${appserver.id}" />
                    <property name="dtgov.version" value="${project.version}" />

                    <!-- Overlord Commons Installer and Dependencies -->
                    <property name="dtgov.overlord-commons.installer.jar" value="${maven.dependency.org.overlord.overlord-commons-installer.jar.path}" />
                    <property name="overlord-commons.idp.file" value="${maven.dependency.org.overlord.overlord-commons-idp-eap61.war.path}" />
                    <property name="overlord-commons.services.file" value="${maven.dependency.org.overlord.overlord-commons-services.jar.path}" />
                    <property name="overlord-commons.auth.file" value="${maven.dependency.org.overlord.overlord-commons-auth.jar.path}" />
                    <property name="overlord-commons.auth.tomcat7.file" value="${maven.dependency.org.overlord.overlord-commons-auth-tomcat7.jar.path}" />
                    <property name="overlord-commons.auth.jboss7.file" value="${maven.dependency.org.overlord.overlord-commons-auth-jboss7.jar.path}" />

                    <!-- DTGov WARs -->
                    <property name="dtgov.dtgov-war.path" value="${maven.dependency.org.overlord.dtgov.dtgov-war-eap61.war.path}" />
                    <property name="dtgov.dtgov-ui.path" value="${maven.dependency.org.overlord.dtgov.dtgov-ui-war-eap61.war.path}" />

                    <property file="build.properties" />
                    <property name="dtgov.appserver.zip" value="${basedir}/jboss-eap-6.1.0.zip" />
                    <unzip src="${dtgov.appserver.zip}" dest="${dtgov.install.dir}" overwrite="false" />
                    <chmod perm="a+x" dir="${dtgov.appserver.dir}/bin">
                      <include name="*.sh" />
                    </chmod>

                    <property name="dtgov.temp-installer-dir" value="${project.build.directory}/test-installer" />
                    <delete dir="${dtgov.temp-installer-dir}" />
                    <mkdir dir="${dtgov.temp-installer-dir}" />
                    <copy todir="${dtgov.temp-installer-dir}">
                      <fileset dir="${basedir}/src/main/resources" />
                    </copy>
                    <copy todir="${dtgov.temp-installer-dir}">
                      <fileset dir="${basedir}/src/main/resources-filtered" />
                    </copy>
                    <replace file="${dtgov.temp-installer-dir}/updates/dtgov.properties" value="${project.version}">
                      <replacetoken><![CDATA[${project.version}]]></replacetoken>
                    </replace>
                    <ant dir="${dtgov.temp-installer-dir}" antfile="${dtgov.temp-installer-dir}/build.xml">
                      <target name="install" />
                    </ant>
                  </tasks>
                </configuration>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <!-- ****************************************** -->
    <!-- Profile to install into Tomcat 7 -->
    <!-- ****************************************** -->
    <profile>
      <id>install-tomcat7</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.7</version>
            <dependencies>
              <dependency>
                <groupId>ant</groupId>
                <artifactId>ant-trax</artifactId>
                <version>1.6.5</version>
              </dependency>
            </dependencies>
            <executions>
              <execution>
                <id>install-tomcat7</id>
                <phase>install</phase>
                <configuration>
                  <tasks>
                    <property name="appserver.id" value="tomcat-7" />
                    <property name="dtgov.install.dir" value="${project.build.directory}" />
                    <property name="dtgov.appserver.dir" location="${dtgov.install.dir}/apache-tomcat-${tomcat.version}" />
                    <property name="dtgov.version" value="${project.version}" />

                    <!-- BMT Dependencies in tomcat/lib -->
                    <property name="lib.btm.jar" value="${maven.dependency.org.codehaus.btm.btm.jar.path}" />
                    <property name="lib.btm-tomcat55-lifecycle.jar" value="${maven.dependency.org.codehaus.btm.btm-tomcat55-lifecycle.jar.path}" />
                    <property name="lib.h2.jar" value="${maven.dependency.com.h2database.h2.jar.path}" />
                    <property name="lib.jta.jar" value="${maven.dependency.javax.transaction.jta.jar.path}" />
                    <property name="lib.slf4j-api.jar" value="${maven.dependency.org.slf4j.slf4j-api.jar.path}" />
                    <property name="lib.slf4j-jdk14.jar" value="${maven.dependency.org.slf4j.slf4j-jdk14.jar.path}" />
                    <!-- email -->
					<property name="lib.mail.jar" value="${maven.dependency.javax.mail.mail.jar.path}" />
                    
                    <!-- Overlord Commons Installer and Dependencies -->
                    <property name="dtgov.overlord-commons.installer.jar" value="${maven.dependency.org.overlord.overlord-commons-installer.jar.path}" />
                    <property name="overlord-commons.idp.file" value="${maven.dependency.org.overlord.overlord-commons-idp-tomcat7.war.path}" />
                    <property name="overlord-commons.services.file" value="${maven.dependency.org.overlord.overlord-commons-services.jar.path}" />
                    <property name="overlord-commons.auth.file" value="${maven.dependency.org.overlord.overlord-commons-auth.jar.path}" />
                    <property name="overlord-commons.auth.tomcat7.file" value="${maven.dependency.org.overlord.overlord-commons-auth-tomcat7.jar.path}" />
					
					

                    <!-- DTGov WARs -->
                    <property name="dtgov.dtgov-war-tc7.path" value="${maven.dependency.org.overlord.dtgov.dtgov-war-tomcat7.war.path}" />
                    <property name="dtgov.dtgov-ui-tc7.path" value="${maven.dependency.org.overlord.dtgov.dtgov-ui-war-tomcat7.war.path}" />

                    <property file="build.properties" />
                    <property name="dtgov.appserver.zip" value="${basedir}/apache-tomcat-7.0.52.zip" />
                    <unzip src="${dtgov.appserver.zip}" dest="${dtgov.install.dir}" overwrite="false" />
                    <chmod perm="a+x" dir="${dtgov.appserver.dir}/bin">
                      <include name="*.sh" />
                    </chmod>

                    <property name="dtgov.temp-installer-dir" value="${project.build.directory}/test-installer" />
                    <delete dir="${dtgov.temp-installer-dir}" />
                    <mkdir dir="${dtgov.temp-installer-dir}" />
                    <copy todir="${dtgov.temp-installer-dir}">
                      <fileset dir="${basedir}/src/main/resources" />
                    </copy>
                    <copy todir="${dtgov.temp-installer-dir}">
                      <fileset dir="${basedir}/src/main/resources-filtered" />
                    </copy>
                    <replace file="${dtgov.temp-installer-dir}/updates/dtgov.properties">
                      <replacetoken><![CDATA[dtgov.workflows.version]]></replacetoken>
                      <replacevalue><![CDATA[#dtgov.workflows.version]]></replacevalue>
                    </replace>

                    <ant dir="${dtgov.temp-installer-dir}" antfile="${dtgov.temp-installer-dir}/build.xml">
                      <target name="install" />
                    </ant>
                  </tasks>
                </configuration>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- Profile to seed S-RAMP with dtgov data -->
    <profile>
      <id>seed</id>
      <dependencies>
        <dependency>
          <groupId>org.overlord.sramp</groupId>
          <artifactId>s-ramp-distro-assembly-cli</artifactId>
          <version>${s-ramp.version}</version>
          <type>zip</type>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.7</version>
            <dependencies>
              <dependency>
                <groupId>ant</groupId>
                <artifactId>ant-trax</artifactId>
                <version>1.6.5</version>
              </dependency>
            </dependencies>
            <executions>
              <execution>
                <id>seed</id>
                <phase>install</phase>
                <configuration>
                  <tasks>
                    <property name="appserver.id" value="jboss-as-7.1.1.Final" />
                    <property file="build.properties" />
                    <property name="dtgov.s-ramp.cli.zip" value="${maven.dependency.org.overlord.sramp.s-ramp-distro-assembly-cli.zip.path}" />
                    <unzip src="${dtgov.s-ramp.cli.zip}" dest="${project.build.directory}" overwrite="true" />
                    <property name="dtgov.s-ramp.cli.jar" value="${project.build.directory}/s-ramp-cli-${s-ramp.version}/bin/s-ramp-shell-${s-ramp.version}.jar" />
                    <ant dir="${basedir}/src/main/resources" antfile="${basedir}/src/main/resources/build.xml">
                      <target name="seed" />
                    </ant>
                  </tasks>
                </configuration>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

  </profiles>
</project>