Index: build.xml
===================================================================
--- build.xml	(revision 696656)
+++ build.xml	(working copy)
@@ -464,6 +464,15 @@
     </sequential>
   </target>
 	
+  <target name="generate-osgi-bundles" depends="osgi.ant.tasks-check, jar-core, jar-src"
+    description="--> Generates the OSGi bundles">
+    <sequential>
+      <jarify-osgi bndfile="lucene-${name}-osgi.bnd.template"/>
+      <jarify-osgi-src/>
+      <contrib-crawl target="dist-osgi"/>
+    </sequential>
+  </target>
+    
   <!-- ================================================================== -->
   <!-- Build the JavaCC files into the source tree                        -->
   <!-- ================================================================== -->
Index: common-build.xml
===================================================================
--- common-build.xml	(revision 696656)
+++ common-build.xml	(working copy)
@@ -36,6 +36,7 @@
     <format property="current.year" pattern="yyyy"/>
     <format property="DSTAMP" pattern="yyyy-MM-dd"/>
     <format property="TSTAMP" pattern="HH:mm:ss"/>
+    <format property="bundle.timestamp" pattern="yyyyMMddHHmm"/>
   </tstamp>
 
   <property name="name" value="${ant.project.name}"/>
@@ -77,6 +78,7 @@
   <property name="maven.dist.dir" location="dist/maven"/>
   <property name="m2.repository.url" value="file://${maven.dist.dir}"/>
   <property name="m2.repository.private.key" value="${user.home}/.ssh/id_dsa"/>
+  <property name="osgi.dist.dir" location="dist/osgi"/>
 
   <property name="javacc.home" location="${common.dir}"/>
   <property name="jflex.home" location="${common.dir}"/>
@@ -124,6 +126,11 @@
     classname="org.apache.maven.artifact.ant.Pom"
   />
 	
+  <available
+    property="osgi.ant.tasks.present"
+    classname="aQute.bnd.ant.BaseTask"
+  />
+		
   <target name="clean"
     description="Removes contents of build and dist directories">
     <delete dir="${build.dir}"/>
@@ -451,6 +458,23 @@
     </junitreport>
   </target>
 
+  <target name="osgi.ant.tasks-check">
+	<fail unless="osgi.ant.tasks.present">
+	  ##################################################################
+      OSGi bundle ant tasks not found.
+	  
+      Please download the OSGi bundle ant tasks from:
+      http://www.aqute.biz/Code/Bnd
+	  
+      Please make sure the bnd jar is in ANT_HOME/lib, or made 
+	  available to Ant using other mechanisms like -lib or CLASSPATH.
+      ##################################################################
+  	</fail>
+    <taskdef resource="aQute/bnd/ant/taskdef.properties"/> 
+  </target>
+
+  <property name="osgi.bnd" value="osgi.bnd.template"/>
+  
   <target name="jar" depends="jar-core">
     <!-- convenience target to package core JAR -->
   </target>
@@ -535,7 +559,50 @@
    </sequential>
   </macrodef>
 
+  <macrodef name="jarify-osgi" description="Builds an OSGi JAR file">
+    <attribute name="bndfile" default="${osgi.bnd}"/>
+    <sequential>
+      <property name="package.version" value="${spec.version}"/>
+      <property name="bundle.version" value="${spec.version}.${bundle.timestamp}"/>
+      <property name="bundle.name" value="Lucene Search Engine: ${name}"/>
+      <property name="bundle.symbolicname" value="org.apache.lucene.${name}"/>
+      <property name="bundle.vendor" value="The Apache Software Foundation"/>
+      <property name="lucene.osgi.jar" value="${osgi.dist.dir}/org.apache.lucene.core_${spec.version}.${bundle.timestamp}.jar"/>
+      <mkdir dir="${osgi.dist.dir}"/>
+      <copy file="@{bndfile}" tofile="${build.dir}/osgi.bnd">
+        <filterset begintoken="@" endtoken="@"> 
+          <filter token="bundle.version" value="${bundle.version}"/>
+          <filter token="package.version" value="${package.version}"/>
+          <filter token="name" value="${name}"/>
+        </filterset>
+      </copy>
+      <bnd 
+        failok="false" 
+        files="${build.dir}/osgi.bnd"
+        output="${osgi.dist.dir}/${bundle.symbolicname}_${spec.version}.${bundle.timestamp}.jar"/> 
+    </sequential>
+  </macrodef>
 
