Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
Include Page
apache-felix-ipojo-header
apache-felix-ipojo-header

HTML
<div class="content">

How to use the iPOJO Maven Plug-in

Wiki Markup
{div:class=toc}
{toc:maxLevel=4|minLevel=2}
{div}

Basic configuration

To use the iPOJO Maven plug-in, edit the following pom.xml (replace all $XXX elements):

Wiki Markup
{div:class=pom}
<project>
&nbsp;<modelVersion>4.0.0</modelVersion>

&nbsp;<packaging>bundle</packaging> <!-- Use the BND Maven plug-in -->
{color:red}&nbsp;{color} {color:red}<groupId>$YOUR_GROUP_ID</groupId>{color}
{color:red}&nbsp;{color} {color:red}<artifactId>$YOUR_ARTIFACT_ID</artifactId>{color}
{color:red}&nbsp;{color} {color:red}<version>$YOUR_ARTIFACT_VERSION</version>{color}
{color:red}&nbsp;{color} {color:red}<name>$YOUR_PROJECT_NAME</name>{color}

{color:red}&nbsp;{color} {color:red}<dependencies>{color}
{color:red}&nbsp;&nbsp;&nbsp;{color} {color:red}$YOUR_MAVEN_DEPENDENCIES{color}
{color:red}&nbsp;{color} {color:red}</dependencies>{color}

&nbsp;<build>
&nbsp;&nbsp;&nbsp;<plugins>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<!-- BND Maven Plugin Configuration -->
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<plugin>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<groupId>org.apache.felix</groupId>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<artifactId>maven-bundle-plugin</artifactId>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <extensions>true</extensions>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <configuration>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <instructions>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <Bundle-SymbolicName>$\{pom.artifactId}</Bundle-SymbolicName>
{color:red}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{color}{color:red}<Private-Package>$YOUR_PRIVATE_PACKAGE</Private-Package>{color}
{color:red}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{color}{color:red}<Export-Package>$YOUR_EXPORTED_PACKAGE</Export-Package>{color}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</instructions>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</configuration>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</plugin>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<!-- iPOJO Maven Plugin Configuration : nothing to do -->
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<plugin>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<groupId>org.apache.felix</groupId>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<artifactId>maven-ipojo-plugin</artifactId>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<version>1.6.0</version>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<executions>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<execution>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <goals>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<goal>ipojo-bundle</goal>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</goals>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</execution>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</executions>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</plugin>
&nbsp;&nbsp;&nbsp;</plugins>
&nbsp;</build>
</project>
{div}

The iPOJO Maven Plug-in is generally used with the BND Maven Plug-in (more details here). However the two configurations are completely separated. So, you can use all BND Maven plug-in features. The iPOJO configuration section can be used as previously written without any changes. However it requires that your metadata file is either inside src/main/ipojo or inside the src/main/resources folder and named "metadata.xml".

Execution

To manipulate your project, use the "mvn clean install" command. The output should be like:

Wiki Markup
{div:class=pom}
\[INFO\] Scanning for projects...
\[INFO\] \---------------------------------------------------------------------------\-
\[INFO\] Building Hello Client
\[INFO\]&nbsp;&nbsp;&nbsp;task-segment: \[clean, install\]
\[INFO\] \---------------------------------------------------------------------------\-
\[INFO\] \[clean:clean\]
\[INFO\] Deleting directory D:\clement\workspaces\iPOJO-Dev\hello.client\target
\[INFO\] Deleting directory D:\clement\workspaces\iPOJO-Dev\hello.client\target\classes
\[INFO\] Deleting directory D:\clement\workspaces\iPOJO-Dev\hello.client\target\test-classes
\[INFO\] Deleting directory D:\clement\workspaces\iPOJO-Dev\hello.client\target\site
\[INFO\] \[resources:resources\]
\[INFO\] Using default encoding to copy filtered resources.
\[INFO\] Copying 1 resource
\[INFO\] \[compiler:compile\]
\[INFO\] Compiling 1 source file to D:\clement\workspaces\iPOJO-Dev\hello.client\target\classes
\[INFO\] \[resources:testResources\]
\[INFO\] Using default encoding to copy filtered resources.
\[INFO\] Resource directory does not exist: D:\clement\workspaces\iPOJO-Dev\hello.client\src\test\resources
\[INFO\] \[compiler:testCompile\]
\[INFO\] No sources to compile
\[INFO\] \[surefire:test\]
\[INFO\] No tests to run.
\[INFO\] \[bundle:bundle\]
\[INFO\] \[org.apache.felix.ipojo.:ipojo-bundle \{execution: default}\]
\[INFO\] Start bundle manipulation
\[INFO\] Metadata File : D:\clement\workspaces\iPOJO-Dev\hello.client\target\classes\metadata.xml
\[INFO\] Input Bundle File : D:\clement\workspaces\iPOJO-Dev\hello.client\target\hello.client-0.0.1.jar
\[INFO\] Bundle manipulation - SUCCESS
\[INFO\] \[install:install\]
\[INFO\] Installing D:\clement\workspaces\iPOJO-Dev\hello.client\target\hello.client-0.0.1.jar to D:\Dev\maven-repo\ipojo\example\hello.client\0.0.1\hello.client-0.0.1.jar
\[INFO\] \-----------------------------------------------------------------------\-
\[INFO\] BUILD SUCCESSFUL
\[INFO\] \-----------------------------------------------------------------------\-
\[INFO\] Total time: 9 seconds
\[INFO\] Finished at: Mon Aug 13 14:04:55 CEST 2007
\[INFO\] Final Memory: 6M/13M
\[INFO\] \-----------------------------------------------------------------------\-
{div}

Configuration Options

You can configure the localization of the iPOJO metadata file as following:

