own karaf command, not detected?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

own karaf command, not detected?

nino martinez wael
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
Reply | Threaded
Open this post in threaded view
|

Re: own karaf command, not detected?

fpapon

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
[hidden email]
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

François Papon
fpapon@apache.org
Yupiik - https://www.yupiik.com