+  <macrodef name="jarify-osgi-src" description="Builds an OSGi Source JAR file for Equinox">
+    <attribute name="bndfile" default="${osgi.bnd}"/>
+    <sequential>
+      <property name="bundle.symbolicname" value="org.apache.lucene.${name}"/>
+      <mkdir dir="${osgi.dist.dir}"/>
+      <jarify basedir="${src.dir}" destfile="${osgi.dist.dir}/${bundle.symbolicname}.source_${spec.version}.${bundle.timestamp}.jar">
+        <manifest-attributes>
+          <attribute name="Manifest-Version" value="1"/>
+          <attribute name="Bundle-SymbolicName" value="${bundle.symbolicname}.source"/>
+          <attribute name="Bundle-ManifestVersion" value="2"/>
+          <attribute name="Bundle-Name" value="Lucene Search Engine: ${name} source"/>
+          <attribute name="Bundle-Version" value="${spec.version}.${bundle.timestamp}"/>
+          <attribute name="Eclipse-SourceBundle" value='${bundle.symbolicname};version="${spec.version}.${bundle.timestamp}"'/>
+          <attribute name="Bundle-Vendor" value="The Apache Software Foundation"/>
+          <attribute name="Bundle-License" value="http://www.apache.org/licenses/LICENSE-2.0"/>
+        </manifest-attributes>
+      </jarify>
+    </sequential>
+  </macrodef>
+
 </project>
 
 

Property changes on: common-build.xml
___________________________________________________________________
Added: svn:eol-style
   + native

Index: contrib/analyzers/osgi.bnd.template
===================================================================
--- contrib/analyzers/osgi.bnd.template	(revision 0)
+++ contrib/analyzers/osgi.bnd.template	(revision 0)
@@ -0,0 +1,40 @@
+Bundle-Name: ${bundle.name}
+Bundle-SymbolicName: ${bundle.symbolicname}
+Bundle-Version: ${bundle.version}
+Bundle-Vendor: ${bundle.vendor}
+
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0
+
+Bundle-RequiredExecutionEnvironment:\
+ J2SE-1.5,\
+ J2SE-1.4
+
+Include-Resource:\
+ META-INF/NOTICE.txt=${common.dir}/NOTICE.txt,\
+ META-INF/LICENSE.txt=${common.dir}/LICENSE.txt
+
+Private-Package:\
+ ${bundle.symbolicname}.internal.*
+ 
+Export-Package:\
+ !${bundle.symbolicname}.internal.*,\
+ !org.apache.lucene.analysis,\
+ !org.apache.lucene.analysis.standard,\
+ org.apache.lucene.analysis.*;version=${package.version}
+ 
+-removeheaders:\
+ Originally-Created-By,\
+ Created-By,\
+ Bnd-LastModified,\
+ Ignore-Package,\
+ Include-Resource,\
+ Private-Package,\
+ Name,\
+ Tool,\
+ DSTAMP,\
+ TSTAMP,\
+ TODAY
+
+-classpath:\
+ ${build.dir}/classes/java,\
+ ${lucene.osgi.jar}
Index: contrib/contrib-build.xml
===================================================================
--- contrib/contrib-build.xml	(revision 696656)
+++ contrib/contrib-build.xml	(working copy)
@@ -24,6 +24,7 @@
   <property name="build.dir" location="../../build/contrib/${ant.project.name}"/>
   <property name="dist.dir" location="../../dist/contrib/${ant.project.name}"/>
   <property name="maven.dist.dir" location="../../dist/maven"/>
+  <property name="osgi.dist.dir" location="../../dist/osgi"/>
   	
   <import file="../common-build.xml"/>
 
@@ -89,6 +90,20 @@
     </sequential>
   </target>
 
+  <available 
+    type="file" 
+    file="${osgi.bnd}" 
+    property="osgi.bnd.present">
+  </available>
+  <property name="osgi.bnd.resolved" location="${osgi.bnd}"/>
+
+  <target name="dist-osgi" if="osgi.bnd.present" depends="compile-core">
+    <sequential>
+      <jarify-osgi/>
+      <jarify-osgi-src/>
+    </sequential>
+  </target>
+
   <target name="javadocs">
    	<sequential>
        <mkdir dir="${javadoc.dir}/contrib-${name}"/>
