You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by mc...@apache.org on 2008/02/05 13:38:47 UTC

svn commit: r618629 - /felix/trunk/bundleplugin/doc/maven-bundle-plugin-bnd.html

Author: mcculls
Date: Tue Feb  5 04:38:46 2008
New Revision: 618629

URL: http://svn.apache.org/viewvc?rev=618629&view=rev
Log:
Refresh bundleplugin docs

Modified:
    felix/trunk/bundleplugin/doc/maven-bundle-plugin-bnd.html

Modified: felix/trunk/bundleplugin/doc/maven-bundle-plugin-bnd.html
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/doc/maven-bundle-plugin-bnd.html?rev=618629&r1=618628&r2=618629&view=diff
==============================================================================
--- felix/trunk/bundleplugin/doc/maven-bundle-plugin-bnd.html (original)
+++ felix/trunk/bundleplugin/doc/maven-bundle-plugin-bnd.html Tue Feb  5 04:38:46 2008
@@ -398,6 +398,36 @@
 </pre>
 </div></div>
 
+<h2><a name="MavenBundlePlugin(BND)-AddingOSGimetadatatoexistingprojectswithoutchangingthepackagingtype"></a>Adding OSGi metadata to existing projects without changing the packaging type</h2>
+
+<p>If you want to keep your project packaging type (for example "jar") but would like to add OSGi metadata<br>
+you can use the manifest goal to generate a bundle manifest. The maven-jar-plugin can then be used to<br>
+add this manifest to the final artifact. For example:</p>
+
+<div class="code"><div class="codeContent">
+<pre class="code-xml"><span class="code-tag">&lt;plugin&gt;</span>
+  <span class="code-tag">&lt;artifactId&gt;</span>maven-jar-plugin<span class="code-tag">&lt;/artifactId&gt;</span>
+  <span class="code-tag">&lt;configuration&gt;</span>
+    <span class="code-tag">&lt;archive&gt;</span>  
+      <span class="code-tag">&lt;manifestFile&gt;</span>${project.build.outputDirectory}/META-INF/MANIFEST.MF<span class="code-tag">&lt;/manifestFile&gt;</span>
+    <span class="code-tag">&lt;/archive&gt;</span> 
+  <span class="code-tag">&lt;/configuration&gt;</span>
+<span class="code-tag">&lt;/plugin&gt;</span>  
+<span class="code-tag">&lt;plugin&gt;</span>   
+  <span class="code-tag">&lt;groupId&gt;</span>org.apache.felix<span class="code-tag">&lt;/groupId&gt;</span>
+  <span class="code-tag">&lt;artifactId&gt;</span>maven-bundle-plugin<span class="code-tag">&lt;/artifactId&gt;</span>
+  <span class="code-tag">&lt;executions&gt;</span>
+    <span class="code-tag">&lt;execution&gt;</span>
+      <span class="code-tag">&lt;id&gt;</span>bundle-manifest<span class="code-tag">&lt;/id&gt;</span>
+      <span class="code-tag">&lt;phase&gt;</span>process-classes<span class="code-tag">&lt;/phase&gt;</span>
+      <span class="code-tag">&lt;goals&gt;</span>    
+        <span class="code-tag">&lt;goal&gt;</span>manifest<span class="code-tag">&lt;/goal&gt;</span>
+      <span class="code-tag">&lt;/goals&gt;</span>   
+    <span class="code-tag">&lt;/execution&gt;</span>
+  <span class="code-tag">&lt;/executions&gt;</span>
+<span class="code-tag">&lt;/plugin&gt;</span></pre>
+</div></div>
+
 <h2><a name="MavenBundlePlugin(BND)-BuildingthePlugin"></a>Building the Plugin</h2>
 
 <p>The plugin is hosted at the Apache Felix project. The following
@@ -434,31 +464,44 @@
 <p>Where GOAL is one of the following:</p>
 
 <ul>
