You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by nino martinez wael <ni...@gmail.com> on 2018/06/25 07:19:12 UTC

own karaf command, not detected?

Hi im on karaf 4.0.10

And I cannot get karaf to pickup my own command, I have no idea on what are
wrong:

package dk.netdesign.aspt.migrate.command;

import org.apache.karaf.shell.api.action.Action;
import org.apache.karaf.shell.api.action.Argument;
import org.apache.karaf.shell.api.action.Command;
import org.apache.karaf.shell.api.action.Option;
import org.apache.karaf.shell.api.action.lifecycle.Service;

@Command(scope = "asp", name = "migrate", description = "migrates from
filestore to database")
@Service
public class migrate implements Action {

    @Option(name = "-o", aliases = { "--option" }, description = "An
option to the command", required = false, multiValued = false)
    private String option;

    @Argument(name = "argument", description = "Argument to the
command", required = false, multiValued = false)
    private String argument;

    @Override
    public Object execute() throws Exception {
         System.out.println("Executing command migrate");
         System.out.println("Option: " + option);
         System.out.println("Argument: " + argument);
         return null;
    }
}


<plugins>
    <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <configuration>
            <instructions>
                <Import-Package>
                    org.apache.felix.service.command,
                    org.apache.karaf.shell.commands,
                    org.apache.karaf.shell.console,
                    *
                </Import-Package>

<Export-Package>dk.netdesign.aspt.migrate.command</Export-Package>
                <Karaf-Commands>*</Karaf-Commands>
            </instructions>
        </configuration>
    </plugin>
    <plugin>
        <groupId>org.apache.karaf.tooling</groupId>
        <artifactId>karaf-services-maven-plugin</artifactId>
        <version>4.2.0</version>
    </plugin>
</plugins>

[image: image.png]



[image: image.png]


-- 
Best regards / Med venlig hilsen
Nino Martinez

Re: own karaf command, not detected?

Posted by Francois Papon <fr...@openobject.fr>.
Hi,

It's better to name your class with a capitalized to the first character.

Other things, you are on Karaf 4.0.10 but you are using the version
4.2.0 of the karaf-services-maven-plugin.

regards,

François Papon
fpapon@apache.org
Open3m - https://www.open3m.io

Le 25/06/2018 à 11:19, nino martinez wael a écrit :
> Hi im on karaf 4.0.10
>
> And I cannot get karaf to pickup my own command, I have no idea on
> what are wrong:
>
> package dk.netdesign.aspt.migrate.command;
>
> import org.apache.karaf.shell.api.action.Action;
> import org.apache.karaf.shell.api.action.Argument;
> import org.apache.karaf.shell.api.action.Command;
> import org.apache.karaf.shell.api.action.Option;
> import org.apache.karaf.shell.api.action.lifecycle.Service;
>
> @Command(scope = "asp", name = "migrate", description = "migrates from filestore to database")
> @Service public class migrate implements Action {
>
>     @Option(name = "-o", aliases = { "--option" }, description = "An option to the command", required = false, multiValued = false)
>     private String option;
>
>     @Argument(name = "argument", description = "Argument to the command", required = false, multiValued = false)
>     private String argument;
>
>     @Override public Object execute() throws Exception {
>          System.out.println("Executing command migrate");
>          System.out.println("Option: " + option);
>          System.out.println("Argument: " + argument);
>          return null;
>     }
> }
>
> <plugins>
>     <plugin>
>         <groupId>org.apache.felix</groupId>
>         <artifactId>maven-bundle-plugin</artifactId>
>         <configuration>
>             <instructions>
>                 <Import-Package>
>                     org.apache.felix.service.command,
>                     org.apache.karaf.shell.commands,
>                     org.apache.karaf.shell.console,
>                     *
>                 </Import-Package>
>                 <Export-Package>dk.netdesign.aspt.migrate.command</Export-Package>
>                 <Karaf-Commands>*</Karaf-Commands>
>             </instructions>
>         </configuration>
>     </plugin>
>     <plugin>
>         <groupId>org.apache.karaf.tooling</groupId>
>         <artifactId>karaf-services-maven-plugin</artifactId>
>         <version>4.2.0</version>
>     </plugin>
> </plugins>
> image.png
>
>
>
> image.png
>
>
> -- 
> Best regards / Med venlig hilsen 
> Nino Martinez