Index: contrib/db/bdb-je/build.xml
===================================================================
--- contrib/db/bdb-je/build.xml	(revision 696656)
+++ contrib/db/bdb-je/build.xml	(working copy)
@@ -20,6 +20,7 @@
   <property name="build.dir" location="../../../build/contrib/db/bdb-je" />
   <property name="dist.dir" location="../../../dist/contrib/db/bdb-je" />
   <property name="maven.dist.dir" location="../../../dist/maven" />
+  <property name="osgi.dist.dir" location="../../../dist/osgi" />
 	
   <import file="../../contrib-build.xml" />
 
Index: contrib/db/bdb/build.xml
===================================================================
--- contrib/db/bdb/build.xml	(revision 696656)
+++ contrib/db/bdb/build.xml	(working copy)
@@ -20,6 +20,7 @@
   <property name="build.dir" location="../../../build/contrib/db/bdb" />
   <property name="dist.dir" location="../../../dist/contrib/db/bdb" />
   <property name="maven.dist.dir" location="../../../dist/maven" />
+  <property name="osgi.dist.dir" location="../../../dist/osgi" />
 
   <import file="../../contrib-build.xml" />
 
Index: contrib/db/build.xml
===================================================================
--- contrib/db/build.xml	(revision 696656)
+++ contrib/db/build.xml	(working copy)
@@ -59,6 +59,11 @@
     <ant dir="bdb-je" target="dist-maven" />
   </target>  	
 
+  <target name="dist-osgi" depends="default">
+    <ant dir="bdb" target="dist-osgi" />
+    <ant dir="bdb-je" target="dist-osgi" />
+  </target>     
+
   <target name="javadocs">
     <ant dir="bdb" target="javadocs" />
     <ant dir="bdb-je" target="javadocs" />
Index: contrib/highlighter/build.xml
===================================================================
--- contrib/highlighter/build.xml	(revision 696656)
+++ contrib/highlighter/build.xml	(working copy)
@@ -28,6 +28,9 @@
   <property name="memory.jar" location="${common.dir}/build/contrib/memory/lucene-memory-${version}.jar"/>
   <available property="memory.jar.present" type="file" file="${memory.jar}"/>
 
+  <property name="memory.osgi.jar" location="${osgi.dist.dir}/org.apache.lucene.memory_${spec.version}.${bundle.timestamp}.jar"/>
+  <available property="memory.osgi.jar.present" type="file" file="${memory.osgi.jar}"/>
+
   <path id="classpath">
     <pathelement path="${lucene.jar}"/>
     <pathelement path="${memory.jar}"/>
@@ -38,7 +41,19 @@
 
   <target name="build-memory" unless="memory.jar.present">
     <echo>Highlighter building dependency ${memory.jar}</echo>
-    <ant antfile="../memory/build.xml" target="default" inheritall="true" dir="../memory" />
+    <ant antfile="../memory/build.xml" target="default" inheritall="false" dir="../memory" />
   </target>
 
+  <target name="dist-osgi" if="osgi.bnd.present" depends="compile-core, dist-memory-osgi">
+    <sequential>
+      <jarify-osgi/>
+      <jarify-osgi-src/>
+    </sequential>
+  </target>
+
+  <target name="dist-memory-osgi" unless="memory.osgi.jar.present">
+    <echo>Highlighter building dependency ${memory.osgi.jar}</echo>
+    <ant antfile="../memory/build.xml" target="dist-osgi" inheritall="false" dir="../memory" />
+  </target>
+
 </project>
