<?xml version="1.0" encoding="UTF-8"?>
<!--
 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.

 Copyright © 2011-2012 ForgeRock AS. All rights reserved.

 The contents of this file are subject to the terms
 of the Common Development and Distribution License
 (the License). You may not use this file except in
 compliance with the License.

 You can obtain a copy of the License at
 http://forgerock.org/license/CDDLv1.0.html
 See the License for the specific language governing
 permission and limitations under the License.

 When distributing Covered Code, include this CDDL
 Header Notice in each file and include the License file
 at http://forgerock.org/license/CDDLv1.0.html
 If applicable, add the following below the CDDL Header,
 with the fields enclosed by brackets [] replaced by
 your own identifying information:
 "Portions Copyrighted [year] [name of copyright owner]"
-->
<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.forgerock.openicf.framework</groupId>
        <artifactId>framework</artifactId>
        <version>1.1.0.1-SNAPSHOT</version>
    </parent>
    <groupId>org.forgerock.openicf.connectors</groupId>
    <artifactId>connectors-parent</artifactId>
    <packaging>pom</packaging>
    <name>OpenICF Connectors Parent</name>
    <description>
        This pom module is the parent for all connector bundles. It defines the dependencies on framework, building the
        connector bundle and common reporting for connectors.
        This is not multimodule project, it does not aggregate the connectors, it is just common parent.
    </description>
    <distributionManagement>
        <site>
            <id>forgerock.org</id>
            <url>${siteDistributionURL}/connectors/</url>
        </site>
    </distributionManagement>
    <scm>
        <connection>scm:svn:https://svn.forgerock.org/openicf/trunk/framework/java/connectors-parent</connection>
        <developerConnection>
            scm:svn:https://svn.forgerock.org/openicf/trunk/framework/java/connectors-parent
        </developerConnection>
        <url>http://sources.forgerock.org/browse/openicf/trunk/framework/java/connectors-parent</url>
    </scm>
    <!-- mvn help:effective-pom
         mvn archetype:create-from-project
         mvn help:active-profiles
     -->
    <properties>
        <framework.compatibilityVersion>1.1</framework.compatibilityVersion>
        <framework.releaseVersion>0.1-SNAPSHOT</framework.releaseVersion>
        <framework.version>${framework.compatibilityVersion}.${framework.releaseVersion}</framework.version>
        <licenseResourceBundle>org.forgerock.openicf:openicf-license:1.0.0</licenseResourceBundle>

        <!--
            These are the properties needed in manifest file of the bundle,
            but now hardcoded in tests
        -->
        <ConnectorBundle-FrameworkVersion>${framework.compatibilityVersion}</ConnectorBundle-FrameworkVersion>
        <ConnectorBundle-Name>${project.artifactId}</ConnectorBundle-Name>
        <ConnectorBundle-Version>${project.version}</ConnectorBundle-Version>
        <!-- 
            These are the variables needs to define in order to a proper test coverage.
        -->
        <connectorGroupId>${project.groupId}</connectorGroupId>
        <connectorArtifactId>${project.artifactId}</connectorArtifactId>
        <connectorVersion>${project.version}</connectorVersion>
        <connectorName>${connectorPackage}.${connectorClass}</connectorName>
        <junitsConfigurations>default</junitsConfigurations>
        <contractsConfigurations>default</contractsConfigurations>
        <contract.suiteName>org.identityconnectors.contract.test.ContractTestSuite</contract.suiteName>
        <junits.skip>${skipTests}</junits.skip>
        <contracts.skip>${skipTests}</contracts.skip>

        <!-- OSGi Properties -->
        <openicf.osgi.exclude.dependencies>false</openicf.osgi.exclude.dependencies>


        <openicf.osgi.import.framework.version>
            version="[$(version;==;${framework.version}),$(version;+;${framework.version}))"
        </openicf.osgi.import.framework.version>
        <openicf.osgi.import.strict.version>
            version="[$(version;===;${framework.version}),$(version;==+;${framework.version}))"
        </openicf.osgi.import.strict.version>

        <openicf.osgi.import.before.defaults/>
        <openicf.osgi.import.defaults/>
        <openicf.osgi.import.additional/>

        <openicf.osgi.import.pkg>
            org.identityconnectors.*;${openicf.osgi.import.framework.version},
            ${openicf.osgi.import.before.defaults},
            ${openicf.osgi.import.defaults},
            ${openicf.osgi.import.additional},
            *
        </openicf.osgi.import.pkg>
        <openicf.osgi.import>${openicf.osgi.import.pkg}</openicf.osgi.import>

        <openicf.osgi.private/>
        <!--openicf.osgi.private>${connectorPackage}*.impl</openicf.osgi.private-->

        <openicf.osgi.export.pkg>!*.impl;${connectorPackage}*</openicf.osgi.export.pkg>
        <openicf.osgi.version>version=${project.version}</openicf.osgi.version>
        <openicf.osgi.split.pkg>-split-package:=first</openicf.osgi.split.pkg>
        <!--openicf.osgi.export>
            ${openicf.osgi.export.pkg};${openicf.osgi.version};-noimport:=true;${openicf.osgi.split.pkg}
        </openicf.osgi.export-->
        <openicf.osgi.export>
            ${openicf.osgi.export.pkg};${openicf.osgi.version};-noimport:=true
        </openicf.osgi.export>


        <openicf.osgi.symbolic.name>${project.artifactId}</openicf.osgi.symbolic.name>
        <openicf.osgi.activator/>
        <openicf.osgi.dynamic.import/>
        <openicf.osgi.include.resource>{maven-resources}</openicf.osgi.include.resource>
        <openicf.osgi.import.default.version>
            [$(version;==;$(@)),$(version;=+;$(@)))
        </openicf.osgi.import.default.version>
        <openicf.osgi.remove.headers>
            Ignore-Package,Include-Resource,Private-Package,Bundle-DocURL,Embedded-Artifacts,Embed-Dependency,Built-By
        </openicf.osgi.remove.headers>
        <openicf.osgi.failok>false</openicf.osgi.failok>
        <openicf.osgi.export.service/>
        <openicf.osgi.import.service/>
        <openicf.osgi.embed/>

    </properties>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-site-plugin</artifactId>
                <inherited>false</inherited>
                <configuration>
                    <generateReports>false</generateReports>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>bundle-impl</id>
            <activation>
                <file>
                    <missing>./bundles-parent</missing>
                </file>
            </activation>

            <dependencies>
                <dependency>
                    <groupId>org.forgerock.openicf</groupId>
                    <artifactId>openicf-license</artifactId>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>org.forgerock.openicf.framework</groupId>
                    <artifactId>connector-framework</artifactId>
                </dependency>
                <dependency>
                    <groupId>org.forgerock.openicf.framework</groupId>
                    <artifactId>connector-test-common</artifactId>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.forgerock.openicf.framework</groupId>
                    <artifactId>connector-framework-internal</artifactId>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.forgerock.openicf.framework</groupId>
                    <artifactId>connector-framework-contract</artifactId>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.testng</groupId>
                    <artifactId>testng</artifactId>
                    <scope>test</scope>
                </dependency>

            </dependencies>

            <build>
                <testResources>
                    <testResource>
                        <directory>${project.basedir}/src/test/config</directory>
                    </testResource>
                    <testResource>
                        <directory>${privateConfigPath}</directory>
                        <excludes>
                            <exclude>lib/**</exclude>
                            <exclude>**/target/**</exclude>
                        </excludes>
                    </testResource>
                    <!--testResource>
                        <directory>src/test/java</directory>
                        <excludes>
                            <exclude>**/*.java</exclude>
                        </excludes>
                    </testResource-->
                    <testResource>
                        <directory>src/test/resources</directory>
                    </testResource>
                </testResources>

                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-javadoc-plugin</artifactId>
                            <configuration>
                                <links>
                                    <link>http://download.oracle.com/javase/6/docs/api/</link>
                                    <link>http://groovy.codehaus.org/api/</link>
                                    <link>http://openicf.forgerock.org/connector-framework/apidocs/</link>
                                </links>
                            </configuration>
                        </plugin>
                        <!--plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-release-plugin</artifactId>
                            <configuration>
                                <mavenExecutorId>forked-path</mavenExecutorId>
                                <useReleaseProfile>false</useReleaseProfile>
                                <goals>deploy</goals>
                                <arguments>-Pforgerock-release,forgerock-bundle-release</arguments>
                            </configuration>
                        </plugin-->
                        <plugin>
                            <artifactId>maven-site-plugin</artifactId>
                            <executions>
                                <execution>
                                    <id>site-deploy</id>
                                    <goals>
                                        <goal>site</goal>
                                        <goal>deploy</goal>
                                    </goals>
                                    <phase>site</phase>
                                </execution>
                                <execution>
                                    <id>site-stage-deploy</id>
                                    <goals>
                                        <goal>stage-deploy</goal>
                                    </goals>
                                    <phase>site</phase>
                                    <configuration>
                                        <stagingSiteURL>
                                            ${siteDistributionURL}/connectors/${project.artifactId}-${project.version}
                                        </stagingSiteURL>
                                    </configuration>
                                </execution>
                            </executions>
                        </plugin>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-scm-plugin</artifactId>
                            <configuration>
                                <tag>${project.artifactId}-${project.version}</tag>
                                <message>[ForgeRock Connector Release] ${project.name}</message>
                            </configuration>
                        </plugin>
                    </plugins>
                </pluginManagement>

                <plugins>
                    <plugin>
                        <groupId>org.apache.felix</groupId>
                        <artifactId>maven-bundle-plugin</artifactId>
                        <extensions>true</extensions>
                        <configuration>
                            <excludeDependencies>${openicf.osgi.exclude.dependencies}</excludeDependencies>
                            <instructions>
                                <!-- Required immutable instructions -->
                                <Embed-Directory>lib</Embed-Directory>
                                <Embed-Transitive>true</Embed-Transitive>

                                <!-- OpenICF Headers -->
                                <ConnectorBundle-FrameworkVersion>
                                    ${ConnectorBundle-FrameworkVersion}
                                </ConnectorBundle-FrameworkVersion>
                                <ConnectorBundle-Name>${ConnectorBundle-Name}</ConnectorBundle-Name>
                                <ConnectorBundle-Version>${ConnectorBundle-Version}</ConnectorBundle-Version>


                                <!-- OSGi Headers -->
                                <Bundle-Name>${project.name}</Bundle-Name>
                                <Bundle-SymbolicName>${openicf.osgi.symbolic.name}</Bundle-SymbolicName>
                                <Bundle-Activator>${openicf.osgi.activator}</Bundle-Activator>
                                <Export-Package>${openicf.osgi.export}</Export-Package>
                                <Import-Package>${openicf.osgi.import}</Import-Package>
                                <DynamicImport-Package>${openicf.osgi.dynamic.import}</DynamicImport-Package>
                                <Private-Package>${openicf.osgi.private}</Private-Package>
                                <Include-Resource>${openicf.osgi.include.resource}</Include-Resource>
                                <_versionpolicy>${openicf.osgi.import.default.version}</_versionpolicy>
                                <_removeheaders>${openicf.osgi.remove.headers}</_removeheaders>
                                <_failok>${openicf.osgi.failok}</_failok>
                                <Export-Service>${openicf.osgi.export.service}</Export-Service>
                                <Import-Service>${openicf.osgi.import.service}</Import-Service>
                                <Embed-Dependency>${openicf.osgi.embed}</Embed-Dependency>


                                <!-- Implementation Entries -->
                                <Implementation-Title>${project.name}</Implementation-Title>
                                <Implementation-Version>${project.version}</Implementation-Version>
                                <Implementation-Vendor-Id>${project.groupId}</Implementation-Vendor-Id>
                                <Implementation-Vendor>${project.organization.name}</Implementation-Vendor>

                                <!-- Specification Entries - ->
                                <Specification-Title>${project.name}</Specification-Title>
                                <Specification-Version>${project.version}</Specification-Version>
                                <Specification-Vendor>${project.organization.name}</Specification-Vendor-->


                                <!-- Miscellanies instructions -->
                                <Subversion-Revision>${env.SVN_REVISION}</Subversion-Revision>
                            </instructions>
                        </configuration>
                    </plugin>
                    <plugin>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>

                            <!-- Copy classes from contract tests -->
                            <execution>
                                <id>copy-contractclasses</id>
                                <phase>generate-test-sources</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.forgerock.openicf.framework</groupId>
                                            <artifactId>connector-framework-contract</artifactId>
                                            <outputDirectory>${project.build.directory}/contractClasses
                                            </outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.forgerock.openicf.framework</groupId>
                                            <artifactId>connector-framework-contract</artifactId>
                                            <classifier>sources</classifier>
                                            <outputDirectory>${project.build.directory}/contractSources
                                            </outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- We want to package up license resources in the JARs produced -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-remote-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>process</goal>
                                </goals>
                                <configuration>
                                    <resourceBundles>
                                        <resourceBundle>${licenseResourceBundle}</resourceBundle>
                                    </resourceBundles>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-jar-plugin</artifactId>
                        <executions>

                            <!-- Attach also test-jar -->
                            <execution>
                                <id>package-test</id>
                                <configuration>
                                    <excludes>
                                        <exclude>${connectorName}/**</exclude>
                                    </excludes>
                                </configuration>
                                <phase>package</phase>
                                <goals>
                                    <goal>test-jar</goal>
                                </goals>
                            </execution>

                            <!-- Attach public test config -->
                            <execution>
                                <id>package-publictestconfig</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <configuration>
                                    <classesDirectory>${project.build.testOutputDirectory}</classesDirectory>
                                    <classifier>publictestconfig</classifier>
                                    <includes>
                                        <include>${connectorName}/**</include>
                                    </includes>
                                    <excludes>
                                        <exclude>**/config-private/**</exclude>
                                    </excludes>
                                </configuration>
                            </execution>

                            <!-- Attach private test config -->
                            <!--execution>
                                <id>package-privatetestconfig</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <configuration>
                                    <classesDirectory>${project.build.testOutputDirectory}</classesDirectory>
                                    <classifier>privatetestconfig</classifier>
                                    <includes>
                                        <include>${connectorName}/config-private/**</include>
                                    </includes>
                                </configuration>
                            </execution-->
                        </executions>
                    </plugin>

                    <!-- Skip default test execution -->
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>default-test</id>
                                <configuration>
                                    <skipTests>true</skipTests>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Instead run surefire-execs plugin -->
                    <plugin>
                        <groupId>org.forgerock.openicf</groupId>
                        <artifactId>maven-surefire-execs-plugin</artifactId>
                        <executions>

                            <!-- Run junits with configuration -->
                            <execution>
                                <id>test-junits</id>
                                <phase>test</phase>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <configuration>
                                    <skipTests>${junits.skip}</skipTests>
                                    <testExecutionsPropertyValues>
                                        <propertyName>testConfig</propertyName>
                                        <propertyValues>${junitsConfigurations}</propertyValues>
                                    </testExecutionsPropertyValues>
                                </configuration>
                            </execution>

                            <!-- Run contract tests -->
                            <execution>
                                <id>test-contracts</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <configuration>
                                    <bundleJar>${project.build.directory}/${project.build.finalName}.jar</bundleJar>
                                    <skipTests>${contracts.skip}</skipTests>
                                    <testSourceDirectory>${project.build.directory}/contractSources
                                    </testSourceDirectory>
                                    <testClassesDirectory>${project.build.directory}/contractClasses
                                    </testClassesDirectory>
                                    <additionalClasspathElements>
                                        <additionalClasspathElement>${project.build.testOutputDirectory}
                                        </additionalClasspathElement>
                                    </additionalClasspathElements>
                                    <test>${contract.suiteName}</test>
                                    <systemProperties>
                                        <property>
                                            <name>connectorName</name>
                                            <value>${connectorName}</value>
                                        </property>
                                        <property>
                                            <name>bundleJar</name>
                                            <value>${project.build.directory}/${project.build.finalName}.jar</value>
                                        </property>
                                        <property>
                                            <name>bundleName</name>
                                            <!--value>${project.artifactId}</value-->
                                            <value>${ConnectorBundle-Name}</value>
                                        </property>
                                        <property>
                                            <name>bundleVersion</name>
                                            <!--value>${project.version}</value-->
                                            <value>${ConnectorBundle-Version}</value>
                                        </property>
                                    </systemProperties>
                                    <testExecutionsPropertyValues>
                                        <propertyName>testConfig</propertyName>
                                        <propertyValues>${contractsConfigurations}</propertyValues>
                                    </testExecutionsPropertyValues>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.forgerock.maven.plugins</groupId>
                        <artifactId>openicf-build-maven-plugin</artifactId>
                        <version>1.0.0-SNAPSHOT</version>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>reducepom</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <!--

        Maven uses when resolving custom properties:

        1. System properties: set with -Dxyz=value on the command line.
        2. From currently active profile(s): settings.xml in user home directory first,
           then profiles.xml in project root directory, then in profiles defined in your pom.xml.
           If many profiles are active, and a property is defined in more than one of those,
           the order of precedence is based on the last profile in which this property is defined,
           in alphabetical order of profile name.
        3. In the properties section of your pom.xml.
        4. Lastly, in properties defined in filters. If a property is defined in multiple filters,
           then the last one (in order of appearance in your filters section)
           has precedence over the others.

        -->
    </profiles>
</project>