-	<li><tt>bundle</tt> - build an OSGi bundle jar<br>
+	<li><b><tt>bundle</tt></b> - build an OSGi bundle jar<br>
 configuration options:
 	<ul>
-		<li><tt>manifestLocation</tt> defaults to ${project.build.outputDirectory}/META-INF</li>
-		<li><tt>unpackBundle</tt> unpack bundle contents to output directory, defaults to false</li>
-		<li><tt>supportedProjectTypes</tt> defaults to "jar","bundle"</li>
+		<li><em><tt>manifestLocation</tt></em> defaults to ${project.build.outputDirectory}/META-INF</li>
+		<li><em><tt>unpackBundle</tt></em> unpack bundle contents to output directory, defaults to false</li>
+		<li><em><tt>excludeDependencies</tt></em> exclude all dependencies from the classpath passed to Bnd, defaults to false</li>
+		<li><em><tt>supportedProjectTypes</tt></em> defaults to "jar","bundle"</li>
 	</ul>
 	</li>
-	<li><tt>bundleall</tt> - build an OSGi bundle jar for all transitive dependencies<br>
+</ul>
+
+
+<ul>
+	<li><b><tt>bundleall</tt></b> - build an OSGi bundle jar for all transitive dependencies<br>
 configuration options:
 	<ul>
-		<li><tt>supportedProjectTypes</tt> defaults to "jar","bundle"</li>
+		<li><em><tt>supportedProjectTypes</tt></em> defaults to "jar","bundle"</li>
 	</ul>
 	</li>
-	<li><tt>wrap</tt> - as above, but limited to the first level of dependencies<br>
+</ul>
+
+
+<ul>
+	<li><b><tt>wrap</tt></b> - as above, but limited to the first level of dependencies<br>
 configuration options:
 	<ul>
-		<li><tt>supportedProjectTypes</tt> defaults to "jar","bundle"</li>
+		<li><em><tt>supportedProjectTypes</tt></em> defaults to "jar","bundle"</li>
 	</ul>
 	</li>
-	<li><tt>manifest</tt> - create an OSGi manifest for the current project<br>
+</ul>
+
+
+<ul>
+	<li><b><tt>manifest</tt></b> - create an OSGi manifest for the current project<br>
 configuration options:
 	<ul>
-		<li><tt>manifestLocation</tt> defaults to ${project.build.outputDirectory}/META-INF</li>
-		<li><tt>supportedProjectTypes</tt> defaults to "jar","bundle"</li>
+		<li><em><tt>manifestLocation</tt></em> defaults to ${project.build.outputDirectory}/META-INF</li>
+		<li><em><tt>supportedProjectTypes</tt></em> defaults to "jar","bundle"</li>
 	</ul>
 	</li>
 </ul>
@@ -467,11 +510,11 @@
 <p>There are also new instructions available from the underlying BND
 tool, which continues to be improved independently; for the latest see <span class="nobr"><a href="http://aqute.biz/Code/Bnd" title="Visit page outside Confluence" rel="nofollow">BND documentation<sup><img class="rendericon" src="maven-bundle-plugin-bnd_files/linkext7.gif" alt="" align="absmiddle" border="0" height="7" width="7"></sup></a></span>.</p>
 
-<p>The default goal <tt>bundle</tt> will be initialized by setting the &lt;packaging&gt; entry to "bundle".</p>
+<p>The default goal <b><tt>bundle</tt></b> will be initialized by setting the &lt;packaging&gt; entry to "bundle".</p>
 
-<h1><a name="MavenBundlePlugin(BND)-Thefollowingfeaturesareonlyavailableinthe1.1.0SNAPSHOTversion"></a>The following features are only available in the 1.1.0-SNAPSHOT version</h1>
+<h1><a name="MavenBundlePlugin(BND)-Thefollowingfeaturesareonlyavailableinversionsafter1.0.0"></a>The following features are only available in versions after 1.0.0</h1>
 