Index: contrib/highlighter/osgi.bnd.template
===================================================================
--- contrib/highlighter/osgi.bnd.template	(revision 0)
+++ contrib/highlighter/osgi.bnd.template	(revision 0)
@@ -0,0 +1,39 @@
+Bundle-Name: ${bundle.name}
+Bundle-SymbolicName: ${bundle.symbolicname}
+Bundle-Version: ${bundle.version}
+Bundle-Vendor: ${bundle.vendor}
+
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0
+
+Bundle-RequiredExecutionEnvironment:\
+ J2SE-1.5,\
+ J2SE-1.4
+
+Include-Resource:\
+ META-INF/NOTICE.txt=${common.dir}/NOTICE.txt,\
+ META-INF/LICENSE.txt=${common.dir}/LICENSE.txt
+
+Private-Package:\
+ ${bundle.symbolicname}.internal.*
+ 
+Export-Package:\
+ !${bundle.symbolicname}.internal.*,\
+ org.apache.lucene.search.highlight.*;version=${package.version}
+ 
+-removeheaders:\
+ Originally-Created-By,\
+ Created-By,\
+ Bnd-LastModified,\
+ Ignore-Package,\
+ Include-Resource,\
+ Private-Package,\
+ Name,\
+ Tool,\
+ DSTAMP,\
+ TSTAMP,\
+ TODAY
+
+-classpath:\
+ ${build.dir}/classes/java,\
+ ${lucene.osgi.jar},\
+ ${memory.osgi.jar}
Index: contrib/memory/osgi.bnd.template
===================================================================
--- contrib/memory/osgi.bnd.template	(revision 0)
+++ contrib/memory/osgi.bnd.template	(revision 0)
@@ -0,0 +1,38 @@
+Bundle-Name: ${bundle.name}
+Bundle-SymbolicName: ${bundle.symbolicname}
+Bundle-Version: ${bundle.version}
+Bundle-Vendor: ${bundle.vendor}
+
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0
+
+Bundle-RequiredExecutionEnvironment:\
+ J2SE-1.5,\
+ J2SE-1.4
+
+Include-Resource:\
+ META-INF/NOTICE.txt=${common.dir}/NOTICE.txt,\
+ META-INF/LICENSE.txt=${common.dir}/LICENSE.txt
+
+Private-Package:\
+ ${bundle.symbolicname}.internal.*
+ 
+Export-Package:\
+ !${bundle.symbolicname}.internal.*,\
+ org.apache.lucene.index.memory.*;version=${package.version}
+ 
+-removeheaders:\
+ Originally-Created-By,\
+ Created-By,\
+ Bnd-LastModified,\
+ Ignore-Package,\
+ Include-Resource,\
+ Private-Package,\
+ Name,\
+ Tool,\
+ DSTAMP,\
+ TSTAMP,\
+ TODAY
+
+-classpath:\
+ ${build.dir}/classes/java,\
+ ${lucene.osgi.jar}
Index: contrib/queries/osgi.bnd.template
===================================================================
--- contrib/queries/osgi.bnd.template	(revision 0)
+++ contrib/queries/osgi.bnd.template	(revision 0)
@@ -0,0 +1,39 @@
+Bundle-Name: ${bundle.name}
+Bundle-SymbolicName: ${bundle.symbolicname}
+Bundle-Version: ${bundle.version}
+Bundle-Vendor: ${bundle.vendor}
+
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0
+
+Bundle-RequiredExecutionEnvironment:\
+ J2SE-1.5,\
+ J2SE-1.4
+
+Include-Resource:\
+ META-INF/NOTICE.txt=${common.dir}/NOTICE.txt,\
+ META-INF/LICENSE.txt=${common.dir}/LICENSE.txt
+
+Private-Package:\
+ ${bundle.symbolicname}.internal.*
+ 
+Export-Package:\
+ !${bundle.symbolicname}.internal.*,\
+ org.apache.lucene.search;-split-package:=first;queries=split;version=${package.version};mandatory:=queries,\
+ org.apache.lucene.search.similar.*;version=${package.version}
+
+-removeheaders:\
+ Originally-Created-By,\
+ Created-By,\
+ Bnd-LastModified,\
+ Ignore-Package,\
+ Include-Resource,\
+ Private-Package,\
+ Name,\
+ Tool,\
+ DSTAMP,\
+ TSTAMP,\
+ TODAY
+
+-classpath:\
+ ${build.dir}/classes/java,\
+ ${lucene.osgi.jar}
Index: contrib/xml-query-parser/build.xml
===================================================================
--- contrib/xml-query-parser/build.xml	(revision 696656)
+++ contrib/xml-query-parser/build.xml	(working copy)
@@ -22,12 +22,18 @@
   <description>
     XML query parser
   </description>
+  
+  <!-- overwrite OSGi bundle symbolic name (dash is not allowed) -->
+  <property name="bundle.symbolicname" value="org.apache.lucene.xmlparser"/>
 
   <import file="../contrib-build.xml"/>
 
   <property name="queries.jar" location="${common.dir}/build/contrib/queries/lucene-queries-${version}.jar"/>
   <available property="queries.jar.present" type="file" file="${queries.jar}"/>
 
