felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1762308 - /felix/site/trunk/content/documentation/faqs/apache-felix-bundle-plugin-faq.mdtext
Date Mon, 26 Sep 2016 09:55:32 GMT
Author: cziegeler
Date: Mon Sep 26 09:55:32 2016
New Revision: 1762308

URL: http://svn.apache.org/viewvc?rev=1762308&view=rev
Log:
FELIX-5361 : Felix Site: Fix external links to bndtools website. Apply patch from Stefan Seifert

Modified:
    felix/site/trunk/content/documentation/faqs/apache-felix-bundle-plugin-faq.mdtext

Modified: felix/site/trunk/content/documentation/faqs/apache-felix-bundle-plugin-faq.mdtext
URL: http://svn.apache.org/viewvc/felix/site/trunk/content/documentation/faqs/apache-felix-bundle-plugin-faq.mdtext?rev=1762308&r1=1762307&r2=1762308&view=diff
==============================================================================
--- felix/site/trunk/content/documentation/faqs/apache-felix-bundle-plugin-faq.mdtext (original)
+++ felix/site/trunk/content/documentation/faqs/apache-felix-bundle-plugin-faq.mdtext Mon
Sep 26 09:55:32 2016
@@ -104,3 +104,63 @@ Put this in either the JAR or bundle plu
 ## Why do some generated resources (such as Declarative Services XML files) appear in the
final jar, but others don't?
 
 When you use the Service-Component instruction to specify Declarative Services the BND tool
scans the project classpath for components and automatically adds its generated XML to the
final bundle, therefore Include-Resource is not necessary. But if you generate files under
OSGI-INF using another mechanism then they won't end up in the bundle unless you add that
directory using Include-Resource (this goes back to the core design decision that BND pulls
classes and resources into the bundle, rather than just taking everything under target/classes).
We try to provide reasonable defaults on the Maven side in the bundleplugin so local classes
and resources will end up in the bundle without additional configuration, but we do this by
looking at the effective pom and src/ folder rather than the generated target/classes content.
+
+## Use SCR metadata generated by BND in Unit Tests
+
+BND and the maven-bundle-plugin support the generation of SCR metadata for OSGi Declarative
Service components annotated with the OSGi annotations from the Java package `org.osgi.service.component.annotations`.
+
+To enable this you have to set two special instructions in your maven-bundle-plugin configuration:
+
+
+    <configuration>
+      <instructions>
+        <!-- Enable processing of OSGI DS component annotations -->
+        <_dsannotations>*</_dsannotations>
+        <!-- Enable processing of OSGI metatype annotations -->
+        <_metatypeannotations>*</_metatypeannotations>
+      </instructions>
+    </configuration>
+
+
+This generates the SCR metadata files at `/OSGI-INF` and `/OSGI-INF/metatype` when building
the JAR file.
+
+If you want to run unit test in the same maven projects that need these SCR metadata files
when running the tests (e.g. when using [OSGi Mocks](http://sling.apache.org/documentation/development/osgi-mock.html))
you need some special configurations to ensure the SCR metadata is also generated in the filesystem
in the maven target folder, and is already available when the unit tests are executed and
not only in the package phase:
+
+
+    <plugin>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>maven-bundle-plugin</artifactId>
+      <extensions>true</extensions>
+      <executions>
+        <!-- Configure extra execution of 'manifest' in process-classes phase to make
sure SCR metadata is generated before unit test runs -->
+        <execution>
+          <id>scr-metadata</id>
+          <goals>
+            <goal>manifest</goal>
+          </goals>
+          <configuration>
+            <supportIncrementalBuild>true</supportIncrementalBuild>
+          </configuration>
+        </execution>
+      </executions>
+      <configuration>
+        <exportScr>true</exportScr>
+        <instructions>
+          <!-- Enable processing of OSGI DS component annotations -->
+          <_dsannotations>*</_dsannotations>
+          <!-- Enable processing of OSGI metatype annotations -->
+          <_metatypeannotations>*</_metatypeannotations>
+        </instructions>
+      </configuration>
+    </plugin>
+
+
+The flag `supportIncrementalBuild` is only necessary when you are using Eclipse and m2e,
it supports generating the appropriate metadata during incremental builds. When you also want
to support the old-style Felix SCR annotations from Java package `org.apache.felix.scr.annotations`
you can add this BND plugin:
+
+
+    <configuration>
+      <instructions>
+        <!-- Support parsing of maven-scr-plugin annotations through the felix.scr.bnd
plugin -->
+        <_plugin>org.apache.felix.scrplugin.bnd.SCRDescriptorBndPlugin;destdir=${project.build.outputDirectory};</_plugin>
+      </instructions>
+    </configuration>



Mime
View raw message