<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.solacesystems</groupId>
		<artifactId>solsuite</artifactId>
		<version>10.16.0</version>
		<relativePath>../pom.xml</relativePath>
	</parent>

	<groupId>com.solacesystems</groupId>
	<artifactId>sol-jms-ra</artifactId>
	<packaging>rar</packaging>
	<name>Solsuite JMS Resource Adapter</name>
    <description>Solsuite JMS Resource Adapter</description>

	<dependencies>
		<dependency>
			<groupId>com.solacesystems</groupId>
			<artifactId>sol-jms</artifactId>
			<version>${project.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.geronimo.specs</groupId>
                    <artifactId>geronimo-jms_1.1_spec</artifactId>
                </exclusion>
            </exclusions>
		</dependency>
        <dependency>
            <groupId>org.apache.geronimo.specs</groupId>
            <artifactId>geronimo-jms_1.1_spec</artifactId>
            <scope>test</scope>
        </dependency>
		<dependency>
			<groupId>javax</groupId>
			<artifactId>javaee-api</artifactId>
			<version>6.0</version>
            <scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>com.solacesystems</groupId>
			<artifactId>solrconf</artifactId>
			<version>${project.version}</version>
            <scope>test</scope>
		</dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
		<dependency>
			<groupId>com.jcraft</groupId>
			<artifactId>jsch</artifactId>
			<version>0.1.51</version>
            <scope>test</scope>
		</dependency>
	</dependencies>
	<build>
		<plugins>
			<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
			</plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <id>sol-jms-ra</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <finalName>sol-jms-ra-${project.version}</finalName>
                            <excludes>
                                <exclude>**/jboss/**</exclude>
                            </excludes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>sol-jms-object-factory</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <finalName>sol-jms-object-factory-${project.version}</finalName>
                            <includes>
                                <include>**/jboss/**</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>build-helper-maven-plugin</artifactId>
              <version>1.10</version>
              <executions>
                <execution>
                  <id>attach-artifacts</id>
                  <phase>package</phase>
                  <goals>
                    <goal>attach-artifact</goal>
                  </goals>
                  <configuration>
                    <artifacts>
                      <artifact>
                        <file>${project.build.directory}/sol-jms-ra-${project.version}.jar</file>
                        <type>jar</type>
                      </artifact>
                    </artifacts>
                  </configuration>
                </execution>
              </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-rar-plugin</artifactId>
                <configuration>
                    <raXmlFile>src/descriptors/ra.xml</raXmlFile>
                    <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                    <rarSourceDirectory>licenses</rarSourceDirectory>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <dependencies>
                  <dependency>
                    <groupId>com.jcraft</groupId>
                    <artifactId>jsch</artifactId>
                    <version>0.1.51</version>
                  </dependency>
                  <dependency>
                    <groupId>org.apache.ant</groupId>
                    <artifactId>ant-jsch</artifactId>
                    <version>1.9.7</version>
                  </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>generate_ear</id>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <!-- Build the WEBSPHERE EAR for the test framework -->
                                <echo>Building the WEBSPHERE EAR for the test framework</echo>
                                <tempfile property="file.ejb" destdir="target/websphere"
                                          suffix=".jar" deleteonexit="true" />
                                <jar destfile="${file.ejb}">
                                    <!-- TODO: Exclude the unneeded bytecode files -->
                                    <fileset dir="tests" includes="META-INF/*ejb-jar*.xml"/>
                                    <fileset dir="target/test-classes" includes="**/Main.class, **/fw/**"/>
                                </jar>

                                <!-- Build the EAR file -->
                                <delete file="target/websphere/ws-testEAR.ear" />
                                <jar destfile="target/websphere/ws-testEAR.ear">
                                    <fileset dir="tests" includes="META-INF/application.xml"/>
                                    <zipfileset fullpath="testsEJB.jar" file="${file.ejb}" />
                                </jar>

                                <!-- Build the JBOSS EAR for the test framework -->
                                <echo>Building the JBOSS EAR for the test framework</echo>
                                <!-- Preserve this file -->
                                <move file="tests/META-INF/ejb-jar.xml" tofile="tests/META-INF/orig-ejb-jar.xml"/>
                                <!-- Replace it with the JBOSS prepared version -->
                                <copy file="tests/etc/jboss/generated-jboss-ejb-jar.xml" tofile="tests/META-INF/ejb-jar.xml" />
                                <tempfile property="file.jboss.ejb" destdir="target/jboss"
                                          suffix=".jar" deleteonexit="true" />
                                <jar destfile="${file.jboss.ejb}">
                                    <!-- TODO: Exclude the unneeded bytecode files -->
                                    <fileset dir="tests" includes="META-INF/ejb-jar.xml"/>
                                    <fileset dir="target/test-classes" includes="**/Main.class, **/fw/**"/>
                                </jar>
                                <!-- Build the EAR file -->
                                <delete file="target/jboss/jboss-testEAR.ear" />
                                <jar destfile="target/jboss/jboss-testEAR.ear">
                                    <fileset dir="tests" includes="META-INF/application.xml"/>
                                    <zipfileset fullpath="testsEJB.jar" file="${file.jboss.ejb}" />
                                </jar>
                                <!-- Restore the original file -->
                                <move file="tests/META-INF/orig-ejb-jar.xml" tofile="tests/META-INF/ejb-jar.xml"/>

                                <!-- Build the WEBLOGIC EAR for the test framework -->
                                <echo>Building the WEBLOGIC EAR for the test framework</echo>
                                <!-- Preserve this file -->
                                <move file="tests/META-INF/ejb-jar.xml" tofile="tests/META-INF/orig-ejb-jar.xml"/>
                                <!-- Replace it with the JBOSS prepared version -->
                                <copy file="tests/etc/weblogic/generated-ejb-jar.xml" tofile="tests/META-INF/ejb-jar.xml" />
                                <copy file="tests/etc/weblogic/generated-weblogic-ejb-jar.xml" tofile="tests/META-INF/weblogic-ejb-jar.xml" />
                                <tempfile property="file.weblogic.ejb" destdir="target/weblogic"
                                          suffix=".jar" deleteonexit="true" />
                                <jar destfile="${file.weblogic.ejb}">
                                    <!-- TODO: Exclude the unneeded bytecode files -->
                                    <fileset dir="tests" includes="META-INF/ejb-jar.xml,META-INF/weblogic-ejb-jar.xml"/>
                                    <fileset dir="target/test-classes" includes="**/Main.class, **/fw/**"/>
                                </jar>
                                <!-- Build the EAR file -->
                                <delete file="target/weblogic/weblogic-testEAR.ear" />
                                <jar destfile="target/weblogic/weblogic-testEAR.ear">
                                    <fileset dir="tests" includes="META-INF/application.xml"/>
                                    <zipfileset fullpath="testsEJB.jar" file="${file.weblogic.ejb}" />
                                </jar>
                                <!-- Restore the original file -->
                                <move file="tests/META-INF/orig-ejb-jar.xml" tofile="tests/META-INF/ejb-jar.xml"/>
                                <delete file="${basedir}/tests/META-INF/weblogic-ejb-jar.xml" />
                            </target>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy_and_restart</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <skip>${skipTests}</skip>
                            <target>
                                <macrodef name="doSsh">
                                    <attribute name="host" default="" description="The host name"/>
                                    <attribute name="cmd"
                                                description="The command to be executed on remote host via ssh."/>
                                    <attribute name="outprop" default=""/>
                                    <sequential>
                                        <sshexec
                                            host="@{host}"
                                            trust="yes"
                                            username="loadbuild"
                                            password="load7&amp;build"
                                            command="@{cmd} &amp;&gt; /dev/null"
                                            failonerror="true"
                                            outputproperty="@{outprop}"
                                            verbose="true"/>
                                    </sequential>
                                </macrodef>
                                <macrodef name="doScp">
                                    <attribute name="host" default="" description="The host name, ex: user:pass@hostname"/>
                                    <attribute
                                        name="todir"
                                        description="todir attribute for scp ant task"/>
                                    <attribute
                                        name="failonerror"
                                        default="true"
                                        description="Whether scp ant task should fail on error"/>
                                    <element
                                        name="scpargs"
                                        implicit="true"
                                        description="Args to pass to scp ant task"/>
                                    <sequential>
                                        <scp
                                            todir="@{host}:@{todir}"
                                            password="load7&amp;build"
                                            trust="yes"
                                            failonerror="@{failonerror}">
                                            <scpargs/>
                                        </scp>
                                    </sequential>
                                </macrodef>
                                <echo>Cleaning target directory on remote app server host</echo>
                                <doSsh cmd="rm -rf /home/local/solJMSRAIntegrationTesting/artifacts/*" host="dev2-92"/>
                                <echo>Copying files to remote app server host</echo>
                                <doScp host="loadbuild@dev2-92" todir="/home/local/solJMSRAIntegrationTesting/artifacts">
                                    <fileset dir="${basedir}/target">
                                        <include name="*.rar"/>
                                    </fileset>
                                    <fileset dir="${basedir}/target/jboss">
                                        <include name="*.ear"/>
                                    </fileset>
                                    <fileset dir="${basedir}/target/websphere">
                                        <include name="*.ear"/>
                                    </fileset>
                                    <fileset dir="${basedir}/target/weblogic">
                                        <include name="*.ear"/>
                                    </fileset>
                                </doScp>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <jvm>${test.jvm}</jvm>
                    <forkMode>once</forkMode>
                    <skip>${skipTests}</skip>
                </configuration>
                <executions>
                    <execution>
                        <id>default-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </execution>
                    <execution>
                        <id>WebSphere</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <argLine>-Xmx2048m -XX:MaxPermSize=1024m -Xdebug -DOverrideSolace_JMS_VPN=JEETests_was -DUseExternalAppServerType=WebSphere</argLine>
                            <includes>
                                <include>**/SimpleTestCase.java</include>
                                <include>**/OutboundAdapterTestCase.java</include>
                                <include>**/InboundAdapterTestCase.java</include>
                            </includes>
                            <redirectTestOutputToFile>true</redirectTestOutputToFile>
                            <reportsDirectory>${project.build.directory}/surefire-reports-websphere</reportsDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>JBoss</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <argLine>-Xmx1536m -Xdebug -DOverrideSolace_JMS_VPN=JEETests_jboss -DUseExternalAppServerType=JBoss</argLine>
                            <includes>
                                <include>**/SimpleTestCase.java</include>
                                <include>**/OutboundAdapterTestCase.java</include>
                                <include>**/InboundAdapterTestCase.java</include>
                            </includes>
                            <redirectTestOutputToFile>true</redirectTestOutputToFile>
                            <reportsDirectory>${project.build.directory}/surefire-reports-jboss</reportsDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>WebLogic</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <argLine>-Xmx1536m -Xdebug -DOverrideSolace_JMS_VPN=JEETests_wls -DUseExternalAppServerType=WebLogic</argLine>
                            <includes>
                                <include>**/SimpleTestCase.java</include>
                                <include>**/OutboundAdapterTestCase.java</include>
                                <include>**/InboundAdapterTestCase.java</include>
                            </includes>
                            <redirectTestOutputToFile>true</redirectTestOutputToFile>
                            <reportsDirectory>${project.build.directory}/surefire-reports-weblogic</reportsDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
			<plugin>
				<artifactId>maven-assembly-plugin</artifactId>
				<executions>
					<execution>
						<id>assembly</id>
						<goals>
							<goal>single</goal>
						</goals>
						<phase>package</phase>
						<configuration>
							<descriptors>
								<descriptor>internal.xml</descriptor>
								<descriptor>release.xml</descriptor>
							</descriptors>
						</configuration>
					</execution>
				</executions>
			</plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <encoding>cp1252</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.google.code.maven-replacer-plugin</groupId>
                <artifactId>maven-replacer-plugin</artifactId>
                <configuration>
                    <file>src/descriptors/ra.xml.template</file>
                    <outputFile>src/descriptors/ra.xml</outputFile>
                    <replacements>
                        <replacement>
                            <token>@loadversion@</token>
                            <value>${project.version}</value>
                        </replacement>
                    </replacements>
                </configuration>
            </plugin>
        </plugins>
	</build>
</project>
