<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">

    <parent>
        <groupId>org.wso2.wsas</groupId>
        <artifactId>org.wso2.wsas</artifactId>
        <version>2.0-beta</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>wso2wsas-integration</artifactId>
    <packaging>jar</packaging>
    <name>WSO2 Web Services Application Server - Integration</name>

    <dependencies>

        <!-- WSAS Dependencies -->
        <dependency>
            <groupId>org.wso2.wsas</groupId>
            <artifactId>wso2wsas-core</artifactId>
            <version>${pom.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.wso2.wsas</groupId>
            <artifactId>wso2wsas-admin</artifactId>
            <version>${pom.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.wso2.wsas</groupId>
            <artifactId>wso2wsas-samples-chad</artifactId>
            <version>${pom.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.wso2.wsas</groupId>
            <artifactId>wso2wsas-samples-commodityquote</artifactId>
            <version>${pom.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.wso2.wsas</groupId>
            <artifactId>wso2wsas-samples-Javascript-service</artifactId>
            <version>${pom.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.wso2.wsas</groupId>
            <artifactId>wso2wsas-samples-tinyurl</artifactId>
            <version>${pom.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.wso2.wsas</groupId>
            <artifactId>wso2wsas-samples-trader</artifactId>
            <version>${pom.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.wso2.wsas</groupId>
            <artifactId>wso2wsas-core</artifactId>
            <version>${pom.version}</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>

        <!-- System dependency -->
        <dependency>
            <groupId>sun.jdk</groupId>
            <artifactId>tools</artifactId>
            <version>${java.version}</version>
            <scope>system</scope>
            <!--<systemPath>${java.home}/../lib/tools.jar</systemPath>-->
            <systemPath>${toolsjar}</systemPath>
        </dependency>

    </dependencies>

    <build>
        <sourceDirectory>src</sourceDirectory>
        <testSourceDirectory>test</testSourceDirectory>

        <testResources>
            <testResource>
                <directory>../core/test-resources</directory>
                <includes>
                    <include>**/*.cfg.xml</include>
                </includes>
            </testResource>
            <testResource>
                <directory>../core/conf/hibernate</directory>
                <includes>
                    <include>**/*.hbm.xml</include>
                </includes>
            </testResource>
            <testResource>
                <directory>../core/conf</directory>
                <includes>
                    <include>**/*.properties</include>
                </includes>
            </testResource>
        </testResources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.4</source>
                    <target>1.4</target>
                </configuration>
            </plugin>


            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <inherited>false</inherited>
                <configuration>
                    <forkMode>pertest</forkMode>
                    <argLine>-enableassertions</argLine>
                    <testFailureIgnore>false</testFailureIgnore>
                    <skip>false</skip>
                    <forkMode>pertest</forkMode>
                    <argLine>-enableassertions</argLine>
                    <includes>
                        <include>**/*IntegrationTestSuite.java</include>
                    </includes>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>

                    <execution>
                        <id>create_repo</id>
                        <phase>generate-test-resources</phase>
                        <configuration>
                            <tasks>

                                <mkdir dir="target/test-classes"/>
                                <mkdir dir="target/tmp/service"/>

                                <copy file="test-resources/META-INF/integration-services.xml"
                                      tofile="target/tmp/service/META-INF/services.xml"/>
                                <jar jarfile="target/wso2wsas-test-integration.aar"
                                     basedir="target/tmp/service">
                                    <include name="**"/>
                                </jar>

                                <delete dir="target/tmp"/>

                                <copy todir="target/tomcat_test">
                                    <fileset dir="../core/target/tomcat_test"/>
                                </copy>

                                <copy todir="target/tomcat_test/repository/modules"
                                      file="../admin/target/wso2wsas-admin-${wso2wsas.version}.mar"/>
                                <copy file="target/wso2wsas-test-integration.aar"
                                      tofile="target/tomcat_test/repository/services/wso2wsas-test-integration.aar"/>

                                <copy file="../core/target/version.aar"
                                      tofile="target/tomcat_test/repository/services/version.aar"/>

                                <!-- Commodityquote integration test -->
                                <property name="test_service_repo"
                                          value="target/tomcat_test/repository/services"/>
                                <property name="CQ.dir"
                                          value="${test_service_repo}/CommodityQuote"/>
                                <mkdir dir="${CQ.dir}"/>

                                <mkdir dir="${CQ.dir}/META-INF"/>
                                <copy file="../samples/CommodityQuote/conf/services.xml"
                                      tofile="${CQ.dir}/META-INF/services.xml"/>
                                <copy file="../samples/CommodityQuote/wsdl/CommodityQuote.wsdl"
                                      tofile="${CQ.dir}/META-INF/service.wsdl"/>
                                <copy toDir="${CQ.dir}">
                                    <fileset dir="../samples/CommodityQuote/target/classes">
                                        <include name="**/services/**/*.class"/>
                                    </fileset>
                                </copy>

                                <!-- Trader service integration test -->

                                <property name="TC.dir" value="${test_service_repo}/TraderClient"/>
                                <mkdir dir="${TC.dir}"/>

                                <mkdir dir="${TC.dir}/META-INF"/>
                                <copy file="../samples/Trader/conf/Trader_Client_services.xml"
                                      tofile="${TC.dir}/META-INF/services.xml"/>
                                <copy file="../samples/Trader/wsdl/Trader_Client.wsdl"
                                      tofile="${TC.dir}/META-INF/service.wsdl"/>


                                <property name="TE.dir"
                                          value="${test_service_repo}/TraderExchange"/>
                                <mkdir dir="${TE.dir}"/>

                                <mkdir dir="${TE.dir}/META-INF"/>
                                <copy file="../samples/Trader/conf/Trader_Exchange_services.xml"
                                      tofile="${TE.dir}/META-INF/services.xml"/>
                                <copy file="../samples/Trader/wsdl/Trader_Exchange.wsdl"
                                      tofile="${TE.dir}/META-INF/service.wsdl"/>


                                <property name="BE.dir"
                                          value="${test_service_repo}/ExchangeClient"/>
                                <mkdir dir="${BE.dir}"/>

                                <mkdir dir="${BE.dir}/META-INF"/>
                                <copy file="../samples/Trader/conf/Exchange_Client_services.xml"
                                      tofile="${BE.dir}/META-INF/services.xml"/>
                                <copy file="../samples/Trader/wsdl/Exchange_Client.wsdl"
                                      tofile="${BE.dir}/META-INF/service.wsdl"/>

                                <property name="ET.dir"
                                          value="${test_service_repo}/ExchangeTrader"/>
                                <mkdir dir="${ET.dir}"/>

                                <mkdir dir="${ET.dir}/META-INF"/>
                                <copy file="../samples/Trader/conf/Exchange_Trader_services.xml"
                                      tofile="${ET.dir}/META-INF/services.xml"/>
                                <copy file="../samples/Trader/wsdl/Exchange_Trader.wsdl"
                                      tofile="${ET.dir}/META-INF/service.wsdl"/>


                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>

    </build>

</project>
