5 Replies Latest reply on Jun 11, 2012 8:11 PM by Freeman(Yue) Fang

    How to do an osgi:install in a maven pom ?

    nicolas duminil Master

      Hi,

       

      I generally do a mvn clean install, which will install the bundle in the local maven repository, and then I'm doing an osgi:install -s mvn:... at the Karaf console. I've looked in the maven-bundle-plugin documentation to find a goal which would osgi:install the bundle but didn't find anything. Is there any way to do that ?

       

      Many thanks in advance.

       

      Kind regards,

       

      Nicolas

        • 1. Re: How to do an osgi:install in a maven pom ?
          nicolas duminil Master

          Just to complete my question ...

           

          Doing an osgi:install or its equivalent using a specific goal of the maven-bundle-plugin wouldn't be what I'm looking for as this requires the server to run. So it would mean to start the server first, etc.

           

          No, what I'm really looking for is to be able to install bundles on the Karaf server without mandatory having it running. Something equivalent to a Java EE server where you deploy when the server is not started and, when the server starts, all the deployed components are active.

           

          For example, just droping the bundle into the deploy directory would do it ? I tried that but I'm not sure it worked as I got exceptions. But it correctly display the bundle with osgi:list.

           

          What would be the best practice here ?

           

          Kind regards,

           

          Nicolas

          • 2. Re: How to do an osgi:install in a maven pom ?
            Claus Ibsen Master

            A side note: Karaf is scriptable though, so if you have Karaf running, you can write a script that logs into Karaf, and executes the osgi:install command.

             

            By copying to deploy dir should be okay, then you can install offline without Karaf running. It has a bit limitation though, as you cant control the bundle start level and whatnot. And I am not sure if it supports copying a feature file?

             

            A better alternative could be to add your features to the startup list in the config files in the etc directory.

            • 3. Re: How to do an osgi:install in a maven pom ?
              nicolas duminil Master

              Hi Claus,

               

              Many thanks for your answer. While I would like to have a netwise separation between deployment and server startup/shutdown etc., I would prefer the off-line deployment. And yes, I think that using OSGi features repositories would be a nice alternative because it additionally represents a reference of what need to be deployed. But simply looking inside the features file anybody understand what are the required bundles.

               

              But I'm a bit confused as, reading the documentation, it explains that adding your features repository to the config files only works the first time you start the server. My understanding is that, if you already started at least once the server and later you update the config files with your own features repository, it is not taken and you need to do a features:addUrl. Or, this requires the server to run, which I don't want to assume.

               

              Is that correct, does things happen this way ?

               

              Many thanks in advance.

               

              Nicolas

              • 4. Re: How to do an osgi:install in a maven pom ?
                nicolas duminil Master

                I tried to deploy a feature file by simply copying it to the deploy directory. It works. So what's the point then of using all features:addUrl features:install, etc. when it's much simpler to copy the file ?

                 

                And I also would like to deploy a kar. Is that posible with the current version. I'm asking as the maven plugin doesn't seem to have the required goal.

                 

                Kind regards,

                 

                Nicolas

                • 5. Re: How to do an osgi:install in a maven pom ?
                  Freeman(Yue) Fang Master

                  Hi,

                   

                  If you drop a feature file in deploy folder, all bundles in that feature file will get installed/started automatically.

                   

                  If  you use features:addUrl, all features not get installed, it's just available for the OSGi container so that sometime later on if you want to use a certain feature you need use features:install specifically. This is useful especially when some feature file is very big(like camel feature xml) and you generally only need several features from it.

                   

                  No, Kar isn't supported in current FUSE ESB version. Kar should be from Karaf 3.x(which isn't released yet from Apache) but current FUSE ESB are all use Karaf 2.x.

                   

                  Freeman