<?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>4.0.0-wso2v243</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>

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

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

    <profiles>
        <profile>
            <id>integration</id>
            <build>
                <plugins>
                    <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>
                                        <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/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/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>
                        <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>
                                            <type>mar</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target/test_repos/axis2Server/modules
                                            </outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.apache.axis2</groupId>
                                            <artifactId>addressing</artifactId>
                                            <type>mar</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target/test_repos/axis2Client/modules
                                            </outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.apache.rampart</groupId>
                                            <artifactId>rampart</artifactId>
                                            <type>mar</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target/test_repos/axis2Client/modules
                                            </outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.apache.rampart</groupId>
                                            <artifactId>rampart</artifactId>
                                            <type>mar</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target/test_repos/axis2Server/modules
                                            </outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.apache.sandesha2</groupId>
                                            <artifactId>sandesha2</artifactId>
                                            <type>mar</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target/test_repos/axis2Server/modules
                                            </outputDirectory>
                                        </artifactItem>


                                        <artifactItem>
                                            <groupId>org.apache.axis2</groupId>
                                            <artifactId>addressing</artifactId>
                                            <type>mar</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target/test_repos/synapse/modules
                                            </outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.apache.rampart</groupId>
                                            <artifactId>rampart</artifactId>
                                            <type>mar</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target/test_repos/synapse/modules
                                            </outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.apache.sandesha2</groupId>
                                            <artifactId>sandesha2</artifactId>
                                            <type>mar</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target/test_repos/synapse/modules
                                            </outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.apache.synapse</groupId>
                                            <artifactId>synapse</artifactId>
                                            <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>
                        <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>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <argLine>${argLine}</argLine>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                        <Private-Package>samples.*</Private-Package>
                        <Import-Package>
                            !org.apache.commons.logging,
                            javax.activation;version="0.0";resolution:=optional,
                            org.apache.commons.logging; version=0.0.0,,
                            *; resolution:=optional
                        </Import-Package>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.apache.synapse</groupId>
            <artifactId>synapse-core</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>javax.ws.rs</groupId>
                    <artifactId>jsr311-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.synapse</groupId>
            <artifactId>synapse-extensions</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jruby</groupId>
            <artifactId>jruby-complete</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.geronimo.specs</groupId>
            <artifactId>geronimo-jms_1.1_spec</artifactId>
        </dependency>
        <!-- Rampart -->
        <dependency>
            <groupId>org.apache.rampart</groupId>
            <artifactId>rampart-core</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.woden</groupId>
                    <artifactId>woden-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>log4j-over-slf4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-json-jackson</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
        </dependency>

    </dependencies>

</project>
