<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~  Licensed to the Apache Software Foundation (ASF) under one
  ~  or more contributor license agreements.  See the NOTICE file
  ~  distributed with this work for additional information
  ~  regarding copyright ownership.  The ASF licenses this file
  ~  to you under the Apache License, Version 2.0 (the
  ~  "License"); you may not use this file except in compliance
  ~  with the License.  You may obtain a copy of the License at
  ~
  ~   http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~  Unless required by applicable law or agreed to in writing,
  ~  software distributed under the License is distributed on an
  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  ~  KIND, either express or implied.  See the License for the
  ~  specific language governing permissions and limitations
  ~  under the License.
  -->

<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.apache.synapse</groupId>
        <artifactId>Apache-Synapse</artifactId>
        <version>1.1</version>
    </parent>

    <groupId>org.apache.synapse</groupId>
    <artifactId>synapse-samples</artifactId>

    <name>Apache Synapse - Samples</name>
    <description>Apache Synapse - Samples</description>
    <packaging>jar</packaging>

    <profiles>
        <profile>
            <id>integration</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.1</version>
                        <executions>
                            <execution>
                                <id>create_repo</id>
                                <phase>generate-test-resources</phase>
                                <configuration>
                                    <tasks>
                                        <echo message="*** Creating a sample n2n testing repository ***"/>

                                        <mkdir dir="target/test_repos"/>
                                        <mkdir dir="target/test_repos/axis2Server"/>
                                        <mkdir dir="target/test_repos/axis2Client"/>
                                        <mkdir dir="target/test_repos/synapse"/>
                                        <mkdir dir="target/test_repos/synapse"/>
                                        <mkdir dir="target/test_repos/synapse/modules"/>
                                        <mkdir dir="target/test_repos/synapse/conf"/>
                                        <mkdir dir="target/test_repos/axis2Server/services"/>
                                        <mkdir dir="target/test_repos/axis2Server/modules"/>
                                        <mkdir dir="target/test_repos/axis2Server/conf"/>
                                        <mkdir dir="target/test_repos/axis2Client/modules"/>
                                        <mkdir dir="target/test_repos/axis2Client/conf"/>

                                        <copy file="../../repository/conf/sample/resources/misc/server/axis2.xml"
                                              tofile="target/test_repos/axis2Server/conf/axis2.xml"/>
                                        <copy file="../../repository/conf/sample/resources/misc/client/axis2.xml"
                                              tofile="target/test_repos/axis2Client/conf/axis2.xml"/>
                                        <copy file="../../repository/conf/axis2.xml"
                                              tofile="target/test_repos/synapse/conf/axis2.xml"/>
                                        <copy file="../core/src/main/resources/synapseIdentity.jks"
                                              tofile="target/test_repos/synapse/conf/synapseIdentity.jks"/>
                                        <copy file="../core/src/main/resources/axis2Identity.jks"
                                              tofile="target/test_repos/synapse/conf/axis2Identity.jks"/>
                                        <copy file="../core/src/main/resources/trust.jks"
                                              tofile="target/test_repos/synapse/conf/trust.jks"/>
                                        <copy file="../core/src/main/resources/identity.jks"
                                              tofile="target/test_repos/synapse/conf/identity.jks"/>
                                        <copy file="../core/src/main/resources/axis2Trust.jks"
                                              tofile="target/test_repos/synapse/conf/axis2Trust.jks"/>
                                        <copy file="../core/src/main/resources/synapseTrust.jks"
                                              tofile="target/test_repos/synapse/conf/synapseTrust.jks"/>
                                        <copy file="../core/src/test/resources/keystore.jks"
                                              tofile="target/test_repos/synapse/conf/keystore.jks"/>

                                        <property name="temp.dir" value="target/temp"/>
                                        <property name="classes" value="${temp.dir}/classes"/>
                                        <property name="services"
                                                  value="target/test_repos/axis2Server/services"/>

                                        <property name="src"
                                                  value="services/SimpleStockQuoteService/src"/>

                                        <mkdir dir="${temp.dir}"/>
                                        <mkdir dir="${classes}"/>

                                        <javac debug="on" destdir="${classes}" fork="true">
                                            <src path="${src}"/>
                                            <classpath refid="maven.compile.classpath"/>
                                        </javac>

                                        <property name="SSQ.dir"
                                                  value="${temp.dir}/SimpleStockQuote"/>
                                        <mkdir dir="${SSQ.dir}"/>

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

                                        <jar destfile="${services}/SimpleStockQuoteService.aar">
                                            <fileset dir="${SSQ.dir}"/>
                                        </jar>

                                        <property name="src2"
                                                  value="services/SecureStockQuoteService/src"/>
                                        <delete dir="${temp.dir}"/>
                                        <mkdir dir="${temp.dir}"/>
                                        <mkdir dir="${classes}"/>
                                        <javac debug="on" destdir="${classes}" fork="true">
                                            <src path="${src2}"/>
                                            <classpath refid="maven.compile.classpath"/>
                                        </javac>
                                        <property name="SSQ2.dir"
                                                  value="${temp.dir}/SecureStockQuoteService"/>
                                        <mkdir dir="${SSQ2.dir}"/>
                                        <mkdir dir="${SSQ2.dir}/META-INF"/>
                                        <copy file="${src2}/../conf/services.xml"
                                              tofile="${SSQ2.dir}/META-INF/services.xml"/>
                                        <copy file="${src2}/../wsdl/SimpleStockQuoteService.wsdl"
                                              tofile="${SSQ2.dir}/META-INF/service.wsdl"/>
                                        <copy file="${src2}/../store.jks"
                                              tofile="${SSQ2.dir}/store.jks"/>
                                        <copy toDir="${SSQ2.dir}">
                                            <fileset dir="${classes}">
                                                <include name="**/*.class"/>
                                            </fileset>
                                        </copy>
                                        <jar destfile="${services}/SecureStockQuoteService.aar">
                                            <fileset dir="${SSQ2.dir}"/>
                                        </jar>

                                        <property name="src3"
                                                  value="services/MTOMSwASampleService/src"/>
                                        <delete dir="${temp.dir}"/>
                                        <mkdir dir="${temp.dir}"/>
                                        <mkdir dir="${classes}"/>
                                        <javac debug="on" destdir="${classes}" fork="true">
                                            <src path="${src3}"/>
                                            <classpath refid="maven.compile.classpath"/>
                                        </javac>
                                        <property name="SSQ3.dir"
                                                  value="${temp.dir}/MTOMSwASampleService"/>
                                        <mkdir dir="${SSQ3.dir}"/>
                                        <mkdir dir="${SSQ3.dir}/META-INF"/>
                                        <copy file="${src3}/../conf/services.xml"
                                              tofile="${SSQ3.dir}/META-INF/services.xml"/>
                                        <copy toDir="${SSQ3.dir}">
                                            <fileset dir="${classes}">
                                                <include name="**/*.class"/>
                                            </fileset>
                                        </copy>
                                        <jar destfile="${services}/MTOMSwASampleService.aar">
                                            <fileset dir="${SSQ3.dir}"/>
                                        </jar>

                                        <property name="src4"
                                                  value="services/ReliableStockQuoteService/src"/>
                                        <delete dir="${temp.dir}"/>
                                        <mkdir dir="${temp.dir}"/>
                                        <mkdir dir="${classes}"/>
                                        <javac debug="on" destdir="${classes}" fork="true">
                                            <src path="${src4}"/>
                                            <classpath refid="maven.compile.classpath"/>
                                        </javac>
                                        <property name="RSQ.dir"
                                                  value="${temp.dir}/ReliableStockQuoteService"/>
                                        <mkdir dir="${RSQ.dir}"/>

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

                                        <jar destfile="${services}/ReliableStockQuoteService.aar">
                                            <fileset dir="${RSQ.dir}"/>
                                        </jar>

                                        <property name="src5"
                                                  value="services/LoadbalanceFailoverService/src"/>
                                        <delete dir="${temp.dir}"/>
                                        <mkdir dir="${temp.dir}"/>
                                        <mkdir dir="${classes}"/>
                                        <javac debug="on" destdir="${classes}" fork="true">
                                            <src path="${src5}"/>
                                            <classpath refid="maven.compile.classpath"/>
                                        </javac>

                                        <property name="LBFA1.dir" value="${temp.dir}/LBService1"/>
                                        <mkdir dir="${LBFA1.dir}"/>

                                        <mkdir dir="${LBFA1.dir}/META-INF"/>
                                        <copy file="${src5}/../conf/service1/services.xml"
                                              tofile="${LBFA1.dir}/META-INF/services.xml"/>
                                        <copy toDir="${LBFA1.dir}">
                                            <fileset dir="${classes}">
                                                <include name="**/LBService1.class"/>
                                            </fileset>
                                        </copy>

                                        <jar destfile="${services}/LBService1.aar">
                                            <fileset dir="${LBFA1.dir}"/>
                                        </jar>

                                        <property name="LBFA2.dir" value="${temp.dir}/LBService2"/>
                                        <mkdir dir="${LBFA2.dir}"/>

                                        <mkdir dir="${LBFA2.dir}/META-INF"/>
                                        <copy file="${src5}/../conf/service2/services.xml"
                                              tofile="${LBFA2.dir}/META-INF/services.xml"/>
                                        <copy toDir="${LBFA2.dir}">
                                            <fileset dir="${classes}">
                                                <include name="**/LBService2.class"/>
                                            </fileset>
                                        </copy>

                                        <jar destfile="${services}/LBService2.aar">
                                            <fileset dir="${LBFA2.dir}"/>
                                        </jar>

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

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <version>2.0-alpha-1</version>
                        <executions>
                            <execution>
                                <id>copy</id>
                                <phase>generate-test-resources</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.apache.axis2</groupId>
                                            <artifactId>addressing</artifactId>
                                            <version>${addressing.version}</version>
                                            <type>mar</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target/test_repos/axis2Server/modules
                                            </outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.apache.axis2</groupId>
                                            <artifactId>addressing</artifactId>
                                            <version>${addressing.version}</version>
                                            <type>mar</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target/test_repos/axis2Client/modules
                                            </outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.apache.rampart</groupId>
                                            <artifactId>rampart</artifactId>
                                            <version>${rampart.version}</version>
                                            <type>mar</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target/test_repos/axis2Client/modules
                                            </outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.apache.rampart</groupId>
                                            <artifactId>rampart</artifactId>
                                            <version>${rampart.version}</version>
                                            <type>mar</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target/test_repos/axis2Server/modules
                                            </outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.apache.sandesha2</groupId>
                                            <artifactId>sandesha2</artifactId>
                                            <version>${sandesha2.version}</version>
                                            <type>mar</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target/test_repos/axis2Server/modules
                                            </outputDirectory>
                                        </artifactItem>


                                        <artifactItem>
                                            <groupId>org.apache.axis2</groupId>
                                            <artifactId>addressing</artifactId>
                                            <version>${addressing.version}</version>
                                            <type>mar</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target/test_repos/synapse/modules
                                            </outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.apache.rampart</groupId>
                                            <artifactId>rampart</artifactId>
                                            <version>${rampart.version}</version>
                                            <type>mar</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target/test_repos/synapse/modules
                                            </outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.apache.sandesha2</groupId>
                                            <artifactId>sandesha2</artifactId>
                                            <version>${sandesha2.version}</version>
                                            <type>mar</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target/test_repos/synapse/modules
                                            </outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.apache.synapse</groupId>
                                            <artifactId>synapse</artifactId>
                                            <version>${synapse.version}</version>
                                            <type>mar</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target/test_repos/synapse/modules
                                            </outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.3</version>
                        <configuration>
                            <forkMode>pertest</forkMode>
                            <includes>
                                <include>**/*Integration.java</include>
                            </includes>
                            <excludes>
                                <exclude>**/SynapseSample_57_Integration.java</exclude>
                                <exclude>**/SynapseSample_103_Integration.java</exclude>
                                <exclude>**/SynapseSample_102_Integration.java</exclude>
                                <exclude>**/SynapseSample_56_Integration.java</exclude>
                                <exclude>**/SynapseSample_500_Integration.java</exclude>
                                <exclude>**/SynapseSample_501_Integration.java</exclude>
                                <exclude>**/SynapseSample_52_Integration.java</exclude>
                                <exclude>**/SynapseSample_53_Integration.java</exclude>
                                <exclude>**/SynapseSample_51_Integration.java</exclude>
                                <exclude>**/SynapseSample_104_Integration.java</exclude>
                                <exclude>**/SynapseSample_55_Integration.java</exclude>
                                <exclude>**/SynapseSample_5_Integration.java</exclude>
                            </excludes>
                            <redirectTestOutputToFile>true</redirectTestOutputToFile>
                            <workingDirectory>../..</workingDirectory>
                            <childDelegation>false</childDelegation>
                        </configuration>
                    </plugin>

                </plugins>
            </build>
            <activation>
                <property>
                    <name>integration</name>
                </property>
            </activation>
        </profile>
    </profiles>

    <dependencies>
        <dependency>
            <groupId>org.apache.synapse</groupId>
            <artifactId>synapse-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.synapse</groupId>
            <artifactId>synapse-extensions</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jruby</groupId>
            <artifactId>jruby-complete</artifactId>
            <version>0.9.9</version>
        </dependency>
    </dependencies>

</project>
