<?xml version="1.0" encoding="UTF-8"?>
<!--

     Copyright 2005-2015 Red Hat, Inc.

     Red Hat 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.

-->
<!--
    Set these VM properties in your IDE debugger
     
    -Dlog4j.configuration=file://${workspace_loc:fabric-runtime-itests-karaf}/src/test/resources/logging.properties
    -Dtarget.container=karaf
-->
<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>io.fabric8.patch</groupId>
	    <artifactId>patch-project</artifactId>
        <version>1.2.0.redhat-621221</version>
    </parent>

    <artifactId>patch-itests</artifactId>
    
    <name>Fabric8 :: Patch :: Integration Tests</name>

    <!-- Properties -->
    <properties>
        <karaf.home>${project.build.directory}/apache-karaf-${karaf-version}</karaf.home>
    </properties>
    
    <dependencies>
        
        <!-- Provided Dependencies -->
        <dependency>
            <groupId>io.fabric8.itests</groupId>
            <artifactId>fabric-itests-common</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>io.fabric8.patch</groupId>
            <artifactId>patch-core-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>io.fabric8.patch</groupId>
            <artifactId>patch-core</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Test Dependencies -->
        <dependency>
            <groupId>io.fabric8</groupId>
            <artifactId>fabric-zookeeper</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.fabric8.runtime</groupId>
            <artifactId>fabric-runtime-container-karaf-managed</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.container</groupId>
            <artifactId>arquillian-container-karaf-managed</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.container</groupId>
            <artifactId>arquillian-container-spi</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.protocol</groupId>
            <artifactId>arquillian-protocol-jmx</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.osgi</groupId>
            <artifactId>arquillian-osgi-bundle</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.utils</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-aether-provider</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-settings-builder</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.karaf.shell</groupId>
            <artifactId>org.apache.karaf.shell.scr</artifactId>
        </dependency>
    </dependencies>

    <build>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>${maven-dependency-plugin-version}</version>
                <executions>
                    <execution>
                        <id>unpack-karaf</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.apache.karaf</groupId>
                                    <artifactId>apache-karaf</artifactId>
                                    <version>${karaf-version}</version>
                                    <type>tar.gz</type>
                                    <outputDirectory>${project.build.directory}</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <inherited>false</inherited>
                <executions>
                    <execution>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <phase>process-test-resources</phase>
                        <configuration>
                            <target>
                                <copy todir="${karaf.home}/etc" overwrite="true">
                                        <fileset dir="${project.build.directory}/test-classes/etc"/>
                                </copy>
                                <copy todir="${karaf.home}/fabric" overwrite="true">
                                        <fileset dir="${project.build.directory}/test-classes/fabric"/>
                                </copy>
                                <mkdir dir="${karaf.home}/patches/_baseline-root" />
                                <copy todir="${karaf.home}/patches/_baseline-root">
                                    <fileset dir="${karaf.home}"/>
                                </copy>
                                <zip destfile="${karaf.home}/patches/jboss-fuse-full-6.2.0-baseline.zip">
                                    <fileset dir="${karaf.home}/patches" >
                                        <include name="_baseline-root/**" />
                                    </fileset>
                                </zip>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!--
                Add all necessary bundles to the test Karaf container
            -->
            <plugin>
                <groupId>org.apache.karaf.tooling</groupId>
                <artifactId>features-maven-plugin</artifactId>
                <version>${karaf-version}</version>
                <executions>
                <execution>
                <id>add-features-to-repo</id>
                <phase>generate-resources</phase>
                <goals>
                    <goal>add-features-to-repo</goal>
                </goals>
                <configuration>
                <descriptors>
                    <descriptor>mvn:org.apache.karaf.assemblies.features/standard/${karaf-version}/xml/features</descriptor>
                    <descriptor>mvn:io.fabric8.patch/patch-features/${project.version}/xml/features</descriptor>
                </descriptors>
                <features>
                    <feature>scr</feature>
                    <feature>patch</feature>
                </features>
                    <repository>${karaf.home}/system</repository>
                </configuration>
                </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.wagon</groupId>
                        <artifactId>wagon-http</artifactId>
                        <version>2.8</version>
                    </dependency>
                    <dependency>
                        <groupId>org.apache.httpcomponents</groupId>
                        <artifactId>httpclient</artifactId>
                        <version>4.5.1</version>
                    </dependency>
                    <dependency>
                        <groupId>org.apache.httpcomponents</groupId>
                        <artifactId>httpcore</artifactId>
                        <version>4.4.4</version>
                    </dependency>
                    <dependency>
                        <groupId>org.apache.maven.wagon</groupId>
                        <artifactId>wagon-http</artifactId>
                        <version>2.8</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <argLine>${surefire.system.args}</argLine>
                    <redirectTestOutputToFile>false</redirectTestOutputToFile>
                    <reportNameSuffix>karaf</reportNameSuffix>
                    <systemPropertyVariables>
                        <log4j.configuration>file://${basedir}/src/test/resources/logging.properties</log4j.configuration>
                        <target.container>karaf</target.container>
                        <karaf.home>${karaf.home}</karaf.home>
                        <fuse.patch.location>${karaf.home}/patches</fuse.patch.location>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