-<h1><a name="MavenBundlePlugin(BND)-Embeddingdependencies"></a>Embedding dependencies</h1>
+<h2><a name="MavenBundlePlugin(BND)-Embeddingdependencies"></a>Embedding dependencies</h2>
 
 <p>The Maven Bundle Plugin supports embedding of selected project dependencies inside the bundle by using the <tt>&lt;Embed-Dependency&gt;</tt> instruction:</p>
 
@@ -524,7 +567,7 @@
 <pre class="code-xml"><span class="code-tag">&lt;Embed-Dependency&gt;</span>*;scope=compile|runtime;inline=true<span class="code-tag">&lt;/Embed-Dependency&gt;</span></pre>
 </div></div>
 
-<h2><a name="MavenBundlePlugin(BND)-EmbedDependencyandExportPackage"></a>Embed-Dependency and Export-Package</h2>
+<h3><a name="MavenBundlePlugin(BND)-EmbedDependencyandExportPackage"></a>Embed-Dependency and Export-Package</h3>
 
 <p>If you embed a dependency with <tt>&lt;Embed-Dependency&gt;</tt>, and your <tt>&lt;Export-Package&gt;</tt> or <tt>&lt;Private-Package&gt;</tt> instructions match packages inside the embedded jar, you will see some duplication inside the bundle. This is because the <tt>&lt;Export-Package&gt;</tt> and <tt>&lt;Private-Package&gt;</tt>
 instructions will result in classes being inlined in the bundle, even
@@ -534,7 +577,7 @@
 
 <p><tt>&lt;_exportcontents&gt;</tt> behaves just like Export-Package, except it doesn't change the content of the bundle, just what content should be exported.</p>
 
-<h1><a name="MavenBundlePlugin(BND)-OBRintegration"></a>OBR integration</h1>
+<h2><a name="MavenBundlePlugin(BND)-OBRintegration"></a>OBR integration</h2>
 
 <p>The latest Maven Bundle Plugin automatically updates the local OBR
 repository.xml file during the install phase, using a default location
@@ -578,8 +621,7 @@
 <span class="code-tag">&lt;/configuration&gt;</span></pre>
 </div></div>
 
-
-<h1><a name="MavenBundlePlugin(BND)-Eclipse/PDEintegration"></a>Eclipse/PDE integration</h1>
+<h2><a name="MavenBundlePlugin(BND)-Eclipse/PDEintegration"></a>Eclipse/PDE integration</h2>
 
 <p>It is possible to configure the Maven Bundle Plugin to put the
 bundle manifest where Eclipse/PDE expects it, and use the Maven
@@ -605,11 +647,22 @@
   &lt;packaging&gt;bundle&lt;/packaging&gt;
 
   &lt;build&gt;
+    &lt;resources&gt;
+      &lt;resource&gt;
+        &lt;directory&gt;src/main/resources&lt;/directory&gt;
+      &lt;/resource&gt;
+      &lt;resource&gt;
+        &lt;directory&gt;.&lt;/directory&gt;
+        &lt;includes&gt;
+          &lt;include&gt;plugin.xml&lt;/include&gt;
+        &lt;/includes&gt;
+      &lt;/resource&gt;
+    &lt;/resources&gt;
     &lt;plugins&gt;
       &lt;plugin&gt;
         &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
         &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
-        &lt;version&gt;1.1.0-SNAPSHOT&lt;/version&gt;
+        &lt;version&gt;1.2.0&lt;/version&gt;
         &lt;extensions&gt;true&lt;/extensions&gt;
         &lt;!--
           the following instructions build a simple set of public/private classes into an OSGi bundle
@@ -622,9 +675,9 @@
             &lt;!--
               assume public classes are in the top package, and private classes are under ".internal"
             --&gt;
