felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konrad Windszus <konra...@gmx.de>
Subject Re: Future of maven-scr-plugin
Date Fri, 09 Oct 2015 16:14:09 GMT
I experimented a bit and using something like this in my pom.xml works pretty well.

<plugin>
  <groupId>org.apache.felix</groupId>
  <artifactId>maven-bundle-plugin</artifactId>
  <version>3.0.0</version>
  <extensions>true</extensions>
  <configuration>
    <instructions>
      <!-- enable processing of default OSGI component annotations (since OSGi 5) -->
      <_dsannotations>*</_dsannotations>
      <!-- support inheritance on components -->
      <_dsannotations-inherit>true</_dsannotations-inherit>
      <!-- enable processing of default OSGI metatype annotations (since OSGi 6) -->
      <_metatypeannotations>*</_metatypeannotations>
      <!-- support parsing of maven-scr-plugin annotations through the felix.scr.bnd plugin
-->
      <_plugin>org.apache.felix.scrplugin.bnd.SCRDescriptorBndPlugin;destdir=target/classes</_plugin>
    </instructions>
 </configuration>
 <dependencies>
   <!-- https://github.com/apache/felix/tree/trunk/tools/org.apache.felix.scr.bnd -->
   <dependency>
      <groupId>org.apache.felix</groupId>
      <artifactId>org.apache.felix.scr.bnd</artifactId>
      <version>1.4.0</version>
    </dependency>
  </dependencies>
</plugin>

But while migrating from Felix SCR annotations to official OSGi annotations I just came across
another issue: 
Bnd in contrast to maven-scr-plugin will not generate bind methods for fields annotated with
@Reference (although @Reference is being allowed in fields since OSGi DS 1.3). I opened a
bug on that at https://github.com/bndtools/bnd/issues/1148. Maybe someone can comment on whether
that is a bug in Bnd or the DS Plugin in Bnd was never supposed to modify existing class files
(to add the bind method). That is not clear from the spec (at least to me).
This feature would be an important difference to the maven-scr-plugin as writing those bind
methods manually is a lot more verbose…
Konrad


> On 07 Oct 2015, at 18:33, Konrad Windszus <konrad_w@gmx.de> wrote:
> 
> Hi Carsten, 
> thanks for your answer. One other thing to mention here is that custom plugins exist
for the maven-scr-plugin (http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin/extending-scr-annotations.html
<http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin/extending-scr-annotations.html>).
> Could those be easily migrated to bnd plugins? Do you have any hints on how to accomplish
that for @SlingServlet, @SlingFilter (currently part of maven-scr-plugin, but should be moved
to a Sling module then) and for @SlingHealthCheck (https://github.com/apache/sling/blob/trunk/bundles/extensions/healthcheck/annotations/src/main/java/org/apache/sling/hc/annotations/SlingHealthCheckProcessor.java
<https://github.com/apache/sling/blob/trunk/bundles/extensions/healthcheck/annotations/src/main/java/org/apache/sling/hc/annotations/SlingHealthCheckProcessor.java>)?
> Thanks
> Konrad
> 
>> On 07 Oct 2015, at 18:18, Carsten Ziegeler <cziegeler@apache.org> wrote:
>> 
>> Hi
>> 
>> Am 07.10.15 um 21:07 schrieb Konrad Windszus:
>>> Hi,
>>> I am wondering about the future of the maven-scr-plugin. I think it should be
deprecated and instead the documentation should point to the maven-bundle-plugin to be used
now even for generating descriptors for metatype and declarative services.
>>> 
>>> That can nowadays take care of generating the component descriptor [0] with the
OSGi standard annotations [1]. For the metatype generation bnd came up with its own annotations[3],
which should be a replacement for all maven-scr-plugin annotations.
>> Actually there are standard metatype annotations as well which work
>> nicely with the new R6 DS annotations. So no need to use proprietary
>> annotations anymore
>> 
>>> Also it seems that maven-scr-plugin is not compatible with Declarative Services
1.3 (meaning I cannot use "Configuration Property Types”) [3].
>> It only supports DS upto 1.2
>> 
>>> 
>>> The only thing which is not covered in the maven-bundle-plugin is component inheritance
(but that is deprecated anyways [4]).
>> That's why we deprecated it :)
>> 
>>> Are there any other feature of the maven-scr-plugin which are not covered by
bnd/maven-bundle-plugin?
>> Nearly none - we have default properties in the scr plugin, so you can
>> configure something like the vendor once in your parent pom and it gets
>> applied to every component.
>> 
>> The plan is to indeed phase out the maven scr plugin. It still has some
>> usage, as the bundle plugin is not a dropin replacement. You would need
>> to rewrite your components - and switching to the official annotations
>> has some subtle differences in the defaults.
>> On the other hand, we have a bnd plugin that is able to process the
>> proprietary Felix annotations.
>> 
>> Therefore, I totally agree that we should update the documentation. But
>> of course we have to support our user base for some time.
>> 
>> Carsten
>> 
>>> 
>>> My request originates from the discussion at https://github.com/bndtools/bnd/issues/999.
>>> 
>>> WDYT?
>>> Thanks for any input,
>>> Konrad
>>> 
>>> 
>>> [0] - http://www.aqute.biz/Bnd/Components
>>> [1] - https://osgi.org/javadoc/r6/enterprise/org/osgi/service/component/annotations/package-summary.html
>>> [2] - http://www.aqute.biz/Bnd/MetaType
>>> [3] - http://njbartlett.name/2015/08/17/osgir6-declarative-services.html
>>> [4] - https://issues.apache.org/jira/browse/FELIX-4170
>>> 
>>> 
>> 
>> 
>> -- 
>> Carsten Ziegeler
>> Adobe Research Switzerland
>> cziegeler@apache.org
> 


Mime
View raw message