From ded21ed1790d125f36b9309b20879630f76db3cc Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Mon, 25 Mar 2013 17:40:53 +0000
Subject: [PATCH] Fix OPENDJ-833: Fix OSGi integration for OpenDJ LDAP SDK and sub-modules

---
 opendj3/opendj-rest2ldap-servlet/pom.xml |    7 -------
 opendj3/opendj-ldap-sdk/pom.xml          |    8 +++-----
 opendj3/opendj-rest2ldap/pom.xml         |    7 ++++++-
 opendj3/pom.xml                          |   30 ++++++++++++++++++++++++++++++
 4 files changed, 39 insertions(+), 13 deletions(-)

diff --git a/opendj3/opendj-ldap-sdk/pom.xml b/opendj3/opendj-ldap-sdk/pom.xml
index c625079..22c46d5 100644
--- a/opendj3/opendj-ldap-sdk/pom.xml
+++ b/opendj3/opendj-ldap-sdk/pom.xml
@@ -57,6 +57,9 @@
       <scope>test</scope>
     </dependency>
   </dependencies>
+  <properties>
+      <opendj.osgi.import.additional>com.sun.security.auth*;resolution:=optional</opendj.osgi.import.additional>
+  </properties>
   <build>
     <plugins>
       <plugin>
@@ -80,11 +83,6 @@
         <groupId>org.apache.felix</groupId>
         <artifactId>maven-bundle-plugin</artifactId>
         <extensions>true</extensions>
-        <configuration>
-          <instructions>
-            <Export-Package>org.forgerock.opendj.*</Export-Package>
-          </instructions>
-        </configuration>
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
diff --git a/opendj3/opendj-rest2ldap-servlet/pom.xml b/opendj3/opendj-rest2ldap-servlet/pom.xml
index 11c2ec8..cc05569 100644
--- a/opendj3/opendj-rest2ldap-servlet/pom.xml
+++ b/opendj3/opendj-rest2ldap-servlet/pom.xml
@@ -73,13 +73,6 @@
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <extensions>true</extensions>
-                <configuration>
-                    <instructions>
-                        <Export-Package>
-                            org.forgerock.opendj.rest2ldap.servlet;version=${project.version}
-                        </Export-Package>
-                    </instructions>
-                </configuration>
             </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
diff --git a/opendj3/opendj-rest2ldap/pom.xml b/opendj3/opendj-rest2ldap/pom.xml
index 0ac7b5b..ea8e42d 100644
--- a/opendj3/opendj-rest2ldap/pom.xml
+++ b/opendj3/opendj-rest2ldap/pom.xml
@@ -27,7 +27,7 @@
     <description>
         This module includes APIs for accessing LDAP repositories using commons REST.
     </description>
-    <packaging>jar</packaging>
+    <packaging>bundle</packaging>
     <properties>
         <forgerockRestVersion>2.0.0-SNAPSHOT</forgerockRestVersion>
         <checkstyleHeaderLocation>org/forgerock/checkstyle/default-java-header</checkstyleHeaderLocation>
@@ -77,6 +77,11 @@
       </plugin>
       -->
             <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>
             </plugin>
diff --git a/opendj3/pom.xml b/opendj3/pom.xml
index 5fbbd0b..5fb121a 100644
--- a/opendj3/pom.xml
+++ b/opendj3/pom.xml
@@ -107,6 +107,18 @@
     <i18nFrameworkVersion>1.4.0</i18nFrameworkVersion>
     <grizzlyFrameworkVersion>2.2.19</grizzlyFrameworkVersion>
     <gaId>UA-23412190-8</gaId>
+    <!-- OSGi bundles properties -->
+    <opendj.osgi.import.additional/>
+    <!--
+     | Use provide:=true to disallow mixing OpenDJ and ForgeRock resource versions.
+     | it change the version policy from == + to == =+  [2.0,3) [2.0,2.1)
+    -->
+    <opendj.osgi.import>
+     org.forgerock.opendj.*;provide:=true,
+     org.forgerock.json.*;provide:=true,
+     ${opendj.osgi.import.additional},
+     *
+    </opendj.osgi.import>
     <!--
       Release date is specified only when building the documentation
       for publication. For example:
@@ -200,6 +212,24 @@
             </properties>
           </configuration>
         </plugin>
+          <plugin>
+              <groupId>org.apache.felix</groupId>
+              <artifactId>maven-bundle-plugin</artifactId>
+              <version>2.3.7</version>
+              <extensions>true</extensions>
+              <configuration>
+                  <instructions>
+                      <!--
+                      | Remove the by default removed headers plus some other to make cleaner the generated MANIFEST.MF
+                      -->
+                      <_removeheaders>
+                          Bnd-LastModified,Built-By,Private-Package,Tool,Created-By,Build-Jdk,Include-Resource,
+                          Ignore-Package,Private-Package,Bundle-DocURL
+                      </_removeheaders>
+                      <Import-Package>${opendj.osgi.import}</Import-Package>
+                  </instructions>
+              </configuration>
+          </plugin>
         <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-javadoc-plugin</artifactId>

--
Gitblit v1.10.0