...
How to use the iPOJO Maven Plug-in
Div | ||||||
---|---|---|---|---|---|---|
| ||||||
| ||||||
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):
Div | ||
---|---|---|
| ||
<project> | ||
Wiki Markup | ||
{div:class=pom}
<project>
<modelVersion>4 .0.0</modelVersion> <packaging>bundle<<packaging>bundle</packaging> <!-- Use the BND Maven plug-in --> {color:red} {color} {color:red}
|
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:
<dependencies> <build> |
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:
Div | ||
---|---|---|
| ||
[INFO] Scanning for projects... | ||
Wiki Markup | ||
{div:class=pom}
\[INFO\] Scanning for projects...
\[INFO\] \------ --------------------------------------------------------------------- \-- \
] BUILD SUCCESSFUL
|
Configuration Options
You can configure the localization of the iPOJO metadata file as following:
Wiki Markup |
---|
{div:class=pom}
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-ipojo-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<goals>
<goal>ipojo-bundle</goal>
</goals>
<configuration>
{color:red}<metadata>ipojo/meta.xml</metadata>{color}
</configuration>
</execution>
</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>
<groupId>org.apache.felix</groupId>
<artifactId>maven-ipojo-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<goals>
<goal>ipojo-bundle</goal>
</goals>
<configuration>
{color:red}<ignoreAnnotations>true</ignoreAnnotations>{color}
</configuration>
</execution>
</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>
<groupId>org.apache.felix</groupId>
<artifactId>maven-ipojo-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<goals>
<goal>ipojo-bundle</goal>
</goals>
<configuration>
{color:red}<ignoreEmbeddedSchemas>true</ignoreEmbeddedSchemas>{color}
</configuration>
</execution>
</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 | ||
---|---|---|
| ||
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.
] Total time: 9 seconds |
Configuration Options
You can configure the localization of the iPOJO metadata file as following:
Div | ||
---|---|---|
| ||
<plugin> |
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:
Div | ||
---|---|---|
| ||
<plugin> |
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:
Div | ||
---|---|---|
| ||
<plugin> |
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 | ||
---|---|---|
| ||
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.
Div | ||
---|---|---|
| ||
<plugin> | ||
Wiki Markup | ||
{div:class=pom}
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-ipojo-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<goals>
<goal>ipojo-bundle</goal>
</goals>
<configuration>
<ignoreAnnotations>true</ignoreAnnotations>
<metadata>
<![CDATA[
<ipojo
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
http://felix.apache.org/ipojo/schemas/CURRENT/core .xsd" .xsd"
/> field="m_conf" method="setConf" /> </properties> </component> <component /> " immediate="true" architecture="true"> <provides /> <controller
/> field="m_conf" method="setConf" /> </properties> </component> </ipojo> ]]> </metadata> </configuration> </execution> </executions> </plugin> {div}/> |
Include Page | ||||
---|---|---|---|---|
|