-            &lt;Export-Package&gt;${bundle.namespace};version="${pom.version}"&lt;/Export-Package&gt;
-            &lt;Private-Package&gt;${bundle.namespace}.internal&lt;/Private-Package&gt;
-            &lt;Bundle-Activator&gt;${bundle.namespace}.internal.Activator&lt;/Bundle-Activator&gt;
+            &lt;Export-Package&gt;!${bundle.namespace}.internal.*,${bundle.namespace}.*;version="${pom.version}"&lt;/Export-Package&gt;
+            &lt;Private-Package&gt;${bundle.namespace}.internal.*&lt;/Private-Package&gt;
+            &lt;Bundle-Activator&gt;${bundle.namespace}.internal.ExampleActivator&lt;/Bundle-Activator&gt;
             &lt;!--
               embed compile/runtime dependencies using path that matches the copied dependency folder
             --&gt;
@@ -697,7 +750,7 @@
 handle any embedded entries. The pax:eclipse goal extends
 eclipse:eclipse, and supports the same parameters.</p>
 
-<h1><a name="MavenBundlePlugin(BND)-Unpackingbundlecontentsto'target/classes'"></a>Unpacking bundle contents to 'target/classes'</h1>
+<h2><a name="MavenBundlePlugin(BND)-Unpackingbundlecontentsto'target/classes'"></a>Unpacking bundle contents to 'target/classes'</h2>
 
 <p>Once in a while you may create a bundle which contains additional classes to the ones compiled from <tt>src/main/java</tt>,
 for example when you embed the classes from another jar. This can
@@ -710,24 +763,24 @@
 Thankfully there is now an easy option to do this in the bundle-plugin:</p>
 
 <div class="code"><div class="codeContent">
-<pre class="code-java">&lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
-&lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
-&lt;extensions&gt;<span class="code-keyword">true</span>&lt;/extensions&gt;
-&lt;configuration&gt;
-  &lt;unpackBundle&gt;<span class="code-keyword">true</span>&lt;/unpackBundle&gt;
-  &lt;instructions&gt;
-    &lt;!-- bnd instructions --&gt;
-  &lt;/instructions&gt;
-&lt;/configuration&gt;</pre>
+<pre class="code-xml"><span class="code-tag">&lt;groupId&gt;</span>org.apache.felix<span class="code-tag">&lt;/groupId&gt;</span>
+<span class="code-tag">&lt;artifactId&gt;</span>maven-bundle-plugin<span class="code-tag">&lt;/artifactId&gt;</span>
+<span class="code-tag">&lt;extensions&gt;</span>true<span class="code-tag">&lt;/extensions&gt;</span>
+<span class="code-tag">&lt;configuration&gt;</span>
+  <span class="code-tag">&lt;unpackBundle&gt;</span>true<span class="code-tag">&lt;/unpackBundle&gt;</span>
+  <span class="code-tag">&lt;instructions&gt;</span>
+    <span class="code-tag"><span class="code-comment">&lt;!-- bnd instructions --&gt;</span></span>
+  <span class="code-tag">&lt;/instructions&gt;</span>
+<span class="code-tag">&lt;/configuration&gt;</span></pre>
 </div></div>
 
-<h1><a name="MavenBundlePlugin(BND)-UsinganexistingMANIFEST.MFfile"></a>Using an existing MANIFEST.MF file</h1>
+<h2><a name="MavenBundlePlugin(BND)-UsinganexistingMANIFEST.MFfile"></a>Using an existing MANIFEST.MF file</h2>
 
 <p>If you have an existing manifest, you can add this to the Bnd instructions, like so:</p>
 
 <div class="code"><div class="codeContent">
-<pre class="code-java">&lt;_include&gt;src/main/resources/META-INF/MANIFEST.MF&lt;/_include&gt;
-&lt;Export-Package&gt;org.example.*&lt;/Export-Package&gt;</pre>
+<pre class="code-xml"><span class="code-tag">&lt;_include&gt;</span>src/main/resources/META-INF/MANIFEST.MF<span class="code-tag">&lt;/_include&gt;</span>
+<span class="code-tag">&lt;Export-Package&gt;</span>org.example.*<span class="code-tag">&lt;/Export-Package&gt;</span></pre>
 </div></div>
 
 <p>Bnd will use it when calculating the bundle contents, and will also