You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Oliver Pajonk <ol...@pjnk.de> on 2014/10/17 20:39:20 UTC

Best practice question: development cycle for a bundle

Hi all,

following up on the latest issue with bundle:watch I have a related
question. I am using the "standard" (as in documented here
<http://karaf.apache.org/manual/latest/developers-guide/custom-distribution.html>)
way to construct a Karaf instance which would run my feature (and a few
related ones). Both feature and distribution are created with
the karaf-maven-plugin, so all bundles get installed into the system
repository to make a self-sufficient distribution.

However, what if I want to do bundle development with this setup? I have
tried to use bundle:update in this scenario, but enabling DEBUG log output
confirmed my suspicion: Karaf does not look in my local Maven repository
for updated SNAPSHOT bundles; it just grabs it from the system repository
[1] - where it is not updated, of course, when I call mvn install for a
bundle project.

My question is therefore: what do you suggest as a "least effort"
development cycle, involving bundle:update and (when it works again)
bundle:watch? A link to a blogpost, a few lines of description, anything
will help :-) Google did not really turn up something for me...

Best regards,
Oliver


[1] Log from a bundle:update call:

2014-10-17 20:31:52,039 | DEBUG | h for user karaf | Connection
          | 1 - org.ops4j.pax.url.mvn - 2.2.0 | Resolving
[mvn:obfuscatedgroupid/obfuscatedartifactid/0.0.1-SNAPSHOT]
2014-10-17 20:31:52,039 | DEBUG | h for user karaf |
DefaultLocalRepositoryProvider   | 1 - org.ops4j.pax.url.mvn - 2.2.0 |
Using manager SimpleLocalRepositoryManager with priority 0.0 for
D:\Dev\Eclipse\Misc\obfuscatedapp\karaf-application\application\target\assembly\system
2014-10-17 20:31:52,039 | DEBUG | h for user karaf | AetherBasedResolver
           | 1 - org.ops4j.pax.url.mvn - 2.2.0 | Resolved
(obfuscatedgroupid:obfuscatedartifactid:jar:0.0.1-SNAPSHOT) as
D:\Dev\Eclipse\Misc\obfuscatedapp\karaf-application\application\target\assembly\system\some\where\obfuscatedartifactid\0.0.1-SNAPSHOT\obfuscatedartifactid-0.0.1-SNAPSHOT.jar

Re: Best practice question: development cycle for a bundle

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Oliver,

what ever you put into the system folder, if you use a SNAPSHOT 
artifact, you can update on the fly with bundle:update and bundle:watch.

By default, bundle:update/bundle:watch take the bundle location 
(containing the mvn URL), and check in your local maven repository 
($HOME/.m2/repository of the user who launch Karaf) for new artifact.

However, the default Karaf configuration is for "production" purpose. 
For development, you have to change a bit the 
etc/org.ops4j.pax.url.mvn.cfg file.

Especially,

org.ops4j.pax.url.mvn.defaultLocalRepoAsRemote=false
...
#org.ops4j.pax.url.mvn.defaultRepositories=
...
org.ops4j.pax.url.mvn.repositories= \
...
      file:${karaf.home}/${karaf.default.repository}@id=systemrepo, \
      file:${karaf.data}/kar@id=karrepos@multi

will allow you to switch in dev mode (instead of production mode).

I will create a Jira to document this (and add comments directly in the 
file).

Regards
JB

