<?xml version="1.0" encoding="UTF-8"?>
<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">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.wso2.carbon.deployment</groupId>
        <artifactId>tests</artifactId>
        <version>5.2.2</version>
    </parent>

    <name>Carbon Deployment OSGi Tests</name>
    <artifactId>osgi-tests</artifactId>

    <dependencies>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.exam</groupId>
            <artifactId>pax-exam</artifactId>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.exam</groupId>
            <artifactId>pax-exam-container-native</artifactId>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.exam</groupId>
            <artifactId>pax-exam-testng</artifactId>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.exam</groupId>
            <artifactId>pax-exam-link-mvn</artifactId>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.url</groupId>
            <artifactId>pax-url-aether</artifactId>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.logging</groupId>
            <artifactId>pax-logging-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.logging</groupId>
            <artifactId>pax-logging-log4j2</artifactId>
        </dependency>
        <dependency>
            <groupId>org.ow2.spec.ee</groupId>
            <artifactId>ow2-jta-1.1-spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.eclipse.equinox</groupId>
            <artifactId>org.eclipse.equinox.simpleconfigurator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.gogo.command</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.gogo.runtime</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.gogo.shell</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.eclipse.equinox</groupId>
            <artifactId>org.eclipse.equinox.app</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.eclipse.equinox</groupId>
            <artifactId>org.eclipse.equinox.common</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.eclipse.equinox</groupId>
            <artifactId>org.eclipse.equinox.concurrent</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.eclipse.equinox</groupId>
            <artifactId>org.eclipse.equinox.console</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.eclipse.equinox</groupId>
            <artifactId>org.eclipse.equinox.ds</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.eclipse.equinox</groupId>
            <artifactId>org.eclipse.equinox.frameworkadmin</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.eclipse.equinox</groupId>
            <artifactId>org.eclipse.equinox.frameworkadmin.equinox</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.eclipse.equinox</groupId>
            <artifactId>org.eclipse.equinox.launcher</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.eclipse.equinox</groupId>
            <artifactId>org.eclipse.equinox.preferences</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.eclipse.equinox</groupId>
            <artifactId>org.eclipse.equinox.registry</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.eclipse.equinox</groupId>
            <artifactId>org.eclipse.equinox.simpleconfigurator.manipulator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.eclipse.equinox</groupId>
            <artifactId>org.eclipse.equinox.util</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.eclipse.equinox</groupId>
            <artifactId>org.eclipse.equinox.cm</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.eclipse.osgi</groupId>
            <artifactId>org.eclipse.osgi.services</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.eclipse.osgi</groupId>
            <artifactId>org.eclipse.osgi</artifactId>
        </dependency>

        <dependency>
            <groupId>org.yaml</groupId>
            <artifactId>snakeyaml</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.deployment</groupId>
            <artifactId>org.wso2.carbon.deployment.engine</artifactId>
            <!--<scope>test</scope>-->
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.deployment</groupId>
            <artifactId>org.wso2.carbon.deployment.notifier</artifactId>
            <!--<scope>test</scope>-->
        </dependency>

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

        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.container</artifactId>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>with-tests</id>
            <activation>
                <property>
                    <name>!maven.test.skip</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <!--copying distribution/carbon-home directory to the target folder-->
                                <id>copy-resources</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.build.directory}/carbon-home</outputDirectory>
                                    <overwrite>true</overwrite>
                                    <resources>
                                        <resource>
                                            <directory>src/test/resources/carbon-home</directory>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <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.deployment</groupId>
                                            <artifactId>wso2carbon-deployment-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.deployment:wso2carbon-deployment-test
                                </org.wso2.carbon.test.default.distribution>
                                <org.ops4j.pax.logging.DefaultServiceLog.level>ERROR</org.ops4j.pax.logging.DefaultServiceLog.level>
                                <org.ops4j.pax.url.mvn.localRepository>${settings.localRepository}</org.ops4j.pax.url.mvn.localRepository>
                            </systemPropertyVariables>
                            <systemProperties>
                                <property>
                                    <name>carbon.home</name>
                                    <value>${basedir}/target/wso2carbon-deployment-test-${project.version}</value>
                                </property>
                            </systemProperties>
                            <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>
                        <version>${jacoco.version}</version>
                        <executions>
                            <execution>
                                <id>default-prepare-agent</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                                <configuration>
                                    <includes>
                                        <include>org.wso2.carbon*</include>
                                    </includes>
                                </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 Deployment OSGi Tests">
                                                <classfiles>
                                                    <fileset dir="../../components/org.wso2.carbon.deployment.engine/target/classes" />
                                                    <fileset dir="../../components/org.wso2.carbon.deployment.notifier/target/classes" />
                                                </classfiles>
                                                <sourcefiles encoding="UTF-8">
                                                    <fileset dir="../../components/org.wso2.carbon.deployment.engine/src" />
                                                    <fileset dir="../../components/org.wso2.carbon.deployment.notifier/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>
