Generating OSGi SCR metadata with bnd-maven-plugin

Description

Hi,

I just generated a new AEM project using archetype 23 and now Adobe uses bnd-maven-plugin instead of the old maven-bundle-plugin.

I am getting an exception org.apache.sling.testing.mock.osgi.NoScrMetadataException: No OSGi SCR metadata found for class java.lang.Class when trying to run tests.

Now, I know how to resolve this one by configuring maven-bundle-plugin as explained here: https://felix.apache.org/documentation/faqs/apache-felix-bundle-plugin-faq.html#use-scr-metadata-generated-by-bnd-in-unit-tests

Is there a similar configuration available for bnd-maven-plugin in order to fix this?

 

Thanks,
Daniel

Activity

Show:
Masoud Rozati
June 15, 2020, 10:02 AM

I think this article describes your problem and its solution:

Stefan Seifert
June 15, 2020, 11:48 AM

we've published a migration guide from maven-bundle-plugin to bnd-maven-plugin mainly for projects set up with the wcm.io AEM project archetype: https://wcm-io.atlassian.net/wiki/x/BICFSw

however, running AEM Mocks-based unit tests with bnd-maven-plugin should work quite "out of the box" with both the adobe and the wcm.io project archetype. do you encounter your problem on the command line or in a specific IDE?

Daniel Strmecki
June 16, 2020, 11:55 AM
Edited

Thanks @Masoud but that solution is for the old plugin.

@Stefan I encounter this problem both in console (maven build) and IDE (InteliJ). However I found one internal project where this works, so I will compare and let you know the results. It must be either different versions, my mistake or something in the archetype.

Daniel Strmecki
June 20, 2020, 8:13 AM
Edited

Of course Stephan is correct, it works OOTB with BND. I had a mistake in my code on line 3, as registerInjectActivateService does not take class as first argument, but it does take variable number of arguments, so you end up with code that compiles and a misleading exception.

The issue can be closed, not sure if you want to update the API to cover this.

Stefan Seifert
June 23, 2020, 7:04 AM

good to hear, closing the ticket

Done

Assignee

Unassigned

Reporter

Daniel Strmecki

Labels

None

Components

Affects versions

Priority

Blocker
Configure