<?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.directory.studio</groupId>
    <artifactId>parent</artifactId>
    <version>1.2.0.SNAPSHOT</version>
  </parent>
  
  <artifactId>test.integration.core</artifactId>
  <version>${test.integration.core.version}</version>
  <name>Apache Directory Studio Core Integration Tests</name>
  <packaging>jar</packaging>

  <description></description>
  
  <profiles>
  
    <!--linux-x86  -->
    <profile>
      <id>linux-x86</id>
      <activation>
        <os>
          <arch>i386</arch>
          <family>unix</family>
          <name>linux</name>
        </os>
      </activation>
      <properties>
        <integration-regexp>^(ApacheDirectoryStudio-[^/]*)/(.*)$$</integration-regexp>
        <integration-cmdline-params>-os linux -ws gtk -arch x86</integration-cmdline-params>
      </properties>
    </profile>
    
    <!-- linux-x86_64 -->
    <profile>
      <id>linux-x86_64</id>
      <activation>
        <os>
          <arch>amd64</arch>
          <family>unix</family>
          <name>linux</name>
        </os>
      </activation>
      <properties>
        <integration-regexp>^(ApacheDirectoryStudio-[^/]*)/(.*)$$</integration-regexp>
        <integration-cmdline-params>-os linux -ws gtk -arch x86_64</integration-cmdline-params>
      </properties>
    </profile>  
    
    <!-- linux-ppc -->
    <profile>
      <id>linux-ppc</id>
      <activation>
        <os>
          <arch>ppc</arch>
          <family>unix</family>
          <name>linux</name>
        </os>
      </activation>
      <properties>
        <integration-regexp>^(ApacheDirectoryStudio-[^/]*)/(.*)$$</integration-regexp>
        <integration-cmdline-params>-os linux -ws gtk -arch ppc</integration-cmdline-params>
      </properties>
    </profile>  
    
    <!--win32  -->
    <profile>
       <id>win32</id>
      <activation>
        <os>
          <arch>x86</arch>
          <family>windows</family>
        </os>
      </activation>
      <properties>
        <integration-regexp>^(ApacheDirectoryStudio-[^\\]*)\\(.*)$$</integration-regexp>
        <integration-cmdline-params>-os win32 -ws win32 -arch x86</integration-cmdline-params>
      </properties>
    </profile>  
    
    <!-- macosx -->
    <profile>
      <id>macosx</id>
      <activation>
        <os>
          <family>unix</family>
          <name>mac os x</name>
        </os>
      </activation>
      <properties>
        <integration-regexp>^(ApacheDirectoryStudio-[^/]*)/(.*)$$</integration-regexp>
        <integration-cmdline-params>-os macosx -ws carbon -arch x64</integration-cmdline-params>
      </properties>
    </profile>  
  
    <!-- launch core tests using eclipse test framework -->
    <profile>
      <id>integration-core</id>
      <build>
        <plugins>
        
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
              <execution>
                <id>integration-ui</id>
                <phase>test</phase>
                <configuration>
                  <tasks>
                    
                    <!-- cleanup and recreate test-sandbox -->
                    <delete dir="target/test-sandbox"/>
                    <mkdir dir="target/test-sandbox"/>
                    <mkdir dir="target/test-sandbox/workspace"/>
                    
                    <!-- copy previous build of of apache directory studio binaries to test-sandbox -->
                    <copy todir="target/test-sandbox">
                      <fileset dir="../target/distributions">
                        <include name="ApacheDirectoryStudio-*/**" />
                      </fileset>
                      <regexpmapper from="${integration-regexp}" to="\2"/>
                    </copy>
                    
                    <!-- copy SWTbot and eclipse testing plugins to test-sandbox -->
                    <copy todir="target/test-sandbox/plugins">
                      <fileset dir="../test-integration-ui/resources/test-plugins">
                        <include name="**/*" />
                      </fileset>
                    </copy>
                    
                    <!-- copy test-integration-core plugin to test-sandbox -->
                    <copy todir="target/test-sandbox/plugins">
                      <fileset dir="target">
                        <include name="test.integration.core-*.jar" />
                      </fileset>
                    </copy>
                    
                    <!-- copy additional eclipse dependencies to test-sandbox -->
                    <copy todir="target/test-sandbox/plugins">
                      <fileset dir="${eclipse-home}/plugins">
                        <include name="org.apache.commons.collections_*.jar" />
                        <include name="org.apache.log4j_*.jar" />
                        <include name="org.eclipse.ant.core_*.jar" />
                        <include name="org.eclipse.ant.ui_*.jar" />
                        <include name="org.eclipse.compare_*.jar" />
                        <include name="org.eclipse.core.variables_*.jar" />
                        <include name="org.eclipse.debug.core_*.jar" />
                        <include name="org.eclipse.debug.ui_*.jar" />
                        <include name="org.eclipse.team.core_*.jar" />
                        <include name="org.eclipse.team.ui_*.jar" />
                        <include name="org.eclipse.ui.browser_*.jar" />
                        <include name="org.eclipse.ui.cheatsheets_*.jar" />
                        <include name="org.eclipse.ui.console_*.jar" />
                        <include name="org.eclipse.ui.externaltools_*.jar" />
                        <include name="org.eclipse.ui.navigator_*.jar" />
                        <include name="org.eclipse.ui.navigator.resources_*.jar" />
                        <include name="org.eclipse.ui.net_*.jar" />
                        <include name="org.eclipse.ui.presentations_*.jar" />
                        <include name="org.eclipse.ui.views.properties.tabbed_*.jar" />
                        <include name="org.eclipse.jdt*" />
                        <include name="org.eclipse.ltk*" />
                        <include name="org.eclipse.pde*" />
                        <include name="org.eclipse.ui.intro.universal_*/**" />
                        <include name="org.apache.ant_*/**" />
                        <include name="org.junit_*/**" />
                        <include name="org.junit4_*/**" />
                      </fileset>
                    </copy>
                    
                    <!-- launch the tests -->
                    <java fork="true" failonerror="true" classname="org.eclipse.core.launcher.Main">
                      <arg line="${integration-cmdline-params} -application org.eclipse.test.coretestapplication -data target/test-sandbox/workspace formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,target/test-sandbox/workspace/test-result.xml -testPluginName org.apache.directory.studio.test.integration.core -className org.apache.directory.studio.test.integration.core.AutomatedSuite"/>
                      <classpath>
                        <pathelement location="target/test-sandbox/plugins/org.eclipse.equinox.launcher_1.0.1.R33x_v20080118.jar" />
                      </classpath>
                    </java>
                  </tasks>
                </configuration>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          
        </plugins>
      </build>
    </profile>
  </profiles>
  
  <build>
    <resources>
      <resource>
        <directory>.</directory>
        <includes>
          <include>plugin.xml</include>
        </includes>
      </resource>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-eclipse-plugin</artifactId>
        <configuration>
          <pde>true</pde>
          <additionalProjectnatures>
            <projectnature>org.eclipse.pde.PluginNature</projectnature>
            <projectnature>org.eclipse.jdt.core.javanature</projectnature>
          </additionalProjectnatures>
          <classpathContainers>
            <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
            <classpathContainer>org.eclipse.pde.core.requiredPlugins</classpathContainer>
          </classpathContainers>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.directory.studio</groupId>
        <artifactId>maven-studio-plugin</artifactId>
        <configuration>
          <skip>false</skip>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>prepare-jar-package</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifestFile>META-INF/MANIFEST.MF</manifestFile>
            <addMavenDescriptor>false</addMavenDescriptor>
          </archive>
        </configuration>
      </plugin>
      <!-- No tests to run -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <skip>false</skip>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>org.apache.directory.server</groupId>
      <artifactId>apacheds-server-unit</artifactId>
      <version>1.5.3-SNAPSHOT</version>
    </dependency> 
    <dependency>
      <groupId>org.apache.directory.server</groupId>
      <artifactId>apacheds-core-integ</artifactId>
      <version>1.5.3-SNAPSHOT</version>
    </dependency> 
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>nlog4j</artifactId>
    </dependency>
    
    <dependency>
      <groupId>org.apache.directory.studio</groupId>
      <artifactId>connection.core</artifactId>
      <scope>provided</scope>
    </dependency>
    
    <dependency>
      <groupId>org.eclipse</groupId>
      <artifactId>osgi</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.equinox</groupId>
      <artifactId>common</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.equinox</groupId>
      <artifactId>registry</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.core</groupId>
      <artifactId>runtime</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.equinox</groupId>
      <artifactId>preferences</artifactId>
      <scope>provided</scope>
    </dependency>
    
  </dependencies>
</project>
