blob: 078fb3a96e5310bdfb3c8d09a40bd37f1106edf2 [file] [log] [blame]
Timothy Bennett3f0cb482005-08-23 06:11:13 +00001This document describes how to use the maven-osgi-plugin for Maven2.
2
3NOTE: This plugin is only for Maven2. It will not work with Maven 1.x versions.
4
5NOTE: This plugin is very immature and is a project under development. Help
6with the development of this plugin is welcome. A development roadmap for this
7plugin will be posted at http://issues.apache.org/jira/browse/FELIX at some
8point in the near future.
9
10HOW-TO
11======
12
131. Install maven-2.0-alpha-3 release on your local machine. You can download
14a binary distro from http://maven.apache.org/maven2/download.html along with
15some instructions for getting started with Maven2.
16
172. You'll need an interim build of Maven2's maven-archiver that I've made
18available at:
19
20 https://svn.apache.org/repos/asf/incubator/felix/trunk/sandbox/tbennett/maven-archiver
21
22I've submitted patches to the Maven team that include these modifications to
23the maven-archiver-plugin. However, they are not scheduled to be released
24until the maven-2.0-beta-1 release. You'll need to use this version of
25maven-archiver until that release is available from the Maven team.
26
27Once you've done an SVN checkout of the maven-archiver from my sandbox, simply
28execute the following command from the maven-archiver project root directory:
29
30 $ m2 install
31
32This will build and locally install this interim version of the maven-archiver-plugin.
33
343. Perform an SVN checkout of the maven-osgi-plugin available at:
35
36 https://svn.apache.org/repos/asf/incubator/felix/trunk/tools/maven2/maven-osgi-plugin
37
38Once you've done this, simply execute the following command from the
39maven-osgi-plugin project root directory:
40
41 $ m2 install
42
43This will build and locally install the maven-osgi-plugin.
44
454. You can now use the plugin with a Maven2 POM to build an OSGi bundle jar
46artifact. An example of what a bundle's Maven2 POM might look like that uses
47this plugin is shown below.
48
49After compiling your bundle using the standard Maven2 compile goal:
50
51 $ m2 compile
52
53You can build the OSGi bundle artifact by issuing the following maven2
54command:
55
56 $ m2 osgi:osgi-jar
57
58Note the definition of the maven-osgi-plugin in the <build/> section of the
59POM, along with the specification of the custom manifest entries you'd like
60Maven2 to include in the jar's manifest file. Currently, the only manifest
61entries that I've added support so far are: Bundle-Activator, Bundle-Name,
62Bundle-Description, Bundle-Version, Bundle-Vendor, Bundle-Date,
63Bundle-UpdateLocation, Export-Package, and Metadata-Location. More support
64will be added soon.
65
66The plugin also takes advantage of Maven2's <scope/> specifier for given
67project dependency. If the scope specifier is either "compile" or
68"runtime", the given dependency will be bundled in the root directory of
69the jar, and it's filename added to the Bundle-Classpath entry in the jar's
70manifest file. This is done automatically by simply setting the dependency
71scope. In the case of the below example, the osgi-framework-1.2.jar
72dependency that my-bundle specifies has scope of "provided". This tells
73the maven-osgi-plugin that the OSGi container will *provide* this dependency
74at runtime, and therefore this dependency will not need to be embedded into
75the bundle's jar file.
76
77<project>
78 <modelVersion>4.0.0</modelVersion>
79 <groupId>gov.bna.jis.osgi.bundle</groupId>
80 <artifactId>my-bundle</artifactId>
81 <packaging>jar</packaging>
82 <version>1.0-SNAPSHOT</version>
83 <name>OSGi Test Bundle</name>
84 <build>
85 <plugins>
86 <plugin>
87 <groupId>org.apache.maven.plugins</groupId>
88 <artifactId>maven-osgi-plugin</artifactId>
89 <version>0.1</version>
90 <configuration>
91 <osgiManifest>
92 <bundleActivator>gov.bna.jis.osgi.bundle.Activator</bundleActivator>
93 <bundleName>My Bundle Name</bundleName>
94 <bundleDescription>My Bundle Description</bundleDescription>
95 <bundleVendor>Metro Government of Nashville-Davidson Co.</bundleVendor>
96 <bundleVersion>1.0.0</bundleVersion>
97 </osgiManifest>
98 </configuration>
99 </plugin>
100 </plugins>
101 </build>
102 <dependencies>
103 <dependency>
104 <groupId>osgi</groupId>
105 <artifactId>osgi-framework</artifactId>
106 <version>1.2</version>
107 <scope>provided</scope>
108 </dependency>
109 </dependencies>
110</project>
111
112There's much more functionality to add to this plugin, but it's a start.
113
114-tbennett