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

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

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

    <build>
        <plugins>

            <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/synapse/modules</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <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 testing repository ***"/>

                                <mkdir dir="target/test_repos"/>
                                <mkdir dir="target/test_repos/synapse/modules"/>
                                <mkdir dir="target/test_repos/synapse/services"/>
                                <mkdir dir="target/test_repos/client/modules"/>

                                <echo message="*** Creating synapse.mar ***"/>
                                <mkdir dir="target/modules/synapse/META-INF"/>
                                <copy file="src/main/resources/module.xml" tofile="target/modules/synapse/META-INF/module.xml"/>

                                <manifest file="target/MANIFEST.MF">
                                    <attribute name="Extension-Name" value="org.apache.synapse"/>
                                    <attribute name="Specification-Title" value="synapse"/>
                                    <attribute name="Specification-Vendor" value="Apache Software Foundation"/>
                                    <attribute name="Specification-Version" value="${pom.version}"/>
                                    <attribute name="Implementation-Title" value="Apache Synapse"/>
                                    <attribute name="Implementation-Vendor-Id" value="org.apache"/>
                                    <attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
                                    <attribute name="Implementation-Version" value="${pom.version}"/>
                                </manifest>

                                <jar jarfile="target/synapse-${version}.mar" manifest="target/MANIFEST.MF">
                                    <fileset dir="target/modules/synapse">
                                         <include name="**"/>
                                    </fileset>
                                    <!--<fileset dir="target/classes">
                                        <include name="**"/>
                                    </fileset>-->
                                </jar>

                                <copy file="target/synapse-${version}.mar"
                                    tofile="target/test_repos/synapse/modules/synapse-${version}.mar"/>

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

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <systemProperties>
                        <property>
                            <name>org.xml.sax.driver</name>
                            <value>org.apache.xerces.parsers.SAXParser</value>
                        </property>
                        <property>
                            <name>javax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema</name>
                            <value>org.apache.xerces.jaxp.validation.XMLSchemaFactory</value>
                        </property>
                    </systemProperties>
                    <forkMode>pertest</forkMode>
                    <!--<redirectTestOutputToFile>true</redirectTestOutputToFile>-->
                    <!--<workingDirectory>../..</workingDirectory>-->
                    <childDelegation>false</childDelegation>
                </configuration>
            </plugin>

        </plugins>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>**/*.jks</exclude>
                </excludes>
            </resource>
        </resources>
    </build>
    
    <dependencies>
        <dependency>
            <groupId>org.apache.synapse</groupId>
            <artifactId>synapse-transports</artifactId>
        </dependency>
    </dependencies>
</project>
