Index: build.xml
===================================================================
--- build.xml	(revision 696310)
+++ build.xml	(working copy)
@@ -464,6 +464,40 @@
     </sequential>
   </target>
 	
+  <target name="generate-osgi-bundles" depends="osgi.ant.tasks-check, jar-core, jar-src"
+    description="--> Generates the OSGi bundles">
+    <sequential>
+      <mkdir dir="${osgi.dist.dir}"/>
+      <!-- bundle version must match "major.minor.service[.qualifier]", only qualifier can be a string -->
+      <property name="bundle.version" value="${spec.version}.${bundle.timestamp}"/>
+      <!-- bundle version must match "major.minor.service" -->
+      <property name="package.version" value="${spec.version}"/>
+      <copy file="lucene-${name}-osgi.bnd.template" tofile="${build.dir}/lucene-${name}-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 
+        classpath="${build.dir}/classes/java" 
+        failok="false" 
+        files="${build.dir}/lucene-${name}-osgi.bnd"
+        output="${osgi.dist.dir}/org.apache.lucene.${name}_${spec.version}.${bundle.timestamp}.jar"/> 
+      <jarify basedir="src/java" destfile="${osgi.dist.dir}/org.apache.lucene.${name}.source_${spec.version}.${bundle.timestamp}.jar">
+        <manifest-attributes>
+          <attribute name="Manifest-Version" value="1"/>
+          <attribute name="Bundle-SymbolicName" value="org.apache.lucene.${name}.source"/>
+          <attribute name="Bundle-ManifestVersion" value="2"/>
+          <attribute name="Bundle-Name" value="Lucene Search Engine: ${name} source"/>
+          <attribute name="Bundle-Version" value="${bundle.version}"/>
+          <attribute name="Eclipse-SourceBundle" value='org.apache.lucene.${name};version="${bundle.version}"'/>
+          <attribute name="Bundle-Vendor" value="The Apache Software Foundation"/>
+        </manifest-attributes>
+      </jarify>
+    </sequential>
+  </target>
+    
   <!-- ================================================================== -->
   <!-- Build the JavaCC files into the source tree                        -->
   <!-- ================================================================== -->
Index: common-build.xml
===================================================================
--- common-build.xml	(revision 696310)
+++ 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:
+      https://opensource.luminis.net/confluence/display/SITE/OSGi+Bundle+Ant+Task
+	  
+      Please make sure the net.luminis.build.plugin 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>
+
+
   <target name="jar" depends="jar-core">
     <!-- convenience target to package core JAR -->
   </target>
Index: lucene-core-osgi.bnd.template
===================================================================
--- lucene-core-osgi.bnd.template	(revision 0)
+++ lucene-core-osgi.bnd.template	(revision 0)
@@ -0,0 +1,11 @@
+-removeheaders=DSTAMP,TSTAMP,TODAY
+bundle.version=@bundle.version@
+package.version=@package.version@
+name=@name@
+
+Export-Package= *;version=${package.version}
+Bundle-Version= ${bundle.version}
+Bundle-Vendor= The Apache Software Foundation
+Bundle-Name= Lucene Search Engine: ${name}
+Bundle-SymbolicName= org.apache.lucene.${name}
+
