<?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.stratos</groupId>
        <artifactId>stratos-components-parent</artifactId>
        <version>4.1.3</version>
    </parent>

    <artifactId>org.apache.stratos.cli</artifactId>
    <packaging>jar</packaging>
    <name>Apache Stratos - CLI</name>
    <description>Apache Stratos CLI</description>

    <dependencies>
        <!-- Adding HttpClient dependencies. Those were resolved with above one -->
        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <version>${commons-httpclient.version}</version>
        </dependency>
        <dependency>
            <groupId>org.wso2.securevault</groupId>
            <artifactId>org.wso2.securevault</artifactId>
            <version>1.0.0-wso2v2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents.wso2</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.3.0.wso2v1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.stratos</groupId>
            <artifactId>org.apache.stratos.manager.service.stub</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.stratos</groupId>
            <artifactId>org.apache.stratos.common</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>commons-cli</groupId>
            <artifactId>commons-cli</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>jline</groupId>
            <artifactId>jline</artifactId>
            <version>2.11</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.3.1</version>
        </dependency>
        <dependency>
            <groupId>commons-validator</groupId>
            <artifactId>commons-validator</artifactId>
            <version>1.4.0</version>
        </dependency>
        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${slf4j.version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.3.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.stratos</groupId>
            <artifactId>org.apache.stratos.manager</artifactId>
            <version>${project.version}</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <!-- Copy the CLI -->
                                <artifactItem>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>${project.artifactId}</artifactId>
                                    <version>${project.version}</version>
                                    <type>jar</type>
                                    <overWrite>true</overWrite>
                                    <outputDirectory>${maven.output.build.path}</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>com.github.tomakehurst</groupId>
                                    <artifactId>wiremock</artifactId>
                                    <version>${wiremock.version}</version>
                                    <classifier>standalone</classifier>
                                    <type>jar</type>
                                    <overWrite>true</overWrite>
                                    <outputDirectory>${maven.output.build.path}</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- Integration testing the CLI -->
        <profile>
            <id>cli-test</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>pre-integration-test</phase>
                                <configuration>
                                    <tasks>
                                        <mkdir dir="${project.build.directory}/downloads/"/>
                                        <get src="https://pypi.python.org/packages/source/p/pexpect/pexpect-3.2.tar.gz"
                                             dest="${project.build.directory}/downloads/"
                                             verbose="true"/>
                                        <gunzip src="${project.build.directory}/downloads/pexpect-3.2.tar.gz"
                                                dest="${project.build.directory}/downloads/pexpect-3.2.tar"/>
                                        <untar src="${project.build.directory}/downloads/pexpect-3.2.tar"
                                               dest="${project.build.directory}/"/>
                                    </tasks>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <configuration>
                                    <executable>python</executable>
                                    <workingDirectory>src/test/python</workingDirectory>
                                    <!-- tests common to both interactive and non-interactive use cases -->
                                    <arguments>
                                        <argument>test_common.py</argument>
                                    </arguments>
                                    <environmentVariables>
                                        <PYTHONPATH>
                                            ../../main/python:${project.build.directory}/pexpect-3.2:$PYTHONPATH
                                        </PYTHONPATH>
                                        <CLI_JAR>${project.build.directory}/${project.build.finalName}.jar</CLI_JAR>
                                        <WIREMOCK_JAR>
                                            ${project.build.directory}/dependency/wiremock-${wiremock.version}-standalone.jar
                                        </WIREMOCK_JAR>
                                        <!-- Use uncommon ports to prevent conflict on jenkins -->
                                        <WIREMOCK_HTTP_PORT>3448</WIREMOCK_HTTP_PORT>
                                        <WIREMOCK_HTTPS_PORT>3449</WIREMOCK_HTTPS_PORT>
                                    </environmentVariables>
                                </configuration>
                                <id>python-test-common</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                            </execution>
                            <execution>
                                <configuration>
                                    <executable>python</executable>
                                    <workingDirectory>src/test/python</workingDirectory>
                                    <!-- interactive use cases -->
                                    <arguments>
                                        <argument>test_interactive.py</argument>
                                    </arguments>
                                    <environmentVariables>
                                        <PYTHONPATH>
                                            ../../main/python:${project.build.directory}/pexpect-3.2:$PYTHONPATH
                                        </PYTHONPATH>
                                        <CLI_JAR>${project.build.directory}/${project.build.finalName}.jar</CLI_JAR>
                                        <WIREMOCK_JAR>
                                            ${project.build.directory}/dependency/wiremock-${wiremock.version}-standalone.jar
                                        </WIREMOCK_JAR>
                                        <!-- Use uncommon ports to prevent conflict on jenkins -->
                                        <WIREMOCK_HTTP_PORT>3448</WIREMOCK_HTTP_PORT>
                                        <WIREMOCK_HTTPS_PORT>3449</WIREMOCK_HTTPS_PORT>
                                    </environmentVariables>
                                </configuration>
                                <id>python-test-interactive</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                            </execution>
                            <execution>
                                <configuration>
                                    <executable>python</executable>
                                    <workingDirectory>src/test/python</workingDirectory>
                                    <!-- non-interactive use cases -->
                                    <arguments>
                                        <argument>test_noninteractive.py</argument>
                                    </arguments>
                                    <environmentVariables>
                                        <PYTHONPATH>
                                            ../../main/python:${project.build.directory}/pexpect-3.2:$PYTHONPATH
                                        </PYTHONPATH>
                                        <CLI_JAR>${project.build.directory}/${project.build.finalName}.jar</CLI_JAR>
                                        <WIREMOCK_JAR>
                                            ${project.build.directory}/dependency/wiremock-${wiremock.version}-standalone.jar
                                        </WIREMOCK_JAR>
                                        <!-- Use uncommon ports to prevent conflict on jenkins -->
                                        <WIREMOCK_HTTP_PORT>3448</WIREMOCK_HTTP_PORT>
                                        <WIREMOCK_HTTPS_PORT>3449</WIREMOCK_HTTPS_PORT>
                                    </environmentVariables>
                                </configuration>
                                <id>python-test-noninteractive</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>