How to configure OSGI in IntelliJ when it is processed by Maven

I am an OSBI newb.

I really can use any guidance I can get regarding IntelliJ IDEA / OSGI / Maven / Sling.

So, the actual Felix plugin dies when I download it. Apparently, it was not saved and is no longer compatible with the latest version, by which I mean IntelliJ IDEA 13.

So, I set up the framework for felix-framework-4.2.1 and it seems to work fine. My biggest concern is that if I applied the OSGI facet to a package, the settings seem to indicate that it will change the package. Since we have it installed in Maven, I don’t think we want it. The facet source is the Osmorc plugin. When I used this before, there were complaints about some packages in maven that were not included in OSGI, and the IDE wanted to point to a special Spring repository for jar-dependent OSGI dependencies.

Since we are doing this at Maven, should I even worry about Osmorc? Is there a better way to manage OSGI in IntelliJ IDEA? It’s convenient to know which OSGI packages are included, but an error for this? Indeed? In particular, I mean, "the package is not exported by bundle dependencies," showing import and annotations.

+6
source share
2 answers

My personal observation with Intellij IDEA 13 is that the OSGI project inspector is a bit more aggressive when it comes to profiling your classes that use osgi non-exportable classes. The way around this is to adjust the inspector's level of severity. This allows you to use the same OSGI-based approach that you used in Intellij IDEA 12.

To do this, go to your project settings (on Mac: Command + , ), and then go to the next node:

Inspections --> OSGI --> Package accessibility 

Once selected, you can change the severity level from error to warning.

Making this change is necessary for a few changes in your pom.xml:

 <dependencies> . . <dependency> <groupId>com.pkg.name</groupId> <artifactId>some-non-osgi-artifact</artifactId> <version>0.1-EXAMPLE</version> </dependency> </dependencies> <build> <plugins> . . <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <version>${maven-bundle-plugin.version}</version> <extensions>true</extensions> <configuration> <instructions> <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> <Bundle-Version>${project.version}</Bundle-Version> <Export-Package> you.know.what.goes.here </Export-Package> <Private-Package>you.know.what.goes.here</Private-Package> <Import-Package> * </Import-Package> <Embed-Dependency>some-non-osgi-artifact;scope=compile|runtime;inline=false</Embed-Dependency> <Embed-Transitive>true</Embed-Transitive> <Embed-StripGroup>true</Embed-StripGroup> </instructions> </configuration> </plugin> </plugins> </build> 

Hope this helps, Ajay

+14
source

I think your best bet right now is to use the maven bundle plugin to control import and export. This means that intellij will just see your packages as maven projects. However, there must be the right banks. I process OSGi packages the same way in eclipse and it works great.

I also read on the OSGi dev mailing list that there are bndtools for intellij, but this will probably take some time.

+1
source

All Articles