<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
  ~
  ~ Licensed 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/xsd/maven-4.0.0.xsd">

    <parent>
        <groupId>io.siddhi.distribution</groupId>
        <artifactId>io.siddhi.distribution.parent</artifactId>
        <version>5.1.0-beta</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>io-siddhi-distribution-test-framework</artifactId>
    <name>Siddhi Distributions - Test Framework</name>
    <description>Siddhi Test Framework</description>
    <url>https://siddhi.io</url>

    <dependencies>
        <dependency>
            <groupId>io.siddhi</groupId>
            <artifactId>siddhi-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.logging</groupId>
            <artifactId>pax-logging-log4j2</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.datasources</groupId>
            <artifactId>org.wso2.carbon.datasource.core</artifactId>
        </dependency>
        <dependency>
            <groupId>findbugs</groupId>
            <artifactId>findbugs</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka_2.11</artifactId>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
        </dependency>
        <dependency>
            <groupId>io.nats</groupId>
            <artifactId>java-nats-streaming</artifactId>
        </dependency>
        <!--Test dependencies-->
        <dependency>
            <groupId>org.jacoco</groupId>
            <artifactId>org.jacoco.ant</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.siddhi.extension.io.http</groupId>
            <artifactId>siddhi-io-http</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.siddhi.extension.map.json</groupId>
            <artifactId>siddhi-map-json</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.siddhi.extension.io.nats</groupId>
            <artifactId>siddhi-io-nats</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.tools.core</artifactId>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>with-docker-based-tests</id>
            <activation>
                <property>
                    <name>with-docker</name>
                </property>
            </activation>
            <build>
                <resources>
                    <resource>
                        <directory>src/main/resources</directory>
                        <filtering>true</filtering>
                    </resource>
                </resources>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-jars</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <!--Jars to be included for ExtendingLib Test-->
                                        <artifactItem>
                                            <groupId>mysql</groupId>
                                            <artifactId>mysql-connector-java</artifactId>
                                            <version>${mysql.connector.version}</version>
                                            <outputDirectory>${project.build.directory}/ExtendingLibTestResource/jars
                                            </outputDirectory>
                                        </artifactItem>
                                        <!--Jars to be included for TemperatureAlertAppTest-->
                                        <artifactItem>
                                            <groupId>com.google.protobuf</groupId>
                                            <artifactId>protobuf-java</artifactId>
                                            <version>3.6.1</version>
                                            <outputDirectory>${project.build.directory}/TemperatureAlertApp/jars
                                            </outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>mysql</groupId>
                                            <artifactId>mysql-connector-java</artifactId>
                                            <version>${mysql.connector.version}</version>
                                            <outputDirectory>${project.build.directory}/TemperatureAlertApp/jars
                                            </outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>without-docker-based-tests</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${maven.surefire.plugin.version}</version>
                        <configuration>
                            <systemPropertyVariables>
                                <jacoco-agent.destfile>${project.build.directory}/jacoco.exec</jacoco-agent.destfile>
                            </systemPropertyVariables>
                            <suiteXmlFiles>
                                <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
                            </suiteXmlFiles>
                            <environmentVariables>
                                <JAVA_OPTS>${jcoverage.command}</JAVA_OPTS>
                            </environmentVariables>
                            <skipTests>true</skipTests>
                        </configuration>
                    </plugin>
                </plugins>
            </build>

        </profile>
    </profiles>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                        <Bundle-Name>${project.artifactId}</Bundle-Name>
                        <Private-Package>org.testcontainers.containers.*</Private-Package>
                        <Export-Package>
                            io.siddhi.distribution.test.framework.*;version="${project.version}"
                        </Export-Package>
                        <Include-Resource>
                            META-INF=target/classes/META-INF
                        </Include-Resource>
                        <_dsannotations>*</_dsannotations>
                        <DynamicImport-Package>*</DynamicImport-Package>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>