Wiki Markup
{div:class=pom}
<plugin>
&nbsp;&nbsp;&nbsp; <groupId>org.apache.felix</groupId>
&nbsp;&nbsp;&nbsp; <artifactId>maven-ipojo-plugin</artifactId>
&nbsp;&nbsp;&nbsp; <version>1.6.0</version>
&nbsp;&nbsp;&nbsp; <executions>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <execution>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <goals>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <goal>ipojo-bundle</goal>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </goals>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <configuration>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{color:red}<metadata>ipojo/meta.xml</metadata>{color}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </configuration>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;</execution>
&nbsp;&nbsp;&nbsp;</executions>
</plugin>
{div}

In the metadata element, you can specify your metadata file or directory. The given file path is relative to the root directory ("./ipojo/meta.xml"). If the specified location is a directory, all contained XML files will be used. By default, the plugin searches metadata files into the src/main/ipojo folder. If not found then it searches for target/classes/metadata.xml and ./metadata.xml.

Note: The directory support was introduced in the 1.7.0 version. Previously only one metadata file was found.
Compatibility: Before the 1.7.0, the set location was searched in all resource folders. This is no more supported because it's an anti-pattern.

The second option allows skipping annotations processing, by using the ignoreAnnotations element:

Wiki Markup
{div:class=pom}
<plugin>
&nbsp;&nbsp;&nbsp; <groupId>org.apache.felix</groupId>
&nbsp;&nbsp;&nbsp; <artifactId>maven-ipojo-plugin</artifactId>
&nbsp;&nbsp;&nbsp; <version>1.6.0</version>
&nbsp;&nbsp;&nbsp; <executions>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <execution>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <goals>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <goal>ipojo-bundle</goal>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </goals>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <configuration>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;{color:red}<ignoreAnnotations>true</ignoreAnnotations>{color}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </configuration>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;</execution>
&nbsp;&nbsp;&nbsp;</executions>
</plugin>
{div}

You can also ignore embedded XML-Schemas to use external ones. To do so, add the ignoreEmbeddedSchemas. If set to true, the manipulator doesn't use embedded XML-Schemas:

Wiki Markup
{div:class=pom}
<plugin>
&nbsp;&nbsp;&nbsp; <groupId>org.apache.felix</groupId>
&nbsp;&nbsp;&nbsp; <artifactId>maven-ipojo-plugin</artifactId>
&nbsp;&nbsp;&nbsp; <version>1.6.0</version>
&nbsp;&nbsp;&nbsp; <executions>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <execution>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <goals>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <goal>ipojo-bundle</goal>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </goals>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <configuration>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;{color:red}<ignoreEmbeddedSchemas>true</ignoreEmbeddedSchemas>{color}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </configuration>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;</execution>
&nbsp;&nbsp;&nbsp;</executions>
</plugin>
{div}

Generate the skeleton of your iPOJO bundle

The maven-ipojo-plugin provides a way to generate the skeleton of your project. To generate this structure, just launch the following command:

Code Block
mvn org.apache.maven.plugins:maven-archetype-plugin:generate \
-DarchetypeArtifactId=maven-ipojo-plugin \
-DarchetypeGroupId=org.apache.felix \
-DartifactId=ARTIFACT_NAME_OF_YOUR_PROJECT \
-DgroupId=GROUP_ID_OF_YOUR_PROJECT \
-DarchetypeVersion=VERSION_OF_YOUR_PROJECT \
-DpackageName=PACKAGE_NAME

This command generates :

  • a pom file (to update),
  • the src/main/java and src/main/resources folders,
  • the structure of your package name.

The generated project uses iPOJO annotation and is ready to be deployed.

Info
titleMaven Archetype

The maven-ipojo-plugin archetype generates a pom file using the latest released version of the maven-ipojo-plugin.

Describing iPOJO configuration in the pom file

It is also possible to describe iPOJO components and instances inside the pom file (avoiding using a externalized file). The configuration can be described in the metadata attribute inside a CDATA block.

Wiki Markup
{div:class=pom}
<plugin>
&nbsp;&nbsp;	<groupId>org.apache.felix</groupId>
&nbsp;&nbsp;	<artifactId>maven-ipojo-plugin</artifactId>
&nbsp;&nbsp;	<version>1.6.0</version>
&nbsp;&nbsp;	<executions>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;	<execution>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;		<goals>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;			<goal>ipojo-bundle</goal>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;		</goals>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;		<configuration>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;			<ignoreAnnotations>true</ignoreAnnotations>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;			<metadata>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;				<![CDATA[
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;				<ipojo
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;				 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;				 xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/CURRENT/core.xsd"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;				 xmlns="org.apache.felix.ipojo">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;				 <component
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;					classname="org.apache.felix.ipojo.test.scenarios.component.LifecycleControllerTest"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;					name="LFC-Test">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;					<provides />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;					<controller field="m_state" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;					<properties>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;						<property name="conf" field="m_conf" method="setConf" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;					</properties>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;				 </component>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;				 <component
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;					classname="org.apache.felix.ipojo.test.scenarios.component.LifecycleControllerTest"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;					name="LFC-Test-Immediate" immediate="true" architecture="true">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;					<provides />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;					<controller field="m_state" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;					<properties>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;						<property name="conf" field="m_conf" method="setConf" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;					</properties>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;				 </component>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;				</ipojo>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;			   ]]>
&nbsp;&nbsp;&nbsp;			</metadata>
&nbsp;&nbsp;&nbsp;		</configuration>
&nbsp;&nbsp;&nbsp;	</execution>
&nbsp;&nbsp;	</executions>
</plugin>
{div}



Include Page
apache-felix-ipojo-footer
apache-felix-ipojo-footer