You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Steinar Bang <sb...@dod.no> on 2017/04/21 16:22:30 UTC

Trying to use "mvn karaf:run"

I'm trying to use "mvn karaf:run" to replace the old "mvn
pax:provision" config I used to have.

I used "mvn pax:provision" before I took the leap into using karaf, and
I continued to have it working so that people could have a quick way to
use my webapp without installing anything more than git, java and maven:
  git clone https://github.com/steinarb/ukelonn.git
  cd ukelonn
  git checkout using-vaadin
  mvn -P use-gogoshell install
  cd ukelonn.gogoshell
  mvn install pax:provision
and then open a browser on  http://localhost:8090/ukelonn/ while the
maven command is running.

However, when I went to karaf 4.1.1 I decided to just rip out the
pax:provision stuff: manually resolving the OSGi dependencies, was too
much work for something I don't actually use myself.

So I looked into "mvn karaf:run" to see if that would work for me, and
unfortunately it doesn't.

As far as I can tell, "mvn karaf:run" is intended to run a single bundle
from a project with <packaging>bundle</packaging>...?
  https://github.com/apache/karaf/blob/master/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/RunMojo.java


That won't work for me:
 1. The bundle I tried on, ie. the main bundle, has
    <packaging>war</packaging> so even if it could run solo, it wouldn't
    work
     https://github.com/steinarb/ukelonn/blob/master/ukelonn.bundle/pom.xml
    the starting fails here:
     https://github.com/apache/karaf/blob/master/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/RunMojo.java#L141

 2. The bundle can't run solo, it needs the api bundle
     https://github.com/steinarb/ukelonn/blob/master/ukelonn.api/pom.xml
    and it needs the test database bundle
     https://github.com/steinarb/ukelonn/blob/master/ukelonn.bundle.test.db/pom.xml

What would have worked for me would be to be able to specify a feature
repository, and then what features to install from that repository
(loading all required dependencies in the normal karaf way).

Basically I would liked to be able to specify the same things I do in
the karaf container based pax exam test:
 https://github.com/steinarb/ukelonn/blob/master/ukelonn.tests/src/test/java/no/priv/bang/ukelonn/tests/UkelonnServiceIntegrationTest.java#L57
(I add the ukelonn repo and then load the database feature and the
webapp feature, loading the dependencies in the processs)

Is there a way to use the karaf:run goal that I haven't found?
Is there a different karaf:* goal that can be used in the manner
described above?

Thanks!


Re: Trying to use "mvn karaf:run"

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Achim Nierbeck <bc...@googlemail.com>:

> Hmm
> Sounds a bit Over designed to me.
> How about building your own custom distribution based on the feature?
> Now your user just need to unpack the distribution and run Karaf add it is
> with bin/Karaf

If it sounds overdesigned I'm explaining myself badly...:-)

I don't want to design anything, I would just let people try the webapp
at https://github.com/steinarb/ukelonn without installing anything more
than maven, git and java (which considering the target audience they
already have).

In the old days (ie. two days ago) they could do that with "mvn pax:provision".

I was looking for a way to do the same thing with karaf:run, but it
looks like it isn't possible with the current karaf:run...? (at least
not they way my app is structured across multiple bundles...?)
 

(for "production" use I use (and recommend in the README) downloading
and installing a regular karaf distro, and then
  feature:repo-add mvn:no.priv.bang.ukelonn/ukelonn.karaf/LATEST/xml/features
  feature:install ukelonn-db-postgresql
  feature:install ukelonn
  bundle:watch *
)


Re: Trying to use "mvn karaf:run"

Posted by Achim Nierbeck <bc...@googlemail.com>.
Hmm


Sounds a bit Over designed to me.
How about building your own custom distribution based on the feature?
Now your user just need to unpack the distribution and run Karaf add it is
with bin/Karaf

Regards, Achim



Steinar Bang <sb...@dod.no> schrieb am Fr. 21. Apr. 2017 um 18:26:

> I'm trying to use "mvn karaf:run" to replace the old "mvn
> pax:provision" config I used to have.
>
> I used "mvn pax:provision" before I took the leap into using karaf, and
> I continued to have it working so that people could have a quick way to
> use my webapp without installing anything more than git, java and maven:
>   git clone https://github.com/steinarb/ukelonn.git
>   cd ukelonn
>   git checkout using-vaadin
>   mvn -P use-gogoshell install
>   cd ukelonn.gogoshell
>   mvn install pax:provision
> and then open a browser on  http://localhost:8090/ukelonn/ while the
> maven command is running.
>
> However, when I went to karaf 4.1.1 I decided to just rip out the
> pax:provision stuff: manually resolving the OSGi dependencies, was too
> much work for something I don't actually use myself.
>
> So I looked into "mvn karaf:run" to see if that would work for me, and
> unfortunately it doesn't.
>
> As far as I can tell, "mvn karaf:run" is intended to run a single bundle
> from a project with <packaging>bundle</packaging>...?
>
> https://github.com/apache/karaf/blob/master/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/RunMojo.java
>
>
> That won't work for me:
>  1. The bundle I tried on, ie. the main bundle, has
>     <packaging>war</packaging> so even if it could run solo, it wouldn't
>     work
>
> https://github.com/steinarb/ukelonn/blob/master/ukelonn.bundle/pom.xml
>     the starting fails here:
>
> https://github.com/apache/karaf/blob/master/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/RunMojo.java#L141
>
>  2. The bundle can't run solo, it needs the api bundle
>      https://github.com/steinarb/ukelonn/blob/master/ukelonn.api/pom.xml
>     and it needs the test database bundle
>
> https://github.com/steinarb/ukelonn/blob/master/ukelonn.bundle.test.db/pom.xml
>
> What would have worked for me would be to be able to specify a feature
> repository, and then what features to install from that repository
> (loading all required dependencies in the normal karaf way).
>
> Basically I would liked to be able to specify the same things I do in
> the karaf container based pax exam test:
>
> https://github.com/steinarb/ukelonn/blob/master/ukelonn.tests/src/test/java/no/priv/bang/ukelonn/tests/UkelonnServiceIntegrationTest.java#L57
> (I add the ukelonn repo and then load the database feature and the
> webapp feature, loading the dependencies in the processs)
>
> Is there a way to use the karaf:run goal that I haven't found?
> Is there a different karaf:* goal that can be used in the manner
> described above?
>
> Thanks!
>
> --

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master

