>>>>> Jean-Baptiste Onofré <[email protected]>:
> Hi Jared,
> you can start karaf in debug mode:
> bin/karaf debug
> Then you can plug Eclipse debugger using port 5005 (default).
> You can directly deploy your bundle from eclipse in Karaf.
> So basically, you have a Karaf instance running, executing your eclipse
> bundle. You can rebuild your bundle in eclipse and then just do a
> bundle:update in Karaf. You will have basically the same as you have today.
Here's what I do:
1. Start karaf in debug mode like JB showed above
2. Connect eclipse remote debugging to port 5005
3. Build the application that is to be debugged with "mvn clean install"
to ensure that a SNAPSHOT version of my application is in the local
maven repository, eg. like so:
git clone https://github.com/steinarb/frontend-karaf-demo.git
cd frontend-karaf-demo.git
mvn clean install
3. From the karaf console:
a. Add the feature repository
feature:repo-add
mvn:no.priv.bang.demos/frontend-karaf-demo/LATEST/xml/features
b. Install the feature from the repository that will pull in the
application as well as all required run time dependencies:
feature:install frontend-karaf-demo
c. Make karaf watch for new SNAPSHOT versions in the local maven
repository:
bundle:watch *
After this, every time you build your bundle(s) with maven, karaf will
reload them from the new SNAPSHOT versions in the local repository.
You can either do the maven build from an eclipse run configuration, or
from a command line. When debugging I try to make the builds as brief
as possible, so I usually do something like this, in the pom.xml
directory of just the bundle I'm debugging:
mvn install -DskipTests=true -Dmaven.javadoc.skip=true -DskipSource=true
I add a "clean" to that command if I've moved or renamed or deleted
something. You can skip source attachments, since eclipse will pick up
the source from the bundle project.
See this blog post for some further reading:
https://steinar.bang.priv.no/2018/02/10/develop-osgi-applications-using-karaf/