Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
Stuart McCulloch | 981bd34 | 2008-05-03 12:49:39 +0000 | [diff] [blame] | 2 | <html><head> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 3 | |
| 4 | |
| 5 | |
Stuart McCulloch | 981bd34 | 2008-05-03 12:49:39 +0000 | [diff] [blame] | 6 | <title>Apache Felix - Apache Felix Maven Bundle Plugin (BND)</title> |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 7 | <link rel="stylesheet" href="apache-felix-maven-bundle-plugin-bnd_files/site.css" type="text/css" media="all"> |
Stuart McCulloch | 981bd34 | 2008-05-03 12:49:39 +0000 | [diff] [blame] | 8 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| 9 | </head><body> |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 10 | <div class="title"><div class="logo"><a href="http://felix.apache.org/site/index.html"><img alt="Apache Felix" src="apache-felix-maven-bundle-plugin-bnd_files/logo.png" border="0"></a></div><div class="header"><a href="http://www.apache.org/"><img alt="Apache" src="apache-felix-maven-bundle-plugin-bnd_files/apache.png" border="0"></a></div></div> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 11 | <div class="menu"> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 12 | <ul> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 13 | <li><a href="http://felix.apache.org/site/news.html" title="news">news</a></li> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 14 | <li><a href="http://felix.apache.org/site/license.html" title="license">license</a></li> |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 15 | <li><span class="nobr"><a href="http://felix.apache.org/site/downloads.cgi" title="Visit page outside Confluence" rel="nofollow">downloads<sup><img class="rendericon" src="apache-felix-maven-bundle-plugin-bnd_files/linkext7.gif" alt="" width="7" align="absmiddle" border="0" height="7"></sup></a></span></li> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 16 | <li><a href="http://felix.apache.org/site/documentation.html" title="documentation">documentation</a></li> |
| 17 | <li><a href="http://felix.apache.org/site/mailinglists.html" title="mailinglists">mailing lists</a></li> |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 18 | <li><a href="http://felix.apache.org/site/contributing.html" title="Contributing">contributing</a></li> |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 19 | <li><span class="nobr"><a href="http://www.apache.org/" title="Visit page outside Confluence" rel="nofollow">asf<sup><img class="rendericon" src="apache-felix-maven-bundle-plugin-bnd_files/linkext7.gif" alt="" width="7" align="absmiddle" border="0" height="7"></sup></a></span></li> |
| 20 | <li><span class="nobr"><a href="http://www.apache.org/foundation/sponsorship.html" title="Visit page outside Confluence" rel="nofollow">sponsorship<sup><img class="rendericon" src="apache-felix-maven-bundle-plugin-bnd_files/linkext7.gif" alt="" width="7" align="absmiddle" border="0" height="7"></sup></a></span></li> |
| 21 | <li><span class="nobr"><a href="http://www.apache.org/foundation/thanks.html" title="Visit page outside Confluence" rel="nofollow">sponsors<sup><img class="rendericon" src="apache-felix-maven-bundle-plugin-bnd_files/linkext7.gif" alt="" width="7" align="absmiddle" border="0" height="7"></sup></a></span> |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 22 | <!-- ApacheCon Ad --> |
Stuart McCulloch | b4212cc | 2008-08-05 06:36:05 +0000 | [diff] [blame] | 23 | <iframe src="apache-felix-maven-bundle-plugin-bnd_files/button.html" style="border-width: 0pt; float: left; display: none;" scrolling="no" width="135" frameborder="0" height="135"></iframe> |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 24 | <p style="height: 100px;"> |
| 25 | <!-- ApacheCon Ad --> |
| 26 | </p></li></ul> </div> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 27 | <div class="main"> |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 28 | <h1><a name="ApacheFelixMavenBundlePlugin(BND)-BundlePluginforMaven"></a>Bundle Plugin for Maven</h1> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 29 | |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 30 | <p>This plugin for Maven 2 is based on the <span class="nobr"><a href="http://www.aqute.biz/Code/Bnd" title="Visit page outside Confluence" rel="nofollow">BND<sup><img class="rendericon" src="apache-felix-maven-bundle-plugin-bnd_files/linkext7.gif" alt="" width="7" align="absmiddle" border="0" height="7"></sup></a></span> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 31 | tool from Peter Kriens. The way BND works is by treating your project |
| 32 | as a big collection of classes (e.g., project code, dependencies, and |
| 33 | the class path). The way you create a bundle with BND is to tell it the |
| 34 | content of the bundle's JAR file as a subset of the available classes. |
| 35 | This plugin wraps BND to make it work specifically with the Maven 2 |
| 36 | project structure and to provide it with reasonable default behavior |
| 37 | for Maven 2 projects.</p> |
| 38 | |
Stuart McCulloch | 738a06d | 2009-02-27 06:38:33 +0000 | [diff] [blame] | 39 | <p><em>NOTE: test scoped dependencies are <b>not</b> included in the classpath seen by BND.</em></p> |
Stuart McCulloch | b4212cc | 2008-08-05 06:36:05 +0000 | [diff] [blame] | 40 | |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 41 | <p>Since the 1.4.0 release, this plugin also aims to automate OBR (OSGi |
| 42 | Bundle Repository) management. It helps manage a local OBR for your |
| 43 | local Maven repository, and also supports remote OBRs for bundle |
| 44 | distribution. The plug-in automatically computes bundle capabilities |
| 45 | and requirements, using a combination of Bindex and Maven metadata.</p> |
| 46 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 47 | <p><a name="ApacheFelixMavenBundlePlugin(BND)-simpleexample"></a></p> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 48 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 49 | <h1><a name="ApacheFelixMavenBundlePlugin(BND)-SimpleExample"></a>Simple Example</h1> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 50 | |
| 51 | <p>Rather than going straight to a detailed list of plugin features, we |
| 52 | will first look at a simple example of how to use the plugin to give an |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 53 | immediate flavor. A detailed "<a href="#ApacheFelixMavenBundlePlugin%2528BND%2529-howto" title="how-to on Apache Felix Maven Bundle Plugin (BND)">how to</a>" will follow.</p> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 54 | |
| 55 | <p>Assume that we have a simple bundle project that has a pubic API package an several implementation packages, such as:</p> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 56 | |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 57 | <div class="preformatted"><div class="preformattedContent"> |
| 58 | <pre>org.foo.myproject.api |
| 59 | org.foo.myproject.impl1 |
| 60 | org.foo.myproject.impl2 |
| 61 | ... |
| 62 | </pre> |
| 63 | </div></div> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 64 | |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 65 | <p>If we also assume that we have a bundle activator in one of the implementation packages, then the <tt><plugins></tt> section of the POM file for this bundle project would look like this:</p> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 66 | |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 67 | <div class="preformatted"><div class="preformattedContent"> |
| 68 | <pre>... |
| 69 | <plugins> |
| 70 | <plugin> |
| 71 | <groupId>org.apache.felix</groupId> |
| 72 | <artifactId>maven-bundle-plugin</artifactId> |
| 73 | <extensions>true</extensions> |
| 74 | <configuration> |
| 75 | <instructions> |
| 76 | <Export-Package>org.foo.myproject.api</Export-Package> |
| 77 | <Private-Package>org.foo.myproject.*</Private-Package> |
| 78 | <Bundle-Activator>org.foo.myproject.impl1.Activator</Bundle-Activator> |
| 79 | </instructions> |
| 80 | </configuration> |
| 81 | </plugin> |
| 82 | </plugins> |
| 83 | ... |
| 84 | </pre> |
| 85 | </div></div> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 86 | |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 87 | <p>The <tt><Export-Package></tt> and <tt><Private-Package></tt> instructions tell the plugin about the contents of the resulting bundle JAR file. The <tt><Export-Package></tt> instruction tells the plugin which of the available packages to copy into the bundle <b>and</b> export, while the <tt><Private-Package></tt> instruction indicates which of the available packages to copy into the bundle <b>but not</b> |
| 88 | export. If the two sets overlap, as they do in the case, then the |
| 89 | export takes precedence. Since we did not specify any values for any |
| 90 | other bundle manifest headers, they will assume default values which |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 91 | are described <a href="#ApacheFelixMavenBundlePlugin%2528BND%2529-defaultbehavior" title="default-behavior on Apache Felix Maven Bundle Plugin (BND)">below</a>. One specific behavior to highlight is that the plugin generates the <tt>Import-Package</tt> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 92 | bundle manifest header based on the contents of the bundle, which means |
| 93 | that you generally do not ever need to explicitly specify it yourself. |
| 94 | That's it.</p> |
| 95 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 96 | <h1><a name="ApacheFelixMavenBundlePlugin(BND)-Features"></a>Features</h1> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 97 | |
| 98 | <p>The BND library underlying the plugin defines instructions to direct |
| 99 | its behavior. For this Maven plugin, these instructions are issued in |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 100 | the plugin configuration section of the POM file, as was illustrated <a href="#ApacheFelixMavenBundlePlugin%2528BND%2529-simpleexample" title="simple-example on Apache Felix Maven Bundle Plugin (BND)">above</a>. BND recognizes three types of instructions:</p> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 101 | |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 102 | <ol> |
| 103 | <li><em>Manifest headers</em> - Any instruction that starts with |
| 104 | a capital letter will appear in the resulting bundle's manifest file; |
| 105 | the value for the header will either be copied, augmented, or generated |
| 106 | by BND depending on the instruction.</li> |
| 107 | <li><em>Variables</em> - Any instruction starting with a lowercase letter is assumed to be a variable in the form of a name-value pair, such as <tt>version=3.0</tt>, that can be used for property substitution, but is not copied to the manifest.</li> |
| 108 | <li><em>Directives</em> |
| 109 | - Any instruction starting with a '-' character is considered to be a |
| 110 | directive that informs BND to perform some special processing and is |
| 111 | not copied to the manifest.</li> |
| 112 | </ol> |
| 113 | |
| 114 | |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 115 | <p>The remainder of this section covers the most important aspects of BND's instructions; for complete details refer to the <span class="nobr"><a href="http://www.aqute.biz/Code/Bnd" title="Visit page outside Confluence" rel="nofollow">BND documentation<sup><img class="rendericon" src="apache-felix-maven-bundle-plugin-bnd_files/linkext7.gif" alt="" width="7" align="absmiddle" border="0" height="7"></sup></a></span>.</p> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 116 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 117 | <p><a name="ApacheFelixMavenBundlePlugin(BND)-instructions"></a></p> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 118 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 119 | <h2><a name="ApacheFelixMavenBundlePlugin(BND)-Instructions"></a>Instructions</h2> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 120 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 121 | <h3><a name="ApacheFelixMavenBundlePlugin(BND)-{{<ExportPackage>}}"></a><tt><Export-Package></tt></h3> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 122 | |
| 123 | <p>The <tt><Export-Package></tt> instruction is a list of |
| 124 | packages for the bundle to export. These packages are copied into the |
| 125 | resulting bundle JAR file from the available classes (i.e., project |
| 126 | classes, dependencies, and class path); thus, it is possible to include |
| 127 | classes into your bundle that are not associated with source files in |
| 128 | your project. <tt><Export-Package></tt> can be specified with |
| 129 | package patterns using the '*' wildcard. Also, it is possible to |
| 130 | exclude packages using negation by starting the package pattern with |
| 131 | '!'. Thus, non-negated patterns indicate which of the available |
| 132 | packages to include in the bundle, whereas negated patterns indicate |
| 133 | which should not be included in the bundle.</p> |
| 134 | |
| 135 | <p>The list of package patterns is ordered and earlier patterns are applied before later patterns. For example, if you specify "<tt>org.foo.*,!org.foo.impl</tt>" the second pattern has no effect since all <tt>org.foo</tt> packages have already been selected by the first pattern. Instead, you should specify "<tt>!org.foo.impl,org.foo.*</tt>", which will export all <tt>org.foo</tt> packages except <tt>org.foo.impl</tt>.</p> |
| 136 | |
| 137 | <p>Following standard OSGi R4 syntax, package patterns can include both |
| 138 | directives and attributes, which will be copied appropriately into the |
| 139 | generated Export-Package manifest header. Besides explicitly listing |
| 140 | package version attributes, BND will also determine package versions by |
| 141 | examining the source JAR file or from <tt>packageinfo</tt> files in the package directory.</p> |
| 142 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 143 | <h3><a name="ApacheFelixMavenBundlePlugin(BND)-{{<PrivatePackage>}}"></a><tt><Private-Package></tt></h3> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 144 | |
| 145 | <p>The <tt><Private-Package></tt> instruction is similar in every way to the <tt><Export-Package></tt> instruction, except for the fact that these packages will <b>not</b> |
| 146 | be exported by the bundle. If a package is selected by both the export |
| 147 | and private package headers, then the export takes precedence.</p> |
| 148 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 149 | <h3><a name="ApacheFelixMavenBundlePlugin(BND)-{{<IncludeResource>}}"></a><tt><Include-Resource></tt></h3> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 150 | |
| 151 | <p>The <tt><Include-Resource></tt> instruction is a list of |
| 152 | arbitrary resources that should be copied into the bundle JAR file. The |
| 153 | specified resources are declared as clauses that can have the following |
| 154 | forms:</p> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 155 | |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 156 | <div class="preformatted"><div class="preformattedContent"> |
| 157 | <pre>clause ::= assignment | inline | simple |
| 158 | assignment ::= PATH '=' PATH |
| 159 | simple ::= PATH |
| 160 | inline ::= '@' PATH |
| 161 | </pre> |
| 162 | </div></div> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 163 | |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 164 | <p>For the <tt><Include-Resource></tt> instruction, actual file paths are relative to the <tt>pom.xml</tt>, while file copy destinations are relative to the root of the resulting bundle JAR file. In the case of <tt>assignment</tt> or <tt>simple</tt> forms, the <tt>PATH</tt> parameter can point to a file or directory. The <tt>simple</tt> |
| 165 | form will place the resource in the bundle JAR with only the file name, |
| 166 | i.e., without any path component. For example, including <tt>src/main/resources/a/b.c</tt> will result in a resource <tt>b.c</tt> in the root of the bundle JAR. If the <tt>PATH</tt> |
| 167 | points to a directory, the entire directory hierarchy is copied into |
| 168 | the resulting bundle JAR file relative to the specified directory. If a |
| 169 | specific resource must be placed into a subdirectory of the bundle jar, |
| 170 | then use the <tt>assignment</tt> form, where the first path is the the |
| 171 | destination path (including file name if the resource is a file) and |
| 172 | the second path is the resource to copy. The <tt>inline</tt> form requires a ZIP or JAR file, which will be completely expanded in the bundle JAR.</p> |
| 173 | |
| 174 | <p>If a resource clause is specified inside of "{ ... }" brackets, then |
| 175 | variable substitution will be performed on the resource, where |
| 176 | variables in the resources are denoted with "${ ... }" syntax.</p> |
| 177 | |
Stuart McCulloch | 7c961f5 | 2008-01-02 08:56:07 +0000 | [diff] [blame] | 178 | <p>By default the bundle plugin converts the project's Maven resource directories into a single <tt><Include-Resource></tt> instruction. If you specify your own <tt><Include-Resource></tt> instruction, this will replace the generated one. To include the generated list of Maven resources in your own <tt><Include-Resource></tt> instruction just add {<tt>maven-resources</tt>} to the list and it will be expanded automatically.</p> |
| 179 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 180 | <h3><a name="ApacheFelixMavenBundlePlugin(BND)-{{<ImportPackage>}}"></a><tt><Import-Package></tt></h3> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 181 | |
| 182 | <p>The <tt><Import-Package></tt> instruction is a list of |
| 183 | packages that are required by the bundle's contained packages. The |
| 184 | default for this header is "*", resulting in importing all referred |
| 185 | packages. This header rarely has to be explicitly specified. However, |
| 186 | in certain cases when there is an unwanted import, such an import can |
| 187 | be removed by using a negation package pattern. The package patterns |
| 188 | work in the same way as for <tt><Export-Package></tt>, which means they are ordered. For example, if you wanted to import all packages except <tt>org.foo.impl</tt> you would specify "<tt>!org.foo.impl,*</tt>"</p> |
| 189 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 190 | <p><a name="ApacheFelixMavenBundlePlugin(BND)-defaultbehavior"></a></p> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 191 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 192 | <h2><a name="ApacheFelixMavenBundlePlugin(BND)-DefaultBehavior"></a>Default Behavior</h2> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 193 | |
| 194 | <p>To use this plugin, very little information is required by BND. As |
| 195 | part of the Maven integration, the plugin tries to set reasonable |
| 196 | defaults for various instructions. For example:</p> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 197 | |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 198 | <ul> |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 199 | <li><tt><Bundle-SymbolicName></tt> is computed using the shared <span class="nobr"><a href="http://svn.apache.org/repos/asf/maven/shared/trunk/maven-osgi/src/main/java/org/apache/maven/shared/osgi/DefaultMaven2OsgiConverter.java" title="Visit page outside Confluence" rel="nofollow">Maven2OsgiConverter<sup><img class="rendericon" src="apache-felix-maven-bundle-plugin-bnd_files/linkext7.gif" alt="" width="7" align="absmiddle" border="0" height="7"></sup></a></span> component, which uses the following algorithm:<br> |
Stuart McCulloch | b4212cc | 2008-08-05 06:36:05 +0000 | [diff] [blame] | 200 | Get the symbolic name as groupId + "." + artifactId, with the following exceptions: |
| 201 | <ul> |
| 202 | <li>if |
| 203 | artifact.getFile is not null and the jar contains a OSGi Manifest with |
| 204 | Bundle-SymbolicName property then that value is returned</li> |
| 205 | <li>if |
| 206 | groupId has only one section (no dots) and artifact.getFile is not null |
| 207 | then the first package name with classes is returned. eg. |
| 208 | commons-logging:commons-logging -> org.apache.commons.logging</li> |
| 209 | <li>if artifactId is equal to last section of groupId then groupId is returned. eg. org.apache.maven:maven -> org.apache.maven</li> |
| 210 | <li>if |
| 211 | artifactId starts with last section of groupId that portion is removed. |
Stuart McCulloch | 738a06d | 2009-02-27 06:38:33 +0000 | [diff] [blame] | 212 | eg. org.apache.maven:maven-core -> org.apache.maven.core<br> |
| 213 | The computed symbolic name is also stored in the <tt>$(maven-symbolicname)</tt> property in case you want to add attributes or directives to it.</li> |
Stuart McCulloch | b4212cc | 2008-08-05 06:36:05 +0000 | [diff] [blame] | 214 | </ul> |
| 215 | </li> |
Stuart McCulloch | 738a06d | 2009-02-27 06:38:33 +0000 | [diff] [blame] | 216 | <li><tt><Export-Package></tt> |
| 217 | is now assumed to be the set of packages in your local Java sources, |
| 218 | excluding the default package '.' and any packages containing 'impl' or |
| 219 | 'internal'.<br> |
| 220 | <em>(before version 2 of the bundleplugin it was based on the symbolic name)</em></li> |
| 221 | <li><tt><Private-Package></tt> is now assumed to be the set of packages in your local Java sources (note that any packages in both <tt><Export-Package></tt> and <tt><Private-Package></tt> will be exported).<br> |
| 222 | <em>(before version 2 of the bundleplugin it was assumed to be empty by default)</em></li> |
| 223 | <li><tt><Import-Package></tt> is assumed to be "<tt>*</tt>", which imports everything referred to by the bundle content, but not contained in the bundle.<br> |
| 224 | <em>Any exported packages are also imported by default, to ensure a consistent class space.</em></li> |
Stuart McCulloch | 7c961f5 | 2008-01-02 08:56:07 +0000 | [diff] [blame] | 225 | <li><tt><Include-Resource></tt> is generated from the project's Maven resources, typically "<tt>src/main/resources/</tt>", |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 226 | which will copy the specified project directory hierarchy into the |
| 227 | resulting bundle JAR file, mirroring standard Maven behavior.</li> |
| 228 | <li><tt><Bundle-Version></tt> is assumed to be "<tt>${pom.version</tt>}" with '-' character separator of the qualifier replaced with a '.' character.</li> |
| 229 | <li><tt><Bundle-Name></tt> is assumed to be "<tt>${pom.name</tt>}".</li> |
| 230 | <li><tt><Bundle-Description></tt> is assumed to be "<tt>${pom.description</tt>}".</li> |
| 231 | <li><tt><Bundle-License></tt> is assumed to be "<tt>${pom.licenses</tt>}".</li> |
| 232 | <li><tt><Bundle-Vendor></tt> is assumed to be "<tt>${pom.organization.name</tt>}".</li> |
| 233 | <li><tt><Bundle-DocURL></tt> is assumed to be "<tt>${pom.organization.url</tt>}".</li> |
| 234 | </ul> |
| 235 | |
| 236 | |
Stuart McCulloch | 7c961f5 | 2008-01-02 08:56:07 +0000 | [diff] [blame] | 237 | <p>Since the plugin creates bundles for OSGi R4, it hard-codes <tt>Bundle-ManifestVersion</tt> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 238 | to be '2'. Additionally, it generates imports for every export to |
| 239 | ensure package substitutability, which is very important when working |
| 240 | with collaborating services. It is possible to override any of these |
| 241 | values (except <tt>Bundle-ManifestVersion</tt>) just by specifying the desired value in the plugin configuration section of the POM file.</p> |
| 242 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 243 | <p><a name="ApacheFelixMavenBundlePlugin(BND)-howto"></a></p> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 244 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 245 | <h1><a name="ApacheFelixMavenBundlePlugin(BND)-Detailed"HowTo""></a>Detailed "How To"</h1> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 246 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 247 | <h2><a name="ApacheFelixMavenBundlePlugin(BND)-GetMaven2"></a>Get Maven2</h2> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 248 | |
| 249 | <p>The first step in the process of using the plugin is downloading and |
| 250 | installing the latest version of the Maven2 runtime. The latest Maven2 |
| 251 | release and instuctions for getting started with Maven2 can be found at |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 252 | the <span class="nobr"><a href="http://maven.apache.org/index.html" title="Visit page outside Confluence" rel="nofollow">Maven website<sup><img class="rendericon" src="apache-felix-maven-bundle-plugin-bnd_files/linkext7.gif" alt="" width="7" align="absmiddle" border="0" height="7"></sup></a></span>.</p> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 253 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 254 | <h2><a name="ApacheFelixMavenBundlePlugin(BND)-UsingthePlugin"></a>Using the Plugin</h2> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 255 | |
| 256 | <p>To use the maven-bundle-plugin, you first need to add the plugin and |
| 257 | some appropriate plugin configuration to your bundle project's POM. |
| 258 | Below is an example of a simple OSGi bundle POM for Maven2:</p> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 259 | |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 260 | <div class="preformatted"><div class="preformattedContent"> |
| 261 | <pre><project> |
| 262 | <modelVersion>4.0.0</modelVersion> |
| 263 | <groupId>my-osgi-bundles</groupId> |
| 264 | <artifactId>examplebundle</artifactId> |
| 265 | <packaging>bundle</packaging> <!-- (1) --> |
| 266 | <version>1.0</version> |
| 267 | <name>Example Bundle</name> |
| 268 | <dependencies> |
| 269 | <dependency> |
| 270 | <groupId>org.apache.felix</groupId> |
| 271 | <artifactId>org.osgi.core</artifactId> |
Stuart McCulloch | 7c961f5 | 2008-01-02 08:56:07 +0000 | [diff] [blame] | 272 | <version>1.0.0</version> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 273 | </dependency> |
| 274 | </dependencies> |
| 275 | <build> |
| 276 | <plugins> |
| 277 | <plugin> <!-- (2) START --> |
| 278 | <groupId>org.apache.felix</groupId> |
| 279 | <artifactId>maven-bundle-plugin</artifactId> |
| 280 | <extensions>true</extensions> |
| 281 | <configuration> |
| 282 | <instructions> |
| 283 | <Export-Package>com.my.company.api</Export-Package> |
| 284 | <Private-Package>com.my.company.*</Private-Package> |
| 285 | <Bundle-Activator>com.my.company.Activator</Bundle-Activator> |
| 286 | </instructions> |
| 287 | </configuration> |
| 288 | </plugin> <!-- (2) END --> |
| 289 | </plugins> |
| 290 | </build> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 291 | </project> |
| 292 | </pre> |
| 293 | </div></div> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 294 | |
| 295 | <p>There are two main things to note: (1) the <tt><packaging></tt> |
| 296 | specifier must be "bundle" and (2) the plugin and configuration must be |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 297 | specified (the configuration section is where you will issue |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 298 | instructions to the plugin).</p> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 299 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 300 | <h2><a name="ApacheFelixMavenBundlePlugin(BND)-RealWorldExample"></a>Real-World Example</h2> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 301 | |
| 302 | <p>Consider this more real-world example using Felix' Log Service |
| 303 | implementation. The Log Service project is comprised of a single |
| 304 | package: <tt>org.apache.felix.log.impl</tt>. It has a dependency on |
| 305 | the core OSGi interfaces as well as a dependency on the compendium OSGi |
| 306 | interfaces for the specific log service interfaces. The following is |
| 307 | its POM file:</p> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 308 | |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 309 | <div class="preformatted"><div class="preformattedContent"> |
| 310 | <pre><project> |
| 311 | <modelVersion>4.0.0</modelVersion> |
| 312 | <groupId>org.apache.felix</groupId> |
| 313 | <artifactId>org.apache.felix.log</artifactId> |
| 314 | <packaging>bundle</packaging> |
| 315 | <name>Apache Felix Log Service</name> |
| 316 | <version>0.8.0-SNAPSHOT</version> |
| 317 | <description> |
| 318 | This bundle provides an implementation of the OSGi R4 Log service. |
| 319 | </description> |
| 320 | <dependencies> |
| 321 | <dependency> |
| 322 | <groupId>${pom.groupId}</groupId> |
| 323 | <artifactId>org.osgi.core</artifactId> |
| 324 | <version>0.8.0-incubator</version> |
| 325 | </dependency> |
| 326 | <dependency> |
| 327 | <groupId>${pom.groupId}</groupId> |
| 328 | <artifactId>org.osgi.compendium</artifactId> |
| 329 | <version>0.9.0-incubator-SNAPSHOT</version> |
| 330 | </dependency> |
| 331 | </dependencies> |
| 332 | <build> |
| 333 | <plugins> |
| 334 | <plugin> |
| 335 | <groupId>org.apache.felix</groupId> |
| 336 | <artifactId>maven-bundle-plugin</artifactId> |
| 337 | <extensions>true</extensions> |
| 338 | <configuration> |
| 339 | <instructions> |
| 340 | <Export-Package>org.osgi.service.log</Export-Package> |
| 341 | <Private-Package>org.apache.felix.log.impl</Private-Package> |
| 342 | <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName> |
| 343 | <Bundle-Activator>${pom.artifactId}.impl.Activator</Bundle-Activator> |
| 344 | <Export-Service>org.osgi.service.log.LogService,org.osgi.service.log.LogReaderService</Export-Service> |
| 345 | </instructions> |
| 346 | </configuration> |
| 347 | </plugin> |
| 348 | </plugins> |
| 349 | </build> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 350 | </project> |
| 351 | </pre> |
| 352 | </div></div> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 353 | |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 354 | <p>Notice that the <tt><Export-Package></tt> instruction |
| 355 | specifies that the bundle exports the Log Service package, even though |
| 356 | this package is not contained in the bundle project. By declaring this, |
| 357 | the plugin will copy the Log Service package into the resulting bundle |
| 358 | JAR file. This is useful in this case because now the bundle can |
| 359 | resolve without having to download the entire compendium bundle. The |
| 360 | resulting manifest for the Log Service bundle looks like this (notice |
| 361 | how the imports/exports automatically have version information |
| 362 | associated with them, which was obtained from packageinfo files in the |
| 363 | source packages):</p> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 364 | |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 365 | <div class="preformatted"><div class="preformattedContent"> |
| 366 | <pre>Manifest-Version: 1 |
| 367 | Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt |
| 368 | Bundle-Activator: org.apache.felix.log.impl.Activator |
| 369 | Import-Package: org.osgi.framework;version=1.3, org.osgi.service.log;v |
| 370 | ersion=1.3 |
| 371 | Include-Resource: src/main/resources |
| 372 | Export-Package: org.osgi.service.log;uses:=org.osgi.framework;version= |
| 373 | 1.3 |
| 374 | Bundle-Version: 0.8.0.SNAPSHOT |
| 375 | Bundle-Name: Apache Felix Log Service |
| 376 | Bundle-Description: This bundle provides an implementation of the OSGi |
| 377 | R4 Log service. |
| 378 | Private-Package: org.apache.felix.log.impl |
| 379 | Bundle-ManifestVersion: 2 |
| 380 | Export-Service: org.osgi.service.log.LogService,org.osgi.service.log.L |
| 381 | ogReaderService |
| 382 | Bundle-SymbolicName: org.apache.felix.log |
| 383 | </pre> |
| 384 | </div></div> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 385 | |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 386 | <p>The resulting bundle JAR file has the following content (notice how |
| 387 | the LICENSE and NOTICE files were automatically copied from the <tt>src/main/resources/</tt> directory of the project):</p> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 388 | |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 389 | <div class="preformatted"><div class="preformattedContent"> |
| 390 | <pre>META-INF/MANIFEST.MF |
| 391 | LICENSE |
| 392 | META-INF/ |
| 393 | META-INF/maven/ |
| 394 | META-INF/maven/org.apache.felix/ |
| 395 | META-INF/maven/org.apache.felix/org.apache.felix.log/ |
| 396 | META-INF/maven/org.apache.felix/org.apache.felix.log/pom.properties |
| 397 | META-INF/maven/org.apache.felix/org.apache.felix.log/pom.xml |
| 398 | NOTICE |
| 399 | org/ |
| 400 | org/apache/ |
| 401 | org/apache/felix/ |
| 402 | org/apache/felix/log/ |
| 403 | org/apache/felix/log/impl/ |
| 404 | org/apache/felix/log/impl/Activator.class |
| 405 | org/apache/felix/log/impl/Log.class |
| 406 | org/apache/felix/log/impl/LogEntryImpl.class |
| 407 | org/apache/felix/log/impl/LogException.class |
| 408 | org/apache/felix/log/impl/LogListenerThread.class |
| 409 | org/apache/felix/log/impl/LogNode.class |
| 410 | org/apache/felix/log/impl/LogNodeEnumeration.class |
| 411 | org/apache/felix/log/impl/LogReaderServiceFactory.class |
| 412 | org/apache/felix/log/impl/LogReaderServiceImpl.class |
| 413 | org/apache/felix/log/impl/LogServiceFactory.class |
| 414 | org/apache/felix/log/impl/LogServiceImpl.class |
| 415 | org/osgi/ |
| 416 | org/osgi/service/ |
| 417 | org/osgi/service/log/ |
| 418 | org/osgi/service/log/LogEntry.class |
| 419 | org/osgi/service/log/LogListener.class |
| 420 | org/osgi/service/log/LogReaderService.class |
| 421 | org/osgi/service/log/LogService.class |
| 422 | org/osgi/service/log/package.html |
| 423 | org/osgi/service/log/packageinfo |
| 424 | </pre> |
| 425 | </div></div> |
| 426 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 427 | <h2><a name="ApacheFelixMavenBundlePlugin(BND)-AddingOSGimetadatatoexistingprojectswithoutchangingthepackagingtype"></a>Adding OSGi metadata to existing projects without changing the packaging type</h2> |
Stuart McCulloch | dd4ae5f | 2008-02-05 12:38:46 +0000 | [diff] [blame] | 428 | |
| 429 | <p>If you want to keep your project packaging type (for example "jar") but would like to add OSGi metadata<br> |
| 430 | you can use the manifest goal to generate a bundle manifest. The maven-jar-plugin can then be used to<br> |
| 431 | add this manifest to the final artifact. For example:</p> |
| 432 | |
| 433 | <div class="code"><div class="codeContent"> |
| 434 | <pre class="code-xml"><span class="code-tag"><plugin></span> |
| 435 | <span class="code-tag"><artifactId></span>maven-jar-plugin<span class="code-tag"></artifactId></span> |
| 436 | <span class="code-tag"><configuration></span> |
| 437 | <span class="code-tag"><archive></span> |
| 438 | <span class="code-tag"><manifestFile></span>${project.build.outputDirectory}/META-INF/MANIFEST.MF<span class="code-tag"></manifestFile></span> |
| 439 | <span class="code-tag"></archive></span> |
| 440 | <span class="code-tag"></configuration></span> |
| 441 | <span class="code-tag"></plugin></span> |
| 442 | <span class="code-tag"><plugin></span> |
| 443 | <span class="code-tag"><groupId></span>org.apache.felix<span class="code-tag"></groupId></span> |
| 444 | <span class="code-tag"><artifactId></span>maven-bundle-plugin<span class="code-tag"></artifactId></span> |
| 445 | <span class="code-tag"><executions></span> |
| 446 | <span class="code-tag"><execution></span> |
| 447 | <span class="code-tag"><id></span>bundle-manifest<span class="code-tag"></id></span> |
| 448 | <span class="code-tag"><phase></span>process-classes<span class="code-tag"></phase></span> |
| 449 | <span class="code-tag"><goals></span> |
| 450 | <span class="code-tag"><goal></span>manifest<span class="code-tag"></goal></span> |
| 451 | <span class="code-tag"></goals></span> |
| 452 | <span class="code-tag"></execution></span> |
| 453 | <span class="code-tag"></executions></span> |
| 454 | <span class="code-tag"></plugin></span></pre> |
| 455 | </div></div> |
| 456 | |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 457 | <p>If you want to use packaging types other than "jar" and "bundle" then you also need to enable support<br> |
| 458 | for them in the bundleplugin configuration, for example if you want to use the plugin with WAR files:</p> |
| 459 | |
| 460 | <div class="code"><div class="codeContent"> |
| 461 | <pre class="code-xml"><span class="code-tag"><plugin></span> |
| 462 | <span class="code-tag"><groupId></span>org.apache.felix<span class="code-tag"></groupId></span> |
| 463 | <span class="code-tag"><artifactId></span>maven-bundle-plugin<span class="code-tag"></artifactId></span> |
| 464 | <span class="code-tag"><executions></span> |
| 465 | <span class="code-tag"><execution></span> |
| 466 | <span class="code-tag"><id></span>bundle-manifest<span class="code-tag"></id></span> |
| 467 | <span class="code-tag"><phase></span>process-classes<span class="code-tag"></phase></span> |
| 468 | <span class="code-tag"><goals></span> |
| 469 | <span class="code-tag"><goal></span>manifest<span class="code-tag"></goal></span> |
| 470 | <span class="code-tag"></goals></span> |
| 471 | <span class="code-tag"></execution></span> |
| 472 | <span class="code-tag"></executions></span> |
| 473 | <span class="code-tag"><configuration></span> |
| 474 | <span class="code-tag"><supportedProjectTypes></span> |
| 475 | <span class="code-tag"><supportedProjectType></span>jar<span class="code-tag"></supportedProjectType></span> |
| 476 | <span class="code-tag"><supportedProjectType></span>bundle<span class="code-tag"></supportedProjectType></span> |
| 477 | <span class="code-tag"><supportedProjectType></span>war<span class="code-tag"></supportedProjectType></span> |
| 478 | <span class="code-tag"></supportedProjectTypes></span> |
| 479 | <span class="code-tag"><instructions></span> |
| 480 | <span class="code-tag"><span class="code-comment"><!-- ...etc... --></span></span> |
| 481 | <span class="code-tag"></instructions></span> |
| 482 | <span class="code-tag"></configuration></span> |
| 483 | <span class="code-tag"></plugin></span></pre> |
| 484 | </div></div> |
| 485 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 486 | <h2><a name="ApacheFelixMavenBundlePlugin(BND)-BuildingthePlugin"></a>Building the Plugin</h2> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 487 | |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 488 | <p>The plugin is hosted at the Apache Felix project. The following |
| 489 | steps describe how to build and install the plugin into your local |
| 490 | Maven2 repository.</p> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 491 | |
| 492 | <p>Using the SVN client of your choice, checkout the maven-bundle-plugin project.</p> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 493 | |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 494 | <div class="preformatted"><div class="preformattedContent"> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 495 | <pre>$ svn co http://svn.apache.org/repos/asf/felix/trunk/bundleplugin |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 496 | </pre> |
| 497 | </div></div> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 498 | |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 499 | <p>Using Maven2, build and install the maven-bundle-plugin by issuing |
| 500 | the following Maven2 command in the project directory that was created |
| 501 | as a result of the previous step.</p> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 502 | |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 503 | <div class="preformatted"><div class="preformattedContent"> |
| 504 | <pre>$ mvn install |
| 505 | </pre> |
| 506 | </div></div> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 507 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 508 | <h1><a name="ApacheFelixMavenBundlePlugin(BND)-Goals"></a>Goals</h1> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 509 | |
| 510 | <p>The maven-bundle-plugin also provides additional functionality via |
| 511 | some Maven goals. Command-line execution of a goal is performed as |
| 512 | follows:</p> |
| 513 | |
| 514 | <div class="preformatted"><div class="preformattedContent"> |
| 515 | <pre>mvn org.apache.felix:maven-bundle-plugin:GOAL |
| 516 | </pre> |
| 517 | </div></div> |
| 518 | |
| 519 | <p>Where GOAL is one of the following:</p> |
| 520 | |
| 521 | <ul> |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 522 | <li><b><tt>bundle</tt></b> - build an OSGi bundle jar for the current project<br> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 523 | configuration options: |
| 524 | <ul> |
Stuart McCulloch | dd4ae5f | 2008-02-05 12:38:46 +0000 | [diff] [blame] | 525 | <li><em><tt>manifestLocation</tt></em> defaults to ${project.build.outputDirectory}/META-INF</li> |
| 526 | <li><em><tt>unpackBundle</tt></em> unpack bundle contents to output directory, defaults to false</li> |
Stuart McCulloch | 738a06d | 2009-02-27 06:38:33 +0000 | [diff] [blame] | 527 | <li><em><tt>excludeDependencies</tt></em> comma-separated list of dependency artifactIds to exclude from the classpath passed to Bnd, use "true" to exclude everything.<br> |
| 528 | Version 2 of the bundleplugin now supports the same style of filter clauses in <tt>excludeDependencies</tt> as <tt>Embed-Dependency</tt>.</li> |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 529 | <li><em><tt>classifier</tt></em> attach bundle to the project using the given classifier</li> |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 530 | <li><em><tt>supportedProjectTypes</tt></em> defaults to "jar","bundle"</li> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 531 | </ul> |
| 532 | </li> |
Stuart McCulloch | dd4ae5f | 2008-02-05 12:38:46 +0000 | [diff] [blame] | 533 | </ul> |
| 534 | |
| 535 | |
| 536 | <ul> |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 537 | <li><b><tt>bundleall</tt></b> - build OSGi bundle jars for all transitive dependencies<br> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 538 | configuration options: |
| 539 | <ul> |
Stuart McCulloch | 981bd34 | 2008-05-03 12:49:39 +0000 | [diff] [blame] | 540 | <li><em><tt>wrapImportPackage</tt></em> defaults to "*"</li> |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 541 | <li><em><tt>supportedProjectTypes</tt></em> defaults to "jar","bundle"</li> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 542 | </ul> |
| 543 | </li> |
Stuart McCulloch | dd4ae5f | 2008-02-05 12:38:46 +0000 | [diff] [blame] | 544 | </ul> |
| 545 | |
| 546 | |
| 547 | <ul> |
| 548 | <li><b><tt>wrap</tt></b> - as above, but limited to the first level of dependencies<br> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 549 | configuration options: |
| 550 | <ul> |
Stuart McCulloch | 981bd34 | 2008-05-03 12:49:39 +0000 | [diff] [blame] | 551 | <li><em><tt>wrapImportPackage</tt></em> defaults to "*"</li> |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 552 | <li><em><tt>supportedProjectTypes</tt></em> defaults to "jar","bundle"</li> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 553 | </ul> |
| 554 | </li> |
Stuart McCulloch | dd4ae5f | 2008-02-05 12:38:46 +0000 | [diff] [blame] | 555 | </ul> |
| 556 | |
| 557 | |
| 558 | <ul> |
| 559 | <li><b><tt>manifest</tt></b> - create an OSGi manifest for the current project<br> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 560 | configuration options: |
| 561 | <ul> |
Stuart McCulloch | dd4ae5f | 2008-02-05 12:38:46 +0000 | [diff] [blame] | 562 | <li><em><tt>manifestLocation</tt></em> defaults to ${project.build.outputDirectory}/META-INF</li> |
| 563 | <li><em><tt>supportedProjectTypes</tt></em> defaults to "jar","bundle"</li> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 564 | </ul> |
| 565 | </li> |
| 566 | </ul> |
| 567 | |
| 568 | |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 569 | <ul> |
| 570 | <li><b><tt>install</tt></b> - adds the current bundle project to the local OBR<br> |
| 571 | configuration options: |
| 572 | <ul> |
| 573 | <li><em><tt>obrRepository</tt></em> path to local OBR, defaults to <em><local-maven-repository></em><tt>/repository.xml</tt></li> |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 574 | <li><em><tt>supportedProjectTypes</tt></em> defaults to "jar","bundle"</li> |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 575 | </ul> |
| 576 | </li> |
| 577 | </ul> |
| 578 | |
| 579 | |
| 580 | <p>More GOALs are available in the <b>1.4.0</b> release:</p> |
| 581 | |
| 582 | <ul> |
| 583 | <li><b><tt>ant</tt></b> - create an Ant build script to rebuild the bundle</li> |
| 584 | </ul> |
| 585 | |
| 586 | |
| 587 | <ul> |
| 588 | <li><b><tt>install-file</tt></b> - adds a local bundle file to the local OBR<br> |
| 589 | configuration options: |
| 590 | <ul> |
| 591 | <li><em><tt>obrRepository</tt></em> path to local OBR, defaults to <em><local-maven-repository></em><tt>/repository.xml</tt></li> |
| 592 | <li><em><tt>groupId</tt></em> Maven groupId for the bundle, taken from <em>pomFile</em> if given</li> |
| 593 | <li><em><tt>artifactId</tt></em> Maven artifactId for the bundle, taken from <em>pomFile</em> if given</li> |
| 594 | <li><em><tt>version</tt></em> Maven version for the bundle, taken from <em>pomFile</em> if given</li> |
| 595 | <li><em><tt>packaging</tt></em> Maven packaging type for the bundle, taken from <em>pomFile</em> if given</li> |
| 596 | <li><em><tt>classifier</tt></em> Maven classifier type, defaults to none</li> |
| 597 | <li><em><tt>pomFile</tt></em> optional Pom file describing the bundle</li> |
| 598 | <li><em><tt>file</tt></em> bundle file, defaults to the bundle from the local Maven repository</li> |
| 599 | <li><em><tt>obrXml</tt></em> optional additional properties for the bundle</li> |
| 600 | </ul> |
| 601 | </li> |
| 602 | </ul> |
| 603 | |
| 604 | |
| 605 | <ul> |
| 606 | <li><b><tt>deploy</tt></b> - adds the current bundle project to a remote OBR<br> |
| 607 | configuration options: |
| 608 | <ul> |
| 609 | <li><em><tt>remoteOBR</tt></em> name of remote OBR, defaults to NONE (which means no remote OBR deployment)</li> |
| 610 | <li><em><tt>obrRepository</tt></em> used when the remoteOBR name is blank, defaults to <tt>repository.xml</tt></li> |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 611 | <li><em><tt>prefixUrl</tt></em> optional public URL prefix for the remote repository</li> |
| 612 | <li><em><tt>bundleUrl</tt></em> optional public URL where the bundle has been deployed</li> |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 613 | <li><em><tt>altDeploymentRepository</tt></em> alternative remote repository, <em>id::layout::url</em></li> |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 614 | <li><em><tt>obrDeploymentRepository</tt></em> optional OBR specific deployment repository.</li> |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 615 | <li><em><tt>ignoreLock</tt></em> ignore remote locking when updating the OBR</li> |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 616 | <li><em><tt>supportedProjectTypes</tt></em> defaults to "jar","bundle"</li> |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 617 | </ul> |
| 618 | </li> |
| 619 | </ul> |
| 620 | |
| 621 | |
| 622 | <ul> |
| 623 | <li><b><tt>deploy-file</tt></b> - adds a local bundle file to a remote OBR<br> |
| 624 | configuration options: |
| 625 | <ul> |
| 626 | <li><em><tt>remoteOBR</tt></em> name of remote OBR, defaults to an empty string</li> |
| 627 | <li><em><tt>obrRepository</tt></em> used when the remoteOBR name is blank, defaults to <tt>repository.xml</tt></li> |
| 628 | <li><em><tt>repositoryId</tt></em> optional repository id, used to lookup authentication settings</li> |
| 629 | <li><em><tt>url</tt></em> remote repository transport URL, like |
| 630 | <div class="preformatted"><div class="preformattedContent"> |
| 631 | <pre>scpexe://host/path/to/obr |
| 632 | </pre> |
| 633 | </div></div></li> |
| 634 | <li><em><tt>bundleUrl</tt></em> public URL of deployed bundle, like |
| 635 | <div class="preformatted"><div class="preformattedContent"> |
| 636 | <pre>http://www.foo.org/bundles/foo.jar |
| 637 | </pre> |
| 638 | </div></div></li> |
| 639 | <li><em><tt>groupId</tt></em> Maven groupId for the bundle, taken from <em>pomFile</em> if given</li> |
| 640 | <li><em><tt>artifactId</tt></em> Maven artifactId for the bundle, taken from <em>pomFile</em> if given</li> |
| 641 | <li><em><tt>version</tt></em> Maven version for the bundle, taken from <em>pomFile</em> if given</li> |
| 642 | <li><em><tt>packaging</tt></em> Maven packaging type for the bundle, taken from <em>pomFile</em> if given</li> |
| 643 | <li><em><tt>classifier</tt></em> Maven classifier type, defaults to none</li> |
| 644 | <li><em><tt>pomFile</tt></em> optional Pom file describing the bundle</li> |
| 645 | <li><em><tt>file</tt></em> bundle file, defaults to the bundle from the local Maven repository</li> |
| 646 | <li><em><tt>obrXml</tt></em> optional additional properties for the bundle</li> |
| 647 | <li><em><tt>ignoreLock</tt></em> ignore remote locking when updating the OBR</li> |
| 648 | </ul> |
| 649 | </li> |
| 650 | </ul> |
| 651 | |
| 652 | |
| 653 | <ul> |
| 654 | <li><b><tt>clean</tt></b> - cleans the local OBR, removing missing bundles<br> |
| 655 | configuration options: |
| 656 | <ul> |
| 657 | <li><em><tt>obrRepository</tt></em> path to local OBR, defaults to <em><local-maven-repository></em><tt>/repository.xml</tt></li> |
| 658 | </ul> |
| 659 | </li> |
| 660 | </ul> |
| 661 | |
| 662 | |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 663 | <ul> |
| 664 | <li><b><tt>remote-clean</tt></b> - cleans a remote OBR, removing missing bundles<br> |
| 665 | configuration options: |
| 666 | <ul> |
| 667 | <li><em><tt>remoteOBR</tt></em> name of remote OBR, defaults to NONE (which means no remote cleaning)</li> |
| 668 | <li><em><tt>obrRepository</tt></em> used when the remoteOBR name is blank, defaults to <tt>repository.xml</tt></li> |
| 669 | <li><em><tt>prefixUrl</tt></em> optional public URL prefix for the remote repository</li> |
| 670 | <li><em><tt>altDeploymentRepository</tt></em> alternative remote repository, <em>id::layout::url</em></li> |
| 671 | <li><em><tt>obrDeploymentRepository</tt></em> optional OBR specific deployment repository.</li> |
| 672 | <li><em><tt>ignoreLock</tt></em> ignore remote locking when updating the OBR</li> |
| 673 | </ul> |
| 674 | </li> |
| 675 | </ul> |
| 676 | |
| 677 | |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 678 | <p>There are also new instructions available from the underlying BND |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 679 | 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="apache-felix-maven-bundle-plugin-bnd_files/linkext7.gif" alt="" width="7" align="absmiddle" border="0" height="7"></sup></a></span>.</p> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 680 | |
Stuart McCulloch | dd4ae5f | 2008-02-05 12:38:46 +0000 | [diff] [blame] | 681 | <p>The default goal <b><tt>bundle</tt></b> will be initialized by setting the <packaging> entry to "bundle".</p> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 682 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 683 | <h1><a name="ApacheFelixMavenBundlePlugin(BND)-Thefollowingfeaturesareonlyavailablefromversion1.2.0onwards"></a>The following features are only available from version 1.2.0 onwards</h1> |
Stuart McCulloch | 7c961f5 | 2008-01-02 08:56:07 +0000 | [diff] [blame] | 684 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 685 | <h2><a name="ApacheFelixMavenBundlePlugin(BND)-Embeddingdependencies"></a>Embedding dependencies</h2> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 686 | |
Stuart McCulloch | 7c961f5 | 2008-01-02 08:56:07 +0000 | [diff] [blame] | 687 | <p>The Maven Bundle Plugin supports embedding of selected project dependencies inside the bundle by using the <tt><Embed-Dependency></tt> instruction:</p> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 688 | |
| 689 | <div class="code"><div class="codeContent"> |
| 690 | <pre class="code-xml"><span class="code-tag"><Embed-Dependency></span>dependencies<span class="code-tag"></Embed-Dependency></span></pre> |
| 691 | </div></div> |
| 692 | |
| 693 | <p>where:</p> |
| 694 | |
| 695 | <div class="preformatted"><div class="preformattedContent"> |
| 696 | <pre>dependencies ::= clause ( ',' clause ) * |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 697 | clause ::= MATCH ( ';' attr '=' MATCH | ';inline=' inline ) |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 698 | attr ::= 'groupId' | 'artifactId' | 'version' | 'scope' | 'type' | 'classifier' |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 699 | inline ::= 'true' | 'false' | PATH ( '|' PATH ) * |
| 700 | MATCH ::= <globbed regular expression> |
| 701 | PATH ::= <Ant-style path expression> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 702 | </pre> |
| 703 | </div></div> |
| 704 | |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 705 | <p>The plugin uses the <tt><Embed-Dependency></tt> instruction to transform the project dependencies into <tt><Include-Resource></tt> and <tt><Bundle-ClassPath></tt> |
| 706 | clauses, which are then appended to the current set of instructions and |
| 707 | passed onto BND. If you want the embedded dependencies to be at the |
| 708 | start or middle of <tt><Include-Resource></tt> or <tt><Bundle-ClassPath></tt> then you can use {<tt>maven-dependencies</tt>}, which will automatically expand to the relevant clauses.</p> |
Stuart McCulloch | 7c961f5 | 2008-01-02 08:56:07 +0000 | [diff] [blame] | 709 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 710 | <p>The MATCH section accepts alternatives, separated by <b>|</b>, and can be negated by using <b>!</b> at the <em>beginning</em> of the MATCH. Use <b>*</b> to represent zero or more unknown characters and <b>?</b> to represent a single unknown character. There is no need to escape the <b>.</b> character inside MATCH. The first MATCH in a clause will filter against the artifactId.</p> |
| 711 | |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 712 | <p>some examples:</p> |
| 713 | |
| 714 | <div class="code"><div class="codeContent"> |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 715 | <pre class="code-xml"><span class="code-tag"><span class="code-comment"><!-- embed all compile and runtime scope dependencies --></span></span> |
| 716 | <span class="code-tag"><Embed-Dependency></span>*;scope=compile|runtime<span class="code-tag"></Embed-Dependency></span> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 717 | |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 718 | <span class="code-tag"><span class="code-comment"><!-- embed any dependencies with artifactId junit and scope runtime --></span></span> |
| 719 | <span class="code-tag"><Embed-Dependency></span>junit;scope=runtime<span class="code-tag"></Embed-Dependency></span> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 720 | |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 721 | <span class="code-tag"><span class="code-comment"><!-- inline all non-pom dependencies, except those with scope runtime --></span></span> |
| 722 | <span class="code-tag"><Embed-Dependency></span>*;scope=!runtime;type=!pom;inline=true<span class="code-tag"></Embed-Dependency></span> |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 723 | |
| 724 | <span class="code-tag"><span class="code-comment"><!-- embed all compile and runtime scope dependencies, except those with artifactIds in the given list --></span></span> |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 725 | <span class="code-tag"><Embed-Dependency></span>*;scope=compile|runtime;inline=false;artifactId=!cli|lang|runtime|tidy|jsch<span class="code-tag"></Embed-Dependency></span> |
| 726 | |
| 727 | <span class="code-tag"><span class="code-comment"><!-- inline contents of selected folders from all dependencies --></span></span> |
| 728 | <span class="code-tag"><Embed-Dependency></span>*;inline=images/**|icons/**<span class="code-tag"></Embed-Dependency></span></pre> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 729 | </div></div> |
| 730 | |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 731 | <p>examples of using {<tt>maven-dependencies</tt>}:</p> |
| 732 | |
| 733 | <div class="code"><div class="codeContent"> |
| 734 | <pre class="code-xml"><span class="code-tag"><Include-Resource></span> |
| 735 | {maven-resources}, {maven-dependencies}, |
| 736 | org/foo/Example.class=target/classes/org/foo/Example.class |
| 737 | <span class="code-tag"></Include-Resource></span> |
| 738 | |
| 739 | <span class="code-tag"><Bundle-ClassPath></span>.,{maven-dependencies},some.jar<span class="code-tag"></Bundle-ClassPath></span></pre> |
| 740 | </div></div> |
| 741 | |
Stuart McCulloch | 7c961f5 | 2008-01-02 08:56:07 +0000 | [diff] [blame] | 742 | <p>By default matched dependencies are embedded in the bundle as <tt>artifactId-version.jar</tt>. This behaviour can be modified using the following instructions:</p> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 743 | |
| 744 | <ul> |
| 745 | <li><tt><Embed-StripVersion>true</Embed-StripVersion></tt> - removes the version from the file (ie. <em>artifactId.jar</em>)</li> |
| 746 | <li><tt><Embed-StripGroup>false</Embed-StripGroup></tt> - adds the groupId as a subdirectory (ie. <em>groupId/artifactId-version.jar</em>)</li> |
| 747 | <li><tt><Embed-Directory>directory</Embed-Directory></tt> - adds a subdirectory (ie. <em>directory/artifactId-version.jar</em>)</li> |
| 748 | </ul> |
| 749 | |
| 750 | |
| 751 | <p>Normally the plugin only checks direct dependencies, but this can be |
| 752 | changed to include the complete set of transitive dependencies with the |
| 753 | following option:</p> |
| 754 | |
| 755 | <div class="code"><div class="codeContent"> |
| 756 | <pre class="code-xml"><span class="code-tag"><Embed-Transitive></span>true<span class="code-tag"></Embed-Transitive></span></pre> |
| 757 | </div></div> |
| 758 | |
| 759 | <p>If you want a dependency inlined instead of embedded add the <tt>inline=true</tt>. For example to inline all <em>compile</em> and <em>runtime</em> scoped dependencies use:</p> |
| 760 | |
| 761 | <div class="code"><div class="codeContent"> |
| 762 | <pre class="code-xml"><span class="code-tag"><Embed-Dependency></span>*;scope=compile|runtime;inline=true<span class="code-tag"></Embed-Dependency></span></pre> |
| 763 | </div></div> |
| 764 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 765 | <h3><a name="ApacheFelixMavenBundlePlugin(BND)-EmbedDependencyandExportPackage"></a>Embed-Dependency and Export-Package</h3> |
Stuart McCulloch | 7c961f5 | 2008-01-02 08:56:07 +0000 | [diff] [blame] | 766 | |
| 767 | <p>If you embed a dependency with <tt><Embed-Dependency></tt>, and your <tt><Export-Package></tt> or <tt><Private-Package></tt> instructions match packages inside the embedded jar, you will see some duplication inside the bundle. This is because the <tt><Export-Package></tt> and <tt><Private-Package></tt> |
| 768 | instructions will result in classes being inlined in the bundle, even |
| 769 | though they also exist inside the embedded jar. If you want to export |
| 770 | packages from an embedded dependency without such duplication then you |
| 771 | can either inline the dependency, or use a new BND instruction called <tt><_exportcontents></tt>.</p> |
| 772 | |
| 773 | <p><tt><_exportcontents></tt> behaves just like Export-Package, except it doesn't change the content of the bundle, just what content should be exported.</p> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 774 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 775 | <h2><a name="ApacheFelixMavenBundlePlugin(BND)-OBRintegration"></a>OBR integration</h2> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 776 | |
| 777 | <p>The latest Maven Bundle Plugin automatically updates the local OBR |
| 778 | repository.xml file during the install phase, using a default location |
| 779 | of:</p> |
| 780 | |
| 781 | <div class="code"><div class="codeContent"> |
| 782 | <pre class="code-java"><LOCAL-MAVEN-REPOSITORY>/repository.xml</pre> |
| 783 | </div></div> |
| 784 | |
| 785 | <p>You can configure the location of the OBR repository by using the command line:</p> |
| 786 | |
| 787 | <div class="code"><div class="codeContent"> |
| 788 | <pre class="code-java">mvn clean install -DobrRepository=<PATH_TO_OBR></pre> |
| 789 | </div></div> |
| 790 | |
| 791 | <p>or in the configuration section for the maven-bundle-plugin in your Maven POM:</p> |
| 792 | |
| 793 | <div class="code"><div class="codeContent"> |
| 794 | <pre class="code-xml"><span class="code-tag"><groupId></span>org.apache.felix<span class="code-tag"></groupId></span> |
| 795 | <span class="code-tag"><artifactId></span>maven-bundle-plugin<span class="code-tag"></artifactId></span> |
| 796 | <span class="code-tag"><extensions></span>true<span class="code-tag"></extensions></span> |
| 797 | <span class="code-tag"><configuration></span> |
| 798 | <span class="code-tag"><obrRepository></span>PATH_TO_OBR<span class="code-tag"></obrRepository></span> |
| 799 | <span class="code-tag"><instructions></span> |
| 800 | <span class="code-tag"><span class="code-comment"><!-- bnd instructions --></span></span> |
| 801 | <span class="code-tag"></instructions></span> |
| 802 | <span class="code-tag"></configuration></span></pre> |
| 803 | </div></div> |
| 804 | |
| 805 | <p>to disable OBR installation set the obrRepository to NONE, for example:</p> |
| 806 | |
| 807 | <div class="code"><div class="codeContent"> |
| 808 | <pre class="code-xml"><span class="code-tag"><groupId></span>org.apache.felix<span class="code-tag"></groupId></span> |
| 809 | <span class="code-tag"><artifactId></span>maven-bundle-plugin<span class="code-tag"></artifactId></span> |
| 810 | <span class="code-tag"><extensions></span>true<span class="code-tag"></extensions></span> |
| 811 | <span class="code-tag"><configuration></span> |
| 812 | <span class="code-tag"><obrRepository></span>NONE<span class="code-tag"></obrRepository></span> |
| 813 | <span class="code-tag"><instructions></span> |
| 814 | <span class="code-tag"><span class="code-comment"><!-- bnd instructions --></span></span> |
| 815 | <span class="code-tag"></instructions></span> |
| 816 | <span class="code-tag"></configuration></span></pre> |
| 817 | </div></div> |
| 818 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 819 | <h2><a name="ApacheFelixMavenBundlePlugin(BND)-Eclipse/PDEintegration"></a>Eclipse/PDE integration</h2> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 820 | |
| 821 | <p>It is possible to configure the Maven Bundle Plugin to put the |
| 822 | bundle manifest where Eclipse/PDE expects it, and use the Maven |
| 823 | Dependency Plugin to arrange for any embedded dependencies to appear in |
| 824 | a local directory that matches the Bundle-ClassPath entries. Here is an |
| 825 | example POM that does this:</p> |
| 826 | |
| 827 | <div class="preformatted"><div class="preformattedContent"> |
| 828 | <pre><project> |
| 829 | |
| 830 | <properties> |
| 831 | <bundle.symbolicName>org.example</bundle.symbolicName> |
| 832 | <bundle.namespace>org.example</bundle.namespace> |
| 833 | </properties> |
| 834 | |
| 835 | <modelVersion>4.0.0</modelVersion> |
| 836 | <groupId>examples</groupId> |
| 837 | <artifactId>org.example</artifactId> |
| 838 | <version>1.0-SNAPSHOT</version> |
| 839 | |
| 840 | <name>${bundle.symbolicName} [${bundle.namespace}]</name> |
| 841 | |
| 842 | <packaging>bundle</packaging> |
| 843 | |
| 844 | <build> |
Stuart McCulloch | dd4ae5f | 2008-02-05 12:38:46 +0000 | [diff] [blame] | 845 | <resources> |
| 846 | <resource> |
| 847 | <directory>src/main/resources</directory> |
| 848 | </resource> |
| 849 | <resource> |
| 850 | <directory>.</directory> |
| 851 | <includes> |
| 852 | <include>plugin.xml</include> |
| 853 | </includes> |
| 854 | </resource> |
| 855 | </resources> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 856 | <plugins> |
| 857 | <plugin> |
| 858 | <groupId>org.apache.felix</groupId> |
| 859 | <artifactId>maven-bundle-plugin</artifactId> |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 860 | <version>1.2.1</version> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 861 | <extensions>true</extensions> |
| 862 | <!-- |
| 863 | the following instructions build a simple set of public/private classes into an OSGi bundle |
| 864 | --> |
| 865 | <configuration> |
| 866 | <manifestLocation>META-INF</manifestLocation> |
| 867 | <instructions> |
| 868 | <Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName> |
| 869 | <Bundle-Version>${pom.version}</Bundle-Version> |
| 870 | <!-- |
| 871 | assume public classes are in the top package, and private classes are under ".internal" |
| 872 | --> |
Stuart McCulloch | dd4ae5f | 2008-02-05 12:38:46 +0000 | [diff] [blame] | 873 | <Export-Package>!${bundle.namespace}.internal.*,${bundle.namespace}.*;version="${pom.version}"</Export-Package> |
| 874 | <Private-Package>${bundle.namespace}.internal.*</Private-Package> |
| 875 | <Bundle-Activator>${bundle.namespace}.internal.ExampleActivator</Bundle-Activator> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 876 | <!-- |
| 877 | embed compile/runtime dependencies using path that matches the copied dependency folder |
| 878 | --> |
| 879 | <Embed-Dependency>*;scope=compile|runtime;inline=false</Embed-Dependency> |
| 880 | <Embed-Directory>target/dependency</Embed-Directory> |
| 881 | <Embed-StripGroup>true</Embed-StripGroup> |
| 882 | </instructions> |
| 883 | </configuration> |
| 884 | </plugin> |
| 885 | <plugin> |
| 886 | <artifactId>maven-dependency-plugin</artifactId> |
| 887 | <executions> |
| 888 | <execution> |
| 889 | <id>copy-dependencies</id> |
| 890 | <phase>package</phase> |
| 891 | <goals> |
| 892 | <goal>copy-dependencies</goal> |
| 893 | </goals> |
| 894 | </execution> |
| 895 | </executions> |
| 896 | </plugin> |
| 897 | </plugins> |
| 898 | </build> |
| 899 | |
| 900 | <dependencies> |
| 901 | <dependency> |
| 902 | <groupId>org.osgi</groupId> |
| 903 | <artifactId>osgi_R4_core</artifactId> |
| 904 | <version>1.0</version> |
| 905 | <scope>provided</scope> |
| 906 | <optional>true</optional> |
| 907 | </dependency> |
| 908 | <dependency> |
| 909 | <groupId>org.osgi</groupId> |
| 910 | <artifactId>osgi_R4_compendium</artifactId> |
| 911 | <version>1.0</version> |
| 912 | <scope>provided</scope> |
| 913 | <optional>true</optional> |
| 914 | </dependency> |
| 915 | <dependency> |
| 916 | <groupId>junit</groupId> |
| 917 | <artifactId>junit</artifactId> |
| 918 | <version>3.8.1</version> |
| 919 | <scope>compile</scope> |
| 920 | <optional>true</optional> |
| 921 | </dependency> |
| 922 | </dependencies> |
| 923 | |
| 924 | </project> |
| 925 | </pre> |
| 926 | </div></div> |
| 927 | |
| 928 | <p>To generate the Eclipse metadata use:</p> |
| 929 | |
| 930 | <div class="code"><div class="codeContent"> |
| 931 | <pre class="code-java">mvn clean <span class="code-keyword">package</span> eclipse:eclipse -Declipse.pde install</pre> |
| 932 | </div></div> |
| 933 | |
| 934 | <p>and you should now be able to import this as an existing Eclipse project.</p> |
| 935 | |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 936 | <p>FYI: the above POM was generated using the <tt>pax-create-bundle</tt> command from <span class="nobr"><a href="http://www.ops4j.org/projects/pax/construct/index.html" title="Visit page outside Confluence" rel="nofollow">Pax-Construct<sup><img class="rendericon" src="apache-felix-maven-bundle-plugin-bnd_files/linkext7.gif" alt="" width="7" align="absmiddle" border="0" height="7"></sup></a></span> and then tweaked to demonstrate using the Maven Dependency Plugin to handle embedded jars in Eclipse.</p> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 937 | |
| 938 | <p>With the original Pax-Construct generated POM you would simply use:</p> |
| 939 | |
| 940 | <div class="code"><div class="codeContent"> |
| 941 | <pre class="code-java">mvn clean <span class="code-keyword">package</span> pax:eclipse</pre> |
| 942 | </div></div> |
| 943 | |
| 944 | <p>to create the appropriate Eclipse files and manifest, and also |
| 945 | handle any embedded entries. The pax:eclipse goal extends |
| 946 | eclipse:eclipse, and supports the same parameters.</p> |
| 947 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 948 | <h2><a name="ApacheFelixMavenBundlePlugin(BND)-Unpackingbundlecontentsto'target/classes'"></a>Unpacking bundle contents to 'target/classes'</h2> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 949 | |
| 950 | <p>Once in a while you may create a bundle which contains additional classes to the ones compiled from <tt>src/main/java</tt>, |
| 951 | for example when you embed the classes from another jar. This can |
| 952 | sometimes cause unforeseen problems in Maven, as it will use the output |
| 953 | directory (<tt>target/classes</tt>) rather than the final bundle, when compiling against projects in the same reactor (ie. the same build).</p> |
| 954 | |
| 955 | <p>The easiest way to get around this Maven 'feature' is to unpack the |
| 956 | contents of the bundle to the output directory after the packaging |
| 957 | step, so the additional classes will be found where Maven expects them. |
| 958 | Thankfully there is now an easy option to do this in the bundle-plugin:</p> |
| 959 | |
| 960 | <div class="code"><div class="codeContent"> |
Stuart McCulloch | dd4ae5f | 2008-02-05 12:38:46 +0000 | [diff] [blame] | 961 | <pre class="code-xml"><span class="code-tag"><groupId></span>org.apache.felix<span class="code-tag"></groupId></span> |
| 962 | <span class="code-tag"><artifactId></span>maven-bundle-plugin<span class="code-tag"></artifactId></span> |
| 963 | <span class="code-tag"><extensions></span>true<span class="code-tag"></extensions></span> |
| 964 | <span class="code-tag"><configuration></span> |
| 965 | <span class="code-tag"><unpackBundle></span>true<span class="code-tag"></unpackBundle></span> |
| 966 | <span class="code-tag"><instructions></span> |
| 967 | <span class="code-tag"><span class="code-comment"><!-- bnd instructions --></span></span> |
| 968 | <span class="code-tag"></instructions></span> |
| 969 | <span class="code-tag"></configuration></span></pre> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 970 | </div></div> |
| 971 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 972 | <h2><a name="ApacheFelixMavenBundlePlugin(BND)-UsinganexistingMANIFEST.MFfile"></a>Using an existing MANIFEST.MF file</h2> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 973 | |
| 974 | <p>If you have an existing manifest, you can add this to the Bnd instructions, like so:</p> |
| 975 | |
| 976 | <div class="code"><div class="codeContent"> |
Stuart McCulloch | dd4ae5f | 2008-02-05 12:38:46 +0000 | [diff] [blame] | 977 | <pre class="code-xml"><span class="code-tag"><_include></span>src/main/resources/META-INF/MANIFEST.MF<span class="code-tag"></_include></span> |
| 978 | <span class="code-tag"><Export-Package></span>org.example.*<span class="code-tag"></Export-Package></span></pre> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 979 | </div></div> |
| 980 | |
| 981 | <p>Bnd will use it when calculating the bundle contents, and will also |
| 982 | copy across all manifest attributes starting with a capital letter.<br> |
| 983 | As shown in the above example, you could use this to include a non-OSGi |
| 984 | manifest which you then customize with extra OSGi attributes.</p> |
| 985 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 986 | <h1><a name="ApacheFelixMavenBundlePlugin(BND)-Thefollowingfeaturesareonlyavailablefromversion1.4.0onwards"></a>The following features are only available from version 1.4.0 onwards</h1> |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 987 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 988 | <h2><a name="ApacheFelixMavenBundlePlugin(BND)-bundle:ant"></a>bundle:ant</h2> |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 989 | |
| 990 | <p>The <b>ant</b> goal creates a customized <tt>build.xml</tt> Ant script along with a collection of BND instructions and properties, taken from the current project and stored in <tt>maven-build.bnd</tt>. You also need to run <b><tt>ant:ant</tt></b> to create the standard Ant support tasks to download Maven dependencies and perform compilation, etc.</p> |
| 991 | |
| 992 | <p>The customized Ant script uses the BND tool to rebuild the bundle, |
| 993 | so any source changes should be reflected in the (re)generated manifest.</p> |
| 994 | |
| 995 | <p>Example:</p> |
| 996 | <div class="preformatted"><div class="preformattedContent"> |
| 997 | <pre>mvn ant:ant bundle:ant |
| 998 | |
| 999 | ant clean package |
| 1000 | </pre> |
| 1001 | </div></div> |
| 1002 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 1003 | <h2><a name="ApacheFelixMavenBundlePlugin(BND)-bundle:installfile"></a>bundle:install-file</h2> |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 1004 | |
| 1005 | <p>The <b>install-file</b> goal updates the local OBR with the details of a bundle from the local filesystem.</p> |
| 1006 | |
| 1007 | <p>configuration:</p> |
| 1008 | <ul> |
| 1009 | <li><em>obrRepository</em> path to local OBR, defaults to <em><local-maven-repository></em><tt>/repository.xml</tt></li> |
| 1010 | <li><em>groupId</em> Maven groupId for the bundle, taken from <em>pomFile</em> if given</li> |
| 1011 | <li><em>artifactId</em> Maven artifactId for the bundle, taken from <em>pomFile</em> if given</li> |
| 1012 | <li><em>version</em> Maven version for the bundle, taken from <em>pomFile</em> if given</li> |
| 1013 | <li><em>packaging</em> Maven packaging type for the bundle, taken from <em>pomFile</em> if given</li> |
| 1014 | <li><em>classifier</em> Maven classifier type, defaults to none</li> |
| 1015 | <li><em>pomFile</em> optional Pom file describing the bundle</li> |
| 1016 | <li><em>file</em> bundle file, defaults to the bundle from the local Maven repository</li> |
| 1017 | <li><em>obrXml</em> optional additional properties for the bundle</li> |
| 1018 | </ul> |
| 1019 | |
| 1020 | |
| 1021 | <p>Example:</p> |
| 1022 | <div class="preformatted"><div class="preformattedContent"> |
| 1023 | <pre>mvn org.apache.felix:maven-bundle-plugin:1.4.0:install-file \ |
| 1024 | -DpomFile=myPom.xml -Dfile=foo-1.0.jar |
| 1025 | </pre> |
| 1026 | </div></div> |
| 1027 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 1028 | <h2><a name="ApacheFelixMavenBundlePlugin(BND)-bundle:deploy"></a>bundle:deploy</h2> |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 1029 | |
| 1030 | <p>The <b>deploy goal</b> updates the remote OBR with the details of |
| 1031 | the deployed bundle from the local Maven repository. The remote OBR is |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 1032 | found by querying the <tt><distributionManagement></tt> section of the project, unless <tt>-DaltDeploymentRepository</tt> is set. See <span class="nobr"><a href="http://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html" title="Visit page outside Confluence" rel="nofollow">http://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html<sup><img class="rendericon" src="apache-felix-maven-bundle-plugin-bnd_files/linkext7.gif" alt="" width="7" align="absmiddle" border="0" height="7"></sup></a></span> for more details about these particular settings.</p> |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 1033 | |
| 1034 | <p>(If the project has an <tt>obr.xml</tt> file somewhere in its resources, then it will be automatically detected and applied.)</p> |
| 1035 | |
| 1036 | <p>configuration:</p> |
| 1037 | <ul> |
| 1038 | <li><em>remoteOBR</em> name of remote OBR, defaults to NONE (which means no remote OBR deployment)</li> |
| 1039 | <li><em>obrRepository</em> used when the remoteOBR name is blank, defaults to <tt>repository.xml</tt></li> |
| 1040 | <li><em>altDeploymentRepository</em> alternative remote repository, <em>id::layout::url</em></li> |
| 1041 | <li><em>ignoreLock</em> ignore remote locking when updating the OBR</li> |
| 1042 | </ul> |
| 1043 | |
| 1044 | |
| 1045 | <p>This goal is part of the "bundle" packaging lifecycle, but is disabled by default - to enable just set the <tt>remoteOBR</tt> parameter.</p> |
| 1046 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 1047 | <h2><a name="ApacheFelixMavenBundlePlugin(BND)-bundle:deployfile"></a>bundle:deploy-file</h2> |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 1048 | |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 1049 | <p>The <b>deploy-file</b> goal updates the remote OBR with the details of a deployed bundle from the local filesystem. The remote OBR is found using the <tt>-DrepositoryId</tt> and <tt>-Durl</tt> parameters. See <span class="nobr"><a href="http://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html" title="Visit page outside Confluence" rel="nofollow">http://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html<sup><img class="rendericon" src="apache-felix-maven-bundle-plugin-bnd_files/linkext7.gif" alt="" width="7" align="absmiddle" border="0" height="7"></sup></a></span> for more details about these particular settings.</p> |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 1050 | |
| 1051 | <p>You can use the <tt>-DbundleUrl</tt> parameter to give the public location of the deployed bundle, which may differ from the remote OBR location.</p> |
| 1052 | |
| 1053 | <p>configuration:</p> |
| 1054 | <ul> |
| 1055 | <li><em>remoteOBR</em> name of remote OBR, defaults to an empty string</li> |
| 1056 | <li><em>obrRepository</em> used when the remoteOBR name is blank, defaults to <tt>repository.xml</tt></li> |
| 1057 | <li><em>repositoryId</em> optional repository id, used to lookup authentication settings</li> |
| 1058 | <li><em>url</em> remote repository transport URL, like |
| 1059 | <div class="preformatted"><div class="preformattedContent"> |
| 1060 | <pre>scpexe://host/path/to/obr |
| 1061 | </pre> |
| 1062 | </div></div></li> |
| 1063 | <li><em>bundleUrl</em> public URL of deployed bundle, like |
| 1064 | <div class="preformatted"><div class="preformattedContent"> |
| 1065 | <pre>http://www.foo.org/bundles/foo.jar |
| 1066 | </pre> |
| 1067 | </div></div></li> |
| 1068 | <li><em>groupId</em> Maven groupId for the bundle, taken from <em>pomFile</em> if given</li> |
| 1069 | <li><em>artifactId</em> Maven artifactId for the bundle, taken from <em>pomFile</em> if given</li> |
| 1070 | <li><em>version</em> Maven version for the bundle, taken from <em>pomFile</em> if given</li> |
| 1071 | <li><em>packaging</em> Maven packaging type for the bundle, taken from <em>pomFile</em> if given</li> |
| 1072 | <li><em>classifier</em> Maven classifier type, defaults to none</li> |
| 1073 | <li><em>pomFile</em> optional Pom file describing the bundle</li> |
| 1074 | <li><em>file</em> bundle file, defaults to the bundle from the local Maven repository</li> |
| 1075 | <li><em>obrXml</em> optional additional properties for the bundle</li> |
| 1076 | <li><em>ignoreLock</em> ignore remote locking when updating the OBR</li> |
| 1077 | </ul> |
| 1078 | |
| 1079 | |
Stuart McCulloch | 738a06d | 2009-02-27 06:38:33 +0000 | [diff] [blame] | 1080 | |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 1081 | <p>Example:</p> |
| 1082 | <div class="preformatted"><div class="preformattedContent"> |
| 1083 | <pre>mvn org.apache.felix:maven-bundle-plugin:1.4.0:deploy-file \ |
| 1084 | -DpomFile=myPom.xml -Dfile=foo-1.0.jar -Durl=file:/tmp/example/OBR \ |
| 1085 | -DbundleUrl=http://www.foo.org/bundles/foo.jar |
| 1086 | </pre> |
| 1087 | </div></div> |
| 1088 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 1089 | <h2><a name="ApacheFelixMavenBundlePlugin(BND)-bundle:clean"></a>bundle:clean</h2> |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 1090 | |
| 1091 | <p>Sometimes you would like to clean your local OBR because it contains |
| 1092 | bundles that are no longer in your local Maven repository. This case |
| 1093 | often occurs when artifacts were deleted manually. The |
| 1094 | maven-bundle-plugin provides a simple goal to check for missing |
| 1095 | bundles, and remove them from the local OBR.</p> |
| 1096 | |
| 1097 | <p>configuration:</p> |
| 1098 | <ul> |
| 1099 | <li><em>obrRepository</em> path to local OBR, defaults to <em><local-maven-repository></em><tt>/repository.xml</tt></li> |
| 1100 | </ul> |
| 1101 | |
| 1102 | |
| 1103 | <p>Example:</p> |
| 1104 | <div class="preformatted"><div class="preformattedContent"> |
| 1105 | <pre>mvn bundle:clean |
| 1106 | </pre> |
| 1107 | </div></div> |
| 1108 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 1109 | <h2><a name="ApacheFelixMavenBundlePlugin(BND)-Concurrentupdates"></a>Concurrent updates</h2> |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 1110 | |
| 1111 | <p>With a remote OBR, several uploads may occur at the same time. |
| 1112 | However, the remote OBR is centralized in one file, so concurrent |
| 1113 | modification must be avoided. To achieve this, the plug-in implements a |
| 1114 | locking system. Each time the plug-in tries to modify the file it sets |
| 1115 | a file based lock. If it can't take the lock, it will wait and retry. |
| 1116 | After 3 attempts the upload process fails. To bypass this lock add <tt>-DignoreLock</tt> to the command-line (or add <tt><ignoreLock>true<ignoreLock></tt> to the configuration section of your Pom).</p> |
| 1117 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 1118 | <h2><a name="ApacheFelixMavenBundlePlugin(BND)-FTPprotocol"></a>FTP protocol</h2> |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 1119 | |
| 1120 | <p>Not all protocols are supported by Maven out of the box. For example the ftp protocol requires the <b>wagon-ftp</b> component. To enable the ftp protocol add this to your Pom:</p> |
| 1121 | <div class="code"><div class="codeContent"> |
| 1122 | <pre class="code-xml"><span class="code-tag"><build></span> |
| 1123 | <span class="code-tag"><extensions></span> |
| 1124 | <span class="code-tag"><extension></span> |
| 1125 | <span class="code-tag"><groupId></span>org.apache.maven.wagon<span class="code-tag"></groupId></span> |
| 1126 | <span class="code-tag"><artifactId></span>wagon-ftp<span class="code-tag"></artifactId></span> |
| 1127 | <span class="code-tag"><version></span>1.0-alpha-6<span class="code-tag"></version></span> |
| 1128 | <span class="code-tag"></extension></span> |
| 1129 | <span class="code-tag"></extensions></span> |
| 1130 | <span class="code-tag"></build></span></pre> |
| 1131 | </div></div> |
| 1132 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 1133 | <h2><a name="ApacheFelixMavenBundlePlugin(BND)-Howtheplugincomputesthedescriptionofthebundle"></a>How the plug-in computes the description of the bundle</h2> |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 1134 | |
| 1135 | <p>The description of the bundle comes from three different sources:</p> |
| 1136 | <ul> |
| 1137 | <li>Bindex : Bindex is a tool that analyzes a bundle manifest to generate OBR description</li> |
| 1138 | <li>pom.xml : by analyzing the pom file, various information is collected (symbolic name ...)</li> |
| 1139 | <li>obr.xml : this file contains customized description and capabilities for the bundle</li> |
| 1140 | </ul> |
| 1141 | |
| 1142 | |
| 1143 | <p>These sources are merged together using the following precedence:</p> |
| 1144 | <div class="preformatted"><div class="preformattedContent"> |
| 1145 | <pre>Bindex |
| 1146 | | (overrides) |
| 1147 | pom.xml |
| 1148 | | (overrides) |
| 1149 | obr.xml |
| 1150 | </pre> |
| 1151 | </div></div> |
| 1152 | <p>A warning message is displayed when existing information is overridden.</p> |
| 1153 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 1154 | <h2><a name="ApacheFelixMavenBundlePlugin(BND)-Knownissues&limitations"></a>Known issues & limitations</h2> |
Stuart McCulloch | 0340ae4 | 2008-02-22 11:27:18 +0000 | [diff] [blame] | 1155 | |
| 1156 | <ol> |
| 1157 | <li>obr.xml (file given by the user to add properties not found |
| 1158 | by Bindex) must be correct, because the plug-in does not check its |
| 1159 | syntax.</li> |
| 1160 | </ol> |
| 1161 | |
| 1162 | |
Stuart McCulloch | dd89cdb | 2008-05-03 08:13:09 +0000 | [diff] [blame] | 1163 | <h1><a name="ApacheFelixMavenBundlePlugin(BND)-Feedback"></a>Feedback</h1> |
Stuart McCulloch | 93de649 | 2007-12-16 15:59:05 +0000 | [diff] [blame] | 1164 | |
Stuart McCulloch | c9b81e1 | 2009-02-26 21:29:51 +0000 | [diff] [blame] | 1165 | <p>Subscribe to the Felix users mailing list by sending a message to <span class="nobr"><a href="mailto:users-subscribe@felix.apache.org" title="Send mail to users-subscribe@felix.apache.org" rel="nofollow">users-subscribe@felix.apache.org<sup><img class="rendericon" src="apache-felix-maven-bundle-plugin-bnd_files/mail_small.gif" alt="" width="13" align="absmiddle" border="0" height="12"></sup></a></span>; after subscribing, email questions or feedback to <span class="nobr"><a href="mailto:users@felix.apache.org" title="Send mail to users@felix.apache.org" rel="nofollow">users@felix.apache.org<sup><img class="rendericon" src="apache-felix-maven-bundle-plugin-bnd_files/mail_small.gif" alt="" width="13" align="absmiddle" border="0" height="12"></sup></a></span>.</p> |
Karl Pauls | f87ac14 | 2007-07-06 22:36:17 +0000 | [diff] [blame] | 1166 | </div> |
Stuart McCulloch | b4212cc | 2008-08-05 06:36:05 +0000 | [diff] [blame] | 1167 | </body></html> |