bndtools / bnd

Bnd/Bndtools. Tooling to build OSGi bundles including Eclipse, Maven, and Gradle plugins.
https://bndtools.org
Other
531 stars 304 forks source link

Warning "Unable to determine whether the annotation .. applied to type ... is a component property type as it is not on the project build path." for dependencies #2905

Closed kwin closed 5 years ago

kwin commented 5 years ago

With bnd 4.1 (used together with maven-bundle-plugin) I see the following warnings when building https://github.com/Adobe-Consulting-Services/acs-aem-commons/:

[WARNING] Manifest com.adobe.acs:acs-aem-commons-bundle:bundle:3.19.1-SNAPSHOT : Unable to determine whether the annotation org.apache.felix.scr.annotations.Component applied to type com.day.cq.wcm.core.contentfinder.ContentFinderListInfoProviderHelper is a component property type as it is not on the project build path. If this annotation is a component property type then it must be present on the build path in order to be processed
[WARNING] Manifest com.adobe.acs:acs-aem-commons-bundle:bundle:3.19.1-SNAPSHOT : Unable to determine whether the annotation org.apache.felix.scr.annotations.Reference applied to type com.day.cq.wcm.core.contentfinder.ContentFinderListInfoProviderHelper is a component property type as it is not on the project build path. If this annotation is a component property type then it must be present on the build path in order to be processed
[WARNING] Manifest com.adobe.acs:acs-aem-commons-bundle:bundle:3.19.1-SNAPSHOT : Unable to determine whether the annotation org.apache.felix.scr.annotations.Reference applied to type com.day.cq.commons.servlets.AbstractPredicateServlet is a component property type as it is not on the project build path. If this annotation is a component property type then it must be present on the build path in order to be processed
[WARNING] Manifest com.adobe.acs:acs-aem-commons-bundle:bundle:3.19.1-SNAPSHOT : Unable to determine whether the annotation org.apache.felix.scr.annotations.Component applied to type com.day.cq.commons.servlets.AbstractPredicateServlet is a component property type as it is not on the project build path. If this annotation is a component property type then it must be present on the build path in order to be processed
[WARNING] Manifest com.adobe.acs:acs-aem-commons-bundle:bundle:3.19.1-SNAPSHOT : Unable to determine whether the annotation org.apache.felix.scr.annotations.Activate applied to type com.adobe.cq.dialogconversion.AbstractDialogRewriteRule is a component property type as it is not on the project build path. If this annotation is a component property type then it must be present on the build path in order to be processed
[WARNING] Manifest com.adobe.acs:acs-aem-commons-bundle:bundle:3.19.1-SNAPSHOT : Unable to determine whether the annotation org.apache.felix.scr.annotations.Component applied to type com.adobe.cq.dialogconversion.AbstractDialogRewriteRule is a component property type as it is not on the project build path. If this annotation is a component property type then it must be present on the build path in order to be processed
[WARNING] Manifest com.adobe.acs:acs-aem-commons-bundle:bundle:3.19.1-SNAPSHOT : Unable to determine whether the annotation org.apache.felix.scr.annotations.Component applied to type com.day.cq.wcm.workflow.process.ActivatePageProcess is a component property type as it is not on the project build path. If this annotation is a component property type then it must be present on the build path in order to be processed
[WARNING] Manifest com.adobe.acs:acs-aem-commons-bundle:bundle:3.19.1-SNAPSHOT : Unable to determine whether the annotation org.apache.felix.scr.annotations.Service applied to type com.day.cq.wcm.workflow.process.ActivatePageProcess is a component property type as it is not on the project build path. If this annotation is a component property type then it must be present on the build path in order to be processed
[WARNING] Manifest com.adobe.acs:acs-aem-commons-bundle:bundle:3.19.1-SNAPSHOT : Unable to determine whether the annotation org.apache.felix.scr.annotations.Property applied to type com.day.cq.wcm.workflow.process.ActivatePageProcess is a component property type as it is not on the project build path. If this annotation is a component property type then it must be present on the build path in order to be processed
[WARNING] Manifest com.adobe.acs:acs-aem-commons-bundle:bundle:3.19.1-SNAPSHOT : Unable to determine whether the annotation org.apache.felix.scr.annotations.Reference applied to type com.day.cq.wcm.workflow.process.ReplicatePageProcess is a component property type as it is not on the project build path. If this annotation is a component property type then it must be present on the build path in order to be processed
[WARNING] Manifest com.adobe.acs:acs-aem-commons-bundle:bundle:3.19.1-SNAPSHOT : Unable to determine whether the annotation org.apache.felix.scr.annotations.Component applied to type com.day.cq.wcm.workflow.process.ReplicatePageProcess is a component property type as it is not on the project build path. If this annotation is a component property type then it must be present on the build path in order to be processed
[WARNING] Manifest com.adobe.acs:acs-aem-commons-bundle:bundle:3.19.1-SNAPSHOT : Unable to determine whether the annotation org.apache.felix.scr.annotations.Component applied to type com.day.cq.wcm.workflow.process.DeactivatePageProcess is a component property type as it is not on the project build path. If this annotation is a component property type then it must be present on the build path in order to be processed
[WARNING] Manifest com.adobe.acs:acs-aem-commons-bundle:bundle:3.19.1-SNAPSHOT : Unable to determine whether the annotation org.apache.felix.scr.annotations.Service applied to type com.day.cq.wcm.workflow.process.DeactivatePageProcess is a component property type as it is not on the project build path. If this annotation is a component property type then it must be present on the build path in order to be processed
[WARNING] Manifest com.adobe.acs:acs-aem-commons-bundle:bundle:3.19.1-SNAPSHOT : Unable to determine whether the annotation org.apache.felix.scr.annotations.Property applied to type com.day.cq.wcm.workflow.process.DeactivatePageProcess is a component property type as it is not on the project build path. If this annotation is a component property type then it must be present on the build path in order to be processed