Re: Trying to use "mvn karaf:run"

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Jean-Baptiste Onofré <jb...@nanthrax.net>:

> Hm... since I'm not using a custom distro for production use, this (like
> the old pax:exam stuff) is work that won't see daily use and (also like
> the old pax:exam stuff) will see bit-rot (if I don't use it myself I
> won't discover that it isn't working until someone tells me).

>> Anyway, as we did bundle, it makes sense that karaf:run supports a
>> features set as well. I will create the Jira about that.

The Jira issue is: https://issues.apache.org/jira/browse/KARAF-5104

I have just created a github pull request with a proposed fix for that
issue: https://github.com/apache/karaf/pull/318

The pull request adds:
1. A parameter to set a list of URLs to feature repositories to add to
   the karaf started by karaf:run 
2. A parameter containing a comma separated list of features to install
   in the karaf started by karaf:run 
3. If karaf:run is set up to deploy the current project artifact and if
   the current project has packaging pom and an attached file with
   classifier "features" and type "xml", that attachment will be
   installed as a feature repository in the karaf started by the
   karaf:run goal 

Note: Even if you decide not to take this change, you might consider the
first commit of this pull request, because that is just as-is unit tests
of the RunMojo.deploy(BundleContext) method.


Re: Trying to use "mvn karaf:run"

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Jean-Baptiste Onofr <jb...@nanthrax.net>:

> What about creating your custom distro and run with karaf:run ?

Hm... since I'm not using a custom distro for production use, this (like
the old pax:exam stuff) is work that won't see daily use and (also like
the old pax:exam stuff) will see bit-rot (if I don't use it myself I
won't discover that it isn't working until someone tells me).

> Anyway, as we did bundle, it makes sense that karaf:run supports a
> features set as well. I will create the Jira about that.

Great! :-)



Re: Trying to use "mvn karaf:run"

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

What about creating your custom distro and run with karaf:run ?

Anyway, as we did bundle, it makes sense that karaf:run supports a features set 
as well. I will create the Jira about that.

Regards
JB

On 04/21/2017 06:22 PM, Steinar Bang wrote:
> I'm trying to use "mvn karaf:run" to replace the old "mvn
> pax:provision" config I used to have.
>
> I used "mvn pax:provision" before I took the leap into using karaf, and
> I continued to have it working so that people could have a quick way to
> use my webapp without installing anything more than git, java and maven:
>   git clone https://github.com/steinarb/ukelonn.git
>   cd ukelonn
>   git checkout using-vaadin
>   mvn -P use-gogoshell install
>   cd ukelonn.gogoshell
>   mvn install pax:provision
> and then open a browser on  http://localhost:8090/ukelonn/ while the
> maven command is running.
>
> However, when I went to karaf 4.1.1 I decided to just rip out the
> pax:provision stuff: manually resolving the OSGi dependencies, was too
> much work for something I don't actually use myself.
>
> So I looked into "mvn karaf:run" to see if that would work for me, and
> unfortunately it doesn't.
>
> As far as I can tell, "mvn karaf:run" is intended to run a single bundle
> from a project with <packaging>bundle</packaging>...?
>   https://github.com/apache/karaf/blob/master/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/RunMojo.java
>
>
> That won't work for me:
>  1. The bundle I tried on, ie. the main bundle, has
>     <packaging>war</packaging> so even if it could run solo, it wouldn't
>     work
>      https://github.com/steinarb/ukelonn/blob/master/ukelonn.bundle/pom.xml
>     the starting fails here:
>      https://github.com/apache/karaf/blob/master/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/RunMojo.java#L141
>
>  2. The bundle can't run solo, it needs the api bundle
>      https://github.com/steinarb/ukelonn/blob/master/ukelonn.api/pom.xml
>     and it needs the test database bundle
>      https://github.com/steinarb/ukelonn/blob/master/ukelonn.bundle.test.db/pom.xml
>
> What would have worked for me would be to be able to specify a feature
> repository, and then what features to install from that repository
> (loading all required dependencies in the normal karaf way).
>
> Basically I would liked to be able to specify the same things I do in
> the karaf container based pax exam test:
>  https://github.com/steinarb/ukelonn/blob/master/ukelonn.tests/src/test/java/no/priv/bang/ukelonn/tests/UkelonnServiceIntegrationTest.java#L57
> (I add the ukelonn repo and then load the database feature and the
> webapp feature, loading the dependencies in the processs)
>
> Is there a way to use the karaf:run goal that I haven't found?
> Is there a different karaf:* goal that can be used in the manner
> described above?
>
> Thanks!
>

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