+  <property name="queries.osgi.jar" location="${osgi.dist.dir}/org.apache.lucene.queries_${spec.version}.${bundle.timestamp}.jar"/>
+  <available property="queries.osgi.jar.present" type="file" file="${queries.osgi.jar}"/>
+
   <path id="classpath">
     <pathelement path="${lucene.jar}"/>
     <pathelement path="${queries.jar}"/>
@@ -42,4 +48,16 @@
     <ant antfile="../queries/build.xml" target="default" inheritall="true" dir="../queries" />
   </target>
 
+  <target name="dist-osgi" if="osgi.bnd.present" depends="compile-core, dist-queries-osgi">
+    <sequential>
+      <jarify-osgi/>
+      <jarify-osgi-src/>
+    </sequential>
+  </target>
+
+  <target name="dist-queries-osgi" unless="queries.osgi.jar.present">
+    <echo>XML Parser building dependency ${queries.osgi.jar}</echo>
+    <ant antfile="../queries/build.xml" target="dist-osgi" inheritall="false" dir="../queries" />
+  </target>
+
 </project>
Index: contrib/xml-query-parser/osgi.bnd.template
===================================================================
--- contrib/xml-query-parser/osgi.bnd.template	(revision 0)
+++ contrib/xml-query-parser/osgi.bnd.template	(revision 0)
@@ -0,0 +1,39 @@
+Bundle-Name: ${bundle.name}
+Bundle-SymbolicName: ${bundle.symbolicname}
+Bundle-Version: ${bundle.version}
+Bundle-Vendor: ${bundle.vendor}
+
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0
+
+Bundle-RequiredExecutionEnvironment:\
+ J2SE-1.5,\
+ J2SE-1.4
+
+Include-Resource:\
+ META-INF/NOTICE.txt=${common.dir}/NOTICE.txt,\
+ META-INF/LICENSE.txt=${common.dir}/LICENSE.txt
+
+Private-Package:\
+ ${bundle.symbolicname}.internal.*
+ 
+Export-Package:\
+ !${bundle.symbolicname}.internal.*,\
+ org.apache.lucene.xmlparser.*;version=${package.version}
+
+-removeheaders:\
+ Originally-Created-By,\
+ Created-By,\
+ Bnd-LastModified,\
+ Ignore-Package,\
+ Include-Resource,\
+ Private-Package,\
+ Name,\
+ Tool,\
+ DSTAMP,\
+ TSTAMP,\
+ TODAY
+
+-classpath:\
+ ${build.dir}/classes/java,\
+ ${lucene.osgi.jar},\
+ ${queries.osgi.jar}
\ No newline at end of file
Index: lucene-core-osgi.bnd.template
===================================================================
--- lucene-core-osgi.bnd.template	(revision 0)
+++ lucene-core-osgi.bnd.template	(revision 0)
@@ -0,0 +1,38 @@
+Bundle-Name: ${bundle.name}
+Bundle-SymbolicName: ${bundle.symbolicname}
+Bundle-Version: ${bundle.version}
+Bundle-Vendor: ${bundle.vendor}
+
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0
+
+Bundle-RequiredExecutionEnvironment:\
+ J2SE-1.5,\
+ J2SE-1.4
+
+Include-Resource:\
+ META-INF/NOTICE.txt=${common.dir}/NOTICE.txt,\
+ META-INF/LICENSE.txt=${common.dir}/LICENSE.txt
+
+Private-Package:\
+ ${bundle.symbolicname}.internal.*
+ 
+Export-Package:\
+ !${bundle.symbolicname}.internal.*,\
+ org.apache.lucene.search;core=split;version=${package.version};mandatory:=core,\
+ org.apache.lucene.*;version=${package.version}
+
+-removeheaders:\
+ Originally-Created-By,\
+ Created-By,\
+ Bnd-LastModified,\
+ Ignore-Package,\
+ Include-Resource,\
+ Private-Package,\
+ Name,\
+ Tool,\
+ DSTAMP,\
+ TSTAMP,\
+ TODAY
+
+-classpath:\
+ ${build.dir}/classes/java
