felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Felix > Apache Felix Maven SCR Plugin Use
Date Wed, 11 May 2011 19:12:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=FELIX&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/FELIX/Apache+Felix+Maven+SCR+Plugin+Use">Apache
Felix Maven SCR Plugin Use</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~cziegeler@apache.org">Carsten
Ziegeler</a>
    </h4>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >| {{finalName}} | The name of the
descriptor file to create. This property defaults to the value of the {{scr.descriptor.name}}
property if defined. Otherwise the default is {{serviceComponents.xml}}. | |  <br>|
{{metaTypeName}} | The name of the descriptor file to create. This property defauls to {{metatype.xml}}.
| |  <br></td></tr>
            <tr><td class="diff-changed-lines" >| {{outputDirectory}} | The directory
where all files are generated in. This defaults to <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">${project.build.directory}/scr-plugin-generated.</span>
<span class="diff-added-words"style="background-color: #dfd;">{{scr-plugin-generated}}
inside the build output directory.</span> | | <br></td></tr>
            <tr><td class="diff-unchanged" >The meta type file is generated in
the {{OSGI-INF/metatype/}} directory and the scr descriptor file in the {{OSGI-INF}} directory.
 <br>_Note_: The location of the meta type descriptor may not be changed as the OSGi
Metatype Service Specification prescribes the location of the descriptors.  <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        

<p>Support for automatic generation of the compenent and metadata descriptors is embeded
in the <tt>org.apache.felix:maven-scr-plugin</tt> plugin. To use this plugin,
it has to be declared in the project descriptor as a <tt>&lt;plugin&gt;</tt>
element: </p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"> 
<span class="code-tag">&lt;project&gt;</span>
  ...
  <span class="code-tag">&lt;build&gt;</span>
    ...
    <span class="code-tag">&lt;plugins&gt;</span>
      ...
      <span class="code-tag">&lt;plugin&gt;</span>
        <span class="code-tag">&lt;groupId&gt;</span>org.apache.felix<span
class="code-tag">&lt;/groupId&gt;</span>
        <span class="code-tag">&lt;artifactId&gt;</span>maven-scr-plugin<span
class="code-tag">&lt;/artifactId&gt;</span>
        <span class="code-tag">&lt;executions&gt;</span>
          <span class="code-tag">&lt;execution&gt;</span>
            <span class="code-tag">&lt;id&gt;</span>generate-scr-scrdescriptor<span
class="code-tag">&lt;/id&gt;</span>
            <span class="code-tag">&lt;goals&gt;</span>
              <span class="code-tag">&lt;goal&gt;</span>scr<span class="code-tag">&lt;/goal&gt;</span>
            <span class="code-tag">&lt;/goals&gt;</span>
          <span class="code-tag">&lt;/execution&gt;</span>
        <span class="code-tag">&lt;/executions&gt;</span>
      <span class="code-tag">&lt;/plugin&gt;</span>
      ...
    <span class="code-tag">&lt;/plugins&gt;</span>
    ...
  <span class="code-tag">&lt;/build&gt;</span>
  ...
<span class="code-tag">&lt;/project&gt;</span>
</pre>
</div></div> 

<p>The <tt>scr</tt> goal is bound to the <tt>generate-resources</tt>
phase and will generate a single descriptor file as well as meta type file for all components
found in the project. </p>

<p>The plugin may be configured with the following properties (Check the version column
to make sure you use at least this version for the mentioned feature): </p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<td class='confluenceTd'> <b>Property</b> </td>
<td class='confluenceTd'> <b>Description</b> </td>
<td class='confluenceTd'> <b>Version</b> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>specVersion</tt> </td>
<td class='confluenceTd'> The plugin will generate a descriptor for the Declarative
Service version (either 1.0 or 1.1). If no value is specified, the plugin will detect the
version and only use 1.1 if features from this version are used. </td>
<td class='confluenceTd'> &gt;= 1.4.0 </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>generateAccessors</tt> </td>
<td class='confluenceTd'> If this switch is turned on, the bind and unbind methods for
unary references are automatically generated by the plugin. By default this is set to <tt>true</tt>.
</td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>parseJavadoc</tt> </td>
<td class='confluenceTd'> If this switch is turned on, the java source code and its
javadoc tags are scanned for the scr tags (see below). The default value is <tt>true</tt>.
</td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>processAnnotations</tt> </td>
<td class='confluenceTd'> If this switch is turned on, the java code is scanned for
the scr annotations (see below). The default value is <tt>true</tt>. </td>
<td class='confluenceTd'> &gt;= 1.2.0 </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>sourceExcludes</tt> </td>
<td class='confluenceTd'> Comma separated list of classes to exclude when processing
the source. </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>strictMode</tt> </td>
<td class='confluenceTd'> The plugin distinguishes between errors and warnings. In strict
mode warnings are treated as errors and cause the plugin to fail. The default value is <tt>false</tt>.
</td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>properties</tt> </td>
<td class='confluenceTd'> A map of predefined properties. These properties are set to
each component (if the component does not define the property already). This is a map where
the property name is made up by the included element name and the value is the value of the
element.</td>
<td class='confluenceTd'> &gt;= 1.2.0 </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>finalName</tt> </td>
<td class='confluenceTd'> The name of the descriptor file to create. This property defaults
to the value of the <tt>scr.descriptor.name</tt> property if defined. Otherwise
the default is <tt>serviceComponents.xml</tt>. </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>metaTypeName</tt> </td>
<td class='confluenceTd'> The name of the descriptor file to create. This property defauls
to <tt>metatype.xml</tt>. </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>outputDirectory</tt> </td>
<td class='confluenceTd'> The directory where all files are generated in. This defaults
to <tt>scr-plugin-generated</tt> inside the build output directory. </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
</tbody></table>
</div>

<p>The meta type file is generated in the <tt>OSGI-INF/metatype/</tt> directory
and the scr descriptor file in the <tt>OSGI-INF</tt> directory. <br/>
<em>Note</em>: The location of the meta type descriptor may not be changed as
the OSGi Metatype Service Specification prescribes the location of the descriptors. </p>

<p>The plugin will look for component definition tags in all Java files found in the
source directories of the project. </p>

<h3><a name="ApacheFelixMavenSCRPluginUse-Usingthedescriptor"></a>Using
the descriptor </h3>

<p>Currently the <tt>maven-scr-plugin</tt> only creates the component descriptor
file. Adding the descriptor to the bundle and setting the <tt>Service-Component</tt>
manifest header accordingly is a different task. However, if you're using the <tt>org.apache.felix:maven-bundle-plugin</tt>
to construct the bundle and its manifest, then the <tt>maven-scr-plugin</tt> will
add the following settings automatically for the <tt>org.apache.felix:maven-bundle-plugin</tt>
(given default <tt>maven-scr-plugin</tt> configuration), so you don't have to
configure this yourself: </p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"> 
...
<span class="code-tag">&lt;Include-Resource&gt;</span>
    src/main/resources,
    target/scr-plugin-generated
<span class="code-tag">&lt;/Include-Resource&gt;</span>
<span class="code-tag">&lt;Service-Component&gt;</span>
  OSGI-INF/serviceComponents.xml
<span class="code-tag">&lt;/Service-Component&gt;</span>
...
</pre>
</div></div> 
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/FELIX/Apache+Felix+Maven+SCR+Plugin+Use">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=24183575&revisedVersion=3&originalVersion=2">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/FELIX/Apache+Felix+Maven+SCR+Plugin+Use?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message