Bug 392764 - Add support for declarative service annotations
Summary: Add support for declarative service annotations
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Tycho (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-24 11:08 EDT by Holger Staudacher CLA
Modified: 2021-04-28 16:54 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Holger Staudacher CLA 2012-10-24 11:08:28 EDT
In the OSGi compendium specification (Release 4, Version 4.3) on page 275 annotations are defined as an alternative for the DS XML files. It's made for tools at build time. It should enable tools to create the needed XML files at build time and add manifest headers for the servie components. It would be very cool if tycho could support this.
Comment 1 Jan Sievers CLA 2012-10-24 16:11:07 EDT
I wonder how this should work with PDE.
AFAIK PDE expects DS descriptors to be there as sources, not generated.
Comment 2 Jan Sievers CLA 2012-10-26 17:55:14 EDT
looks like there is a maven plugin available already that could simply be configured in a tycho build:

http://stackoverflow.com/a/9560819/457089

it seems it also has m2eclipse integration so that descriptor generation during incremental build should also work.

Need to try this out on an example though.
Comment 3 Jan Sievers CLA 2012-10-30 14:49:54 EDT
the carrot maven plugin looks OK but during my tests I found that unfortunately it only works with a patched version of the original OSGi annotations:

https://github.com/carrot-garden/carrot-maven/issues/2
Comment 4 Jan Sievers CLA 2013-02-25 03:09:36 EST
issue https://github.com/carrot-garden/carrot-maven/issues/2 was fixed so we shoudl give it another try
Comment 5 Jan Sievers CLA 2013-06-24 05:10:51 EDT
(In reply to comment #4)
> issue https://github.com/carrot-garden/carrot-maven/issues/2 was fixed so we
> shoudl give it another try

the carrot-maven plugin still doesn't work for me.

https://github.com/ecliptical/ds-annotations

reportedly works for PDE UI so may be a candidate to integrate into tycho.
Comment 6 Jan Sievers CLA 2014-06-05 03:36:02 EDT
see also corresponding PDE bug 376950
Comment 7 Konrad Windszus CLA 2016-10-30 03:50:16 EDT
The PDE bug (bug 376950) has been resolved with Neon. Unfortunately that functionality has to be enabled explicitly: https://www.eclipse.org/eclipse/news/4.6/pde.php#ds-annotations. Therefore it would be nice to enforce this through some tycho plugin configuration flag. The should enforce that
1. Neon is used for the build
2. The according setting is enabled on the project
Otherwise it should fail the build (in case the flag is set to true).
Comment 8 Konrad Windszus CLA 2017-04-12 10:39:39 EDT
Using the bnd-maven-plugin together with the maven-resources-plugin works within Tycho already. This is how the pom.xml looks like

<plugin>
                <!-- used for generating SCR descriptors in the Maven Build, supports M2E Incremental builds as well -->
                <groupId>biz.aQute.bnd</groupId>
                <artifactId>bnd-maven-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>bnd-process</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <!-- copy the OSGI-INF directory to a place where it is being detected and picked up by PDE Launcher as well, supported by M2E in incremental builds natively  -->
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.0.2</version>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <!-- here the phase you need -->
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/OSGI-INF</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${project.build.outputDirectory}/OSGI-INF</directory>
                                    <filtering>false</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

So with the workaround it works. Maybe it is worth documenting that as long as Tycho does not natively support those annotations.
Comment 9 Jan Sievers CLA 2017-04-18 04:31:59 EDT
> So with the workaround it works. Maybe it is worth documenting that as long
> as Tycho does not natively support those annotations.

https://wiki.eclipse.org/Tycho/FAQ#How_to_use_OSGi_declarative_service_annotations
Comment 10 Mickael Istria CLA 2021-04-08 18:12:02 EDT
Eclipse Tycho is moving away from this bugs.eclipse.org issue tracker to https://github.com/eclipse/tycho/issues/ instead. If this issue is relevant to you, your action is required.
0. Verify this issue is still happening with latest Tycho 2.4.0-SNAPSHOT
  if issue has disappeared, please change status of this issue to "CLOSED WORKFORME" with some details about your testing environment and how you did verify the issue; and you're done
  if issue is still present when latest release:
* Create a new issue at https://github.com/eclipse/tycho/issues/
  ** Use as title in GitHub the title of this Bugzilla ticket (may include the bug number or not, at your own convenience)
  ** In the GitHub description, start with a link to this bugzilla ticket
  ** Optionally add new content to the description if it can helps towards resolution
  ** Submit GitHub issue
* Update bugzilla ticket
  ** Add to "See also" property (up right column) the link to the newly created GitHub issue
  ** Add a comment "Migrated to <link-to-newly-created-GitHub-issue>"
  ** Set status as CLOSED MOVED
  ** Submit

All issues that remain open will be automatically closed next week or so. Then the Bugzilla component for Tycho will be archived and made read-only.