From my experience using Karaf 4.2.9 I found the following is needed in POM, or 
inherited POM.  

   </build>
      </pluginManagement>
        </plugins>
          <plugin>
             <groupId>org.apache.karaf.tooling</groupId>
             <artifactId>karaf-services-maven-plugin</artifactId>
             <version>4.2.9</version>
             <executions>
               <execution>
                 <id>service-metadata-generate</id>
                 <phase>process-classes</phase>
                 <goals>
                   <goal>service-metadata-generate</goal>
                 </goals>
               </execution>
             </executions>
          </plugin>
        </plugins>
      </pluginManagement>
   </build>

Section 3.2 of the Karaf documentation, 
http://karaf.apache.org/manual/latest/#_commands, contains the following, but 
nowhere mentions the configuration for the goal service-metadata-generate.  

> However, in Karaf 4.x, you can use DS and new annotations and avoid the usage 
> of a blueprint XML.
> 
> The new annotations are available: @Service, @Completion, @Parsing, 
> @Reference. It allows you to completely define the command in the command 
> class directly.
> 
> To simplify the generation of the code and OSGi headers, Karaf 4.x provides 
> the karaf-services-maven-plugin (in org.apache.karaf.tooling Maven groupId).
> 
> Take a look in the developer guide for the command development "new style" 
> details.

When looking through the examples in the source, you find the configuration in 
the buried in Karaf's root pom, 
https://github.com/apache/karaf/blob/master/pom.xml#L2054

I would expect the following:
- Section on karaf-services-maven-plugin in the Developer section of the Karaf 
documentation
- Reference to karaf-services-maven-plugin in the appropriate example code 
documentation
      https://github.com/apache/karaf/tree/master/examples/karaf-command-example


Paul Spencer


> On Jan 25, 2020, at 1:30 PM, j...@nanthrax.net wrote:
> 
> Hi
> 
> Do you have the karaf service plugin in your pom ?
> It's this plugin which converts annotations to services.
> Take a look on the karaf-command-example.
> 
> Regards
> JB
> 
> Le 25 janv. 2020 18:55, Steinar Bang <s...@dod.no> a écrit :
> What's needed to make karaf pick up a command?
> 
> 
> Is it enough to annotate a class implementing the Action interface and
> annotate it with the @Command and @Service annotations, and then load
> the bundle that contains the class?
> 
> Or are there special considerations to make:
> The class should not reside in a bundle that does other things  commands?
> 
> The package containing the classes should be exported from the bundle?
> 
> The command classes should be mentioned in the manifest?
> 
> Should the command classes be handled specially in the karaf feature file?
> 
> I think at some point this command worked, but it is no longer available
> even when the bundle that contains the command is loaded:
> https://github.com/steinarb/ukelonn/blob/master/ukelonn.backend/src/main/java/no/priv/bang/ukelonn/backend/KarafRele
> aseLiquibaseLockCommand.java#L30
> 
> Can anyone spot what might be wrong? (I haven't done anything special
> except for adding the class to a bundle that is loaded by a feature and
> start a DS component)
> 
> Thanks!
> 

Reply via email to