<?xml version="1.0" encoding="UTF-8"?>
<!--
 Copyright (c) 2015, 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>
        <artifactId>carbon-kernel-tests</artifactId>
        <groupId>org.wso2.carbon</groupId>
        <version>5.2.2</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>carbon-kernel-osgi-tests</artifactId>
    <version>5.2.2</version>
    <name>WSO2 Carbon Kernel - OSGi Tests</name>
    <description>OSGi Tests for Carbon Kernel</description>
    <url>http://wso2.com</url>

    <dependencies>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.exam</groupId>
            <artifactId>pax-exam-testng</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.exam</groupId>
            <artifactId>pax-exam-link-mvn</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.ow2.spec.ee</groupId>
            <artifactId>ow2-jta-1.1-spec</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jacoco</groupId>
            <artifactId>org.jacoco.ant</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.eclipse.osgi</groupId>
            <artifactId>org.eclipse.osgi</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.wso2.eclipse.osgi</groupId>
            <artifactId>org.eclipse.osgi.services</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.logging</groupId>
            <artifactId>pax-logging-log4j2</artifactId>
        </dependency>

        <!--Test Distribution-->
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>wso2carbon-kernel-test</artifactId>
            <type>zip</type>
        </dependency>

        <!-- Carbon Touchpoint Test Distribution -->
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>wso2carbon-kernel-carbon-touchpoint-test</artifactId>
            <type>zip</type>
        </dependency>

        <!--Pax exam Container Carbon-->
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.container</artifactId>
        </dependency>

        <!-- Test artifacts -->
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.sample.deployer.mgt</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.sample.dbs.deployer</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.sample.runtime.mgt</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.sample.runtime.mss</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.sample.runtime.webapp</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.sample.runtime.bps</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.sample.runtime.jar</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.sample.runtime.custom</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.sample.transport.mgt</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.sample.transport.http</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.sample.transport.custom</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.sample.transport.custom2</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.sample.transport.file</artifactId>
            <version>5.2.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.sample.transport.jms</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.sample.transport.jetty</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.sample.datasource.mgt</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.sample.order.resolver</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.sample.repository.mgt</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>carbon-context-test-artifact</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.sample.runtime.service</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.utils</groupId>
            <artifactId>org.wso2.carbon.utils</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.config</groupId>
            <artifactId>org.wso2.carbon.config</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <profiles>
        <profile>
            <id>with-tests</id>
            <activation>
                <property>
                    <name>!maven.test.skip</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>unpack-distribution</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.wso2.carbon</groupId>
                                            <artifactId>wso2carbon-kernel-test</artifactId>
                                            <type>zip</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>${project.build.directory}</outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <systemPropertyVariables>
                                <jacoco-agent.destfile>${project.build.directory}/jacoco.exec</jacoco-agent.destfile>
                                <org.wso2.carbon.test.default.distribution>
                                    org.wso2.carbon:wso2carbon-kernel-test
                                </org.wso2.carbon.test.default.distribution>
                                <org.ops4j.pax.logging.DefaultServiceLog.level>ERROR</org.ops4j.pax.logging.DefaultServiceLog.level>
                                <carbon.kernel.version>${carbon.kernel.version}</carbon.kernel.version>
                                <org.ops4j.pax.url.mvn.localRepository>${settings.localRepository}</org.ops4j.pax.url.mvn.localRepository>
                            </systemPropertyVariables>
                            <suiteXmlFiles>
                                <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
                            </suiteXmlFiles>
                            <environmentVariables>
                                <JAVA_OPTS>${jcoverage.command}</JAVA_OPTS>
                            </environmentVariables>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>prepare-agent</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                                <configuration>
                                    <propertyName>jcoverage.command</propertyName>
                                    <includes>
                                        <include>org.wso2.carbon*</include>
                                    </includes>
                                    <append>true</append>
                                </configuration>
                            </execution>
                            <execution>
                                <id>default-check</id>
                                <goals>
                                    <goal>check</goal>
                                </goals>
                                <configuration>
                                    <rules>
                                        <rule>
                                        </rule>
                                    </rules>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>prepare-package</phase>
                                <configuration>
                                    <target xmlns:jacoco="antlib:org.jacoco.ant">
                                        //this task is to provide class/src files locations for jacoco report generation
                                        <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
                                            <classpath path="${project.build.directory}" />
                                        </taskdef>
                                        <jacoco:report>
                                            <executiondata>
                                                <file file="${project.build.directory}/jacoco.exec" />
                                            </executiondata>
                                            <structure name="Carbon Core OSGi Tests">
                                                <classfiles>
                                                    <fileset dir="../../core/target/classes" />
                                                </classfiles>
                                                <sourcefiles encoding="UTF-8">
                                                    <fileset dir="../../core/src" />
                                                </sourcefiles>
                                            </structure>
                                            <html destdir="${project.build.directory}/site/jacoco" />
                                        </jacoco:report>
                                    </target>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                        <dependencies>
                            <dependency>
                                <groupId>org.jacoco</groupId>
                                <artifactId>org.jacoco.ant</artifactId>
                                <version>${org.jacoco.ant.version}</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                    <plugin>
                        <groupId>org.ops4j.pax.exam</groupId>
                        <artifactId>maven-paxexam-plugin</artifactId>
                        <version>${maven.paxexam.plugin.version}</version>
                        <executions>
                            <execution>
                                <id>generate-config</id>
                                <goals>
                                    <goal>generate-depends-file</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
