Yes, I agree, fair enough. I will update the documentation.
Regards JB > Le 13 juil. 2020 à 19:55, Paul Spencer <[email protected]> a écrit : > > JB, > I was expecting this. > > The use of an Activator in bundle that uses karaf-services-maven-plugin is > not discussed in the documenting or JavaDoc. I recommend adding a warning > along the lines of "The use of an Activator is not recommend when > karaf-services-maven-plugin is used." where ever karaf-services-maven-plugin, > org.apache.karaf.shell.api.action.Action, or the BaseActivator is documented. > > Paul Spencer > > >> On Jul 13, 2020, at 12:27 PM, Jean-Baptiste Onofre <[email protected]> wrote: >> >> I understand now, you are mixing BaseActivator and >> karaf-services-maven-plugin. >> >> If you use Karaf-services-maven-plugin, you should not use the Activator for >> command (only for services, tracker, etc). >> >> Regards >> JB >> >>> Le 13 juil. 2020 à 14:56, Paul Spencer <[email protected]> a écrit >>> : >>> >>> JB, >>> >>> >>>> On Jul 13, 2020, at 12:40 AM, Jean-Baptiste Onofre <[email protected]> >>>> wrote: >>>> >>>> Hi Paul, >>>> >>>> Not sure I fully understand what you mean, but ignoring Activator from a >>>> command perspective is by design. >>> >>> You say Activators are ignored by design, so why are services treated >>> differently? >>> >>>> >>>> The plugin scans for any packages part of the bundle (export or private, >>>> but not import). In your case, if foo is imported, it’s not scanned as it >>>> will register its own commands by its own (it’s to avoid to have some >>>> commands register by several bundles). >>> >>> How do I mark foo as imported? >>> >>>> If foo is private to "bar", then, commands will be scanned and added. >>>> >>>> Regards >>>> JB >>>> >>> >>> Paul Spencer >>> >>>>> Le 13 juil. 2020 à 00:42, Paul Spencer <[email protected]> a >>>>> écrit : >>>>> >>>>> Karaf 4.2.9 >>>>> >>>>> I have a bundle "bar" with commands declared with @Service. The bundle >>>>> has dependency on "foo" which also containing commands declared using >>>>> @Service. Commands from "bar" and "foo" are included in the >>>>> "Karaf-Commands" of MANIFEST.MF >>>>> >>>>> Looking at the karaf-services-maven-plugin, specifically >>>>> GenerateServieMetaData.java, I see where Activators not in the output >>>>> class path are ignored. There is not such check for services. >>>>> >>>>> Identification of Bundle Activators defined in dependency are ignored, >>>>> but Services are not. Is this a bug in the karaf-services-maven-plugin? >>>>> >>>>> *** >>>>> * MANIFEST.MF >>>>> *** >>>>> From Karaf-Commands = com.foo.internal,com.bar.internal.commands >>>>> >>>>> *** >>>>> * From the Maven Build >>>>> *** >>>>> [INFO] --- karaf-services-maven-plugin:4.2.9:service-metadata-generate >>>>> (service-metadata-generate) @ ewm-tpm-server --- >>>>> [INFO] Ignoring >>>>> jar:file:/Users/paul/.m2/repository/com/foo/2.0.0-SNAPSHOT/foo-2.0.0-SNAPSHOT.jar!/com/foo/internal/Activator.class >>>>> [INFO] Service com.foo.internal.JobsListCommand >>>>> [INFO] Service com.foo.internal.JobResumeCommand >>>>> [INFO] Service com.foo.internal.JobPauseCommand >>>>> [INFO] Service com.bar.internal.commands.AddCommand >>>>> [INFO] Service com.bar.internal.commands.StatusCommand >>>>> [INFO] Service com.bar.internal.commands.UpdateCommand >>>>> [INFO] Service com.bar.internal.commands.ListCommand >>>>> >>>>> >>>>> *** >>>>> * org.apache.karaf.tooling.tracker.GenerateServieMetaData >>>>> * >>>>> https://github.com/apache/karaf/blob/master/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java >>>>> *** >>>>> URL classUrl = >>>>> clazz.getClassLoader().getResource(clazz.getName().replace('.', '/') + >>>>> ".class"); >>>>> URL outputDirectoryUrl = new >>>>> File(project.getBuild().getOutputDirectory()).toURI().toURL(); >>>>> if (classUrl == null || >>>>> !classUrl.getPath().startsWith(outputDirectoryUrl.getPath())) { >>>>> getLog().info("Ignoring " + classUrl); >>>>> continue; >>>>> } >>>>> ... >>>>> >>>>> for (Class<?> clazz : services) { >>>>> getLog().info("Service " + clazz.getCanonicalName()); >>>>> packages.add(clazz.getPackage().getName()); >>>>> } >>>>> >>>>> >>>>> Paul Spencer >>>>> >>>>> >>>>> >>>> >>> >> >