On 10/17/2014 08:39 PM, Oliver Pajonk wrote:
> Hi all,
>
> following up on the latest issue with bundle:watch I have a related
> question. I am using the "standard" (as in documented here
> <http://karaf.apache.org/manual/latest/developers-guide/custom-distribution.html>)
> way to construct a Karaf instance which would run my feature (and a few
> related ones). Both feature and distribution are created with
> the karaf-maven-plugin, so all bundles get installed into the system
> repository to make a self-sufficient distribution.
>
> However, what if I want to do bundle development with this setup? I have
> tried to use bundle:update in this scenario, but enabling DEBUG log
> output confirmed my suspicion: Karaf does not look in my local Maven
> repository for updated SNAPSHOT bundles; it just grabs it from the
> system repository [1] - where it is not updated, of course, when I call
> mvn install for a bundle project.
>
> My question is therefore: what do you suggest as a "least effort"
> development cycle, involving bundle:update and (when it works again)
> bundle:watch? A link to a blogpost, a few lines of description, anything
> will help :-) Google did not really turn up something for me...
>
> Best regards,
> Oliver
>
>
> [1] Log from a bundle:update call:
>
> 2014-10-17 20:31:52,039 | DEBUG | h for user karaf | Connection
>                | 1 - org.ops4j.pax.url.mvn - 2.2.0 | Resolving
> [mvn:obfuscatedgroupid/obfuscatedartifactid/0.0.1-SNAPSHOT]
> 2014-10-17 20:31:52,039 | DEBUG | h for user karaf |
> DefaultLocalRepositoryProvider   | 1 - org.ops4j.pax.url.mvn - 2.2.0 |
> Using manager SimpleLocalRepositoryManager with priority 0.0 for
> D:\Dev\Eclipse\Misc\obfuscatedapp\karaf-application\application\target\assembly\system
> 2014-10-17 20:31:52,039 | DEBUG | h for user karaf | AetherBasedResolver
>               | 1 - org.ops4j.pax.url.mvn - 2.2.0 | Resolved
> (obfuscatedgroupid:obfuscatedartifactid:jar:0.0.1-SNAPSHOT) as
> D:\Dev\Eclipse\Misc\obfuscatedapp\karaf-application\application\target\assembly\system\some\where\obfuscatedartifactid\0.0.1-SNAPSHOT\obfuscatedartifactid-0.0.1-SNAPSHOT.jar

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Best practice question: development cycle for a bundle

Posted by Oliver Pajonk <ol...@pjnk.de>.
Hi JB,

thank you - that helped a lot. I am now able to update bundles at runtime
with "bundle:update <id>". However, "bundle:watch *" seems to still not
work (I installed the replacement-bundle you provided to fix the command in
3.0.2).

When I run "bundle:watch *", Karaf DEBUG starts repeating the following
every second or so:

2014-10-18 14:09:54,986 | DEBUG | Thread-23        | configadmin
           | 6 - org.apache.felix.configadmin - 1.8.0 | getProperties()

2014-10-18 14:09:54,986 | DEBUG | lixDispatchQueue | framework
           | 0 - org.apache.felix.framework - 4.2.1 | FrameworkEvent
PACKAGES REFRESHED - org.apache.felix.framework

However, when I run "mvn clean install" on my "under-development" bundle,
it does not refresh it. On the other hand, manually running bundle:update
works. I guess I am still missing some small detail here?

Best regards,
Oliver

2014-10-18 7:23 GMT+02:00 Jean-Baptiste Onofré <jb...@nanthrax.net>:

> FYI: https://issues.apache.org/jira/browse/KARAF-3324
>
> Regards
> JB
>
> On 10/17/2014 08:39 PM, Oliver Pajonk wrote:
>
>> Hi all,
>>
>> following up on the latest issue with bundle:watch I have a related
>> question. I am using the "standard" (as in documented here
>> <http://karaf.apache.org/manual/latest/developers-
>> guide/custom-distribution.html>)
>>
>> way to construct a Karaf instance which would run my feature (and a few
>> related ones). Both feature and distribution are created with
>> the karaf-maven-plugin, so all bundles get installed into the system
>> repository to make a self-sufficient distribution.
>>
>> However, what if I want to do bundle development with this setup? I have
>> tried to use bundle:update in this scenario, but enabling DEBUG log
>> output confirmed my suspicion: Karaf does not look in my local Maven
>> repository for updated SNAPSHOT bundles; it just grabs it from the
>> system repository [1] - where it is not updated, of course, when I call
>> mvn install for a bundle project.
>>
>> My question is therefore: what do you suggest as a "least effort"
>> development cycle, involving bundle:update and (when it works again)
>> bundle:watch? A link to a blogpost, a few lines of description, anything
>> will help :-) Google did not really turn up something for me...
>>
>> Best regards,
>> Oliver
>>
>>
>> [1] Log from a bundle:update call:
>>
>> 2014-10-17 20:31:52,039 | DEBUG | h for user karaf | Connection
>>                | 1 - org.ops4j.pax.url.mvn - 2.2.0 | Resolving
>> [mvn:obfuscatedgroupid/obfuscatedartifactid/0.0.1-SNAPSHOT]
>> 2014-10-17 20:31:52,039 | DEBUG | h for user karaf |
>> DefaultLocalRepositoryProvider   | 1 - org.ops4j.pax.url.mvn - 2.2.0 |
>> Using manager SimpleLocalRepositoryManager with priority 0.0 for
>> D:\Dev\Eclipse\Misc\obfuscatedapp\karaf-application\application\
>> target\assembly\system
>> 2014-10-17 20:31:52,039 | DEBUG | h for user karaf | AetherBasedResolver
>>               | 1 - org.ops4j.pax.url.mvn - 2.2.0 | Resolved
>> (obfuscatedgroupid:obfuscatedartifactid:jar:0.0.1-SNAPSHOT) as
>> D:\Dev\Eclipse\Misc\obfuscatedapp\karaf-application\application\
>> target\assembly\system\some\where\obfuscatedartifactid\0.0.1-SNAPSHOT\
>> obfuscatedartifactid-0.0.1-SNAPSHOT.jar
>>
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>

Re: Best practice question: development cycle for a bundle

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
FYI: https://issues.apache.org/jira/browse/KARAF-3324

Regards
JB

On 10/17/2014 08:39 PM, Oliver Pajonk wrote:
> Hi all,
>
> following up on the latest issue with bundle:watch I have a related
> question. I am using the "standard" (as in documented here
> <http://karaf.apache.org/manual/latest/developers-guide/custom-distribution.html>)
> way to construct a Karaf instance which would run my feature (and a few
> related ones). Both feature and distribution are created with
> the karaf-maven-plugin, so all bundles get installed into the system
> repository to make a self-sufficient distribution.
>
> However, what if I want to do bundle development with this setup? I have
> tried to use bundle:update in this scenario, but enabling DEBUG log
> output confirmed my suspicion: Karaf does not look in my local Maven
> repository for updated SNAPSHOT bundles; it just grabs it from the
> system repository [1] - where it is not updated, of course, when I call
> mvn install for a bundle project.
>
> My question is therefore: what do you suggest as a "least effort"
> development cycle, involving bundle:update and (when it works again)
> bundle:watch? A link to a blogpost, a few lines of description, anything
> will help :-) Google did not really turn up something for me...
>
> Best regards,
> Oliver
>
>
> [1] Log from a bundle:update call:
>
> 2014-10-17 20:31:52,039 | DEBUG | h for user karaf | Connection
>                | 1 - org.ops4j.pax.url.mvn - 2.2.0 | Resolving
> [mvn:obfuscatedgroupid/obfuscatedartifactid/0.0.1-SNAPSHOT]
> 2014-10-17 20:31:52,039 | DEBUG | h for user karaf |
> DefaultLocalRepositoryProvider   | 1 - org.ops4j.pax.url.mvn - 2.2.0 |
> Using manager SimpleLocalRepositoryManager with priority 0.0 for
> D:\Dev\Eclipse\Misc\obfuscatedapp\karaf-application\application\target\assembly\system
> 2014-10-17 20:31:52,039 | DEBUG | h for user karaf | AetherBasedResolver
>               | 1 - org.ops4j.pax.url.mvn - 2.2.0 | Resolved
> (obfuscatedgroupid:obfuscatedartifactid:jar:0.0.1-SNAPSHOT) as
> D:\Dev\Eclipse\Misc\obfuscatedapp\karaf-application\application\target\assembly\system\some\where\obfuscatedartifactid\0.0.1-SNAPSHOT\obfuscatedartifactid-0.0.1-SNAPSHOT.jar

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com