The warnings are issued for classes which are dependencies and not classes in the target directory. IMHO those dependencies are not worth to be evaluated for component property types as you never generate metadata for those. Therefore the WARNINGs should IMHO be prevented.

timothyjward commented 5 years ago

These warnings are valid, and important information that is being provided to you.

The warnings are issued for classes which are dependencies and not classes in the target directory.

In this case the bundle being built is embedding classes from other jars/bundles on the class path, as configured in the bundle pom file. If the classes end up in the bundle then they need to be scanned and processed by bnd, regardless of where they came from. You would rightly be upset if bnd ignored the dependencies added by the embedded code!

These embedded classes are annotated with annotations that make them relevant for Declarative Services metadata generation, and so the annotation hierarchy needs to be checked. Unfortunately the annotations themselves are not on the build path (which is what the warning is complaining about). In this case bnd needs the information to do its job properly (i.e. to create the relevant DS metadata for these components.

Therefore this project needs to either:

Note that the latter option will result in no Declarative Services XML descriptors being generated for those types, which may, or may not, be a problem for you, depending on whether the bundle being built expects the components it embeds to be used as components.

kwin commented 5 years ago

@timothyjward Thanks a lot for your answer, but actually the class com.day.cq.wcm.core.contentfinder.ContentFinderListInfoProviderHelper is not embedded in the JAR. Compare with the attached screenshot: screenshot 2019-02-01 at 11 50 38

Still it appears in the WARNING!

kwin commented 5 years ago

At least for ActivatePageProcess I found the reason: There is a component in https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/a4ad6c31263588286cb5380a3919675a64707e1c/bundle/src/main/java/com/adobe/acs/commons/workflow/process/impl/ParameterizedActivatePageProcess.java#L38 which extends from it. Can we bring bnd somehow to not evaluate the parent classes for annotations?

timothyjward commented 5 years ago

Can we bring bnd somehow to not evaluate the parent classes for annotations?

Not scanning parent classes is the default behaviour for bnd, however this project has deliberately enabled scanning of parent classes. https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/84f76f7faccca34062008ea61499e2dd201c7a90/bundle/pom.xml#L79

kwin commented 5 years ago

Thanks a lot again, indeed after disabling inheritance all those warnings disappeared.

marad commented 4 years ago

Add the necessary annotations to the build path so that bnd can do its job

@timothyjward Hi, how can I add the annotations to the build path? I'm using gradle with biz.aQute.bnd.workspace and biz.aQute.bnd plugins and I've tried to set my dependencies to implementation, compileOnly and runtimeOnly but my warnings persist.

rotty3000 commented 4 years ago

@marad IIUC and you are using biz.aQute.bnd.workspace then you should not use gradle dependency management but rather bnd's workspace dependency management which would have you:

a) make sure the dependency is referred to by one of the bnd repositories (look in cnf dir for those typically) b) refer to the dependency from the project's bnd.bnd file on the -buildpath instruction

Pointing at the repository in question might make it easier for us to point out the issue.

marad commented 4 years ago

@rotty3000 Thanks for such a quick answer! I'm very new to OSGi and bndtools. I'm learning and trying to piece all the knowledge and tools together. Maybe it would help to just link the repository: https://github.com/marad/personal-sidecar (the subproject that gives me most of those errors is obsidian-startpage)

I'm building it with ./gradlew build, but I'm not sure if I should use that or the bnd tool to build the workspace?

bjhargrave commented 4 years ago

I'm very new to OSGi and bndtools.

It would be better to move usage questions to the bndtools-users mail list. See https://github.com/bndtools/bnd#feedback.