Hi,

On Thu, Feb 5, 2009 at 12:51 PM, yanshaozhiGmail
<[email protected]> wrote:
> ...You can think that I made a copy of launch app project , I think I should
> change the pom.xml  to include other projects , in other projects there are 
> servlet
>  with osgi service , how can I make the services run automatic ?  where 
> should I
> change the pom.xml file?...

In the current trunk (revision 741089), the launchpad/app and
launchpad/webapp POMs reuse the bundles from the launchpad/bundles
module.

They do so by expanding the launchpad/bundles jar, which contains
other bundles, and repacking those bundles into the final jar.

In the case of launchpad/app, you can see for example

target/classes/resources/bundles/10/org.apache.felix.metatype-1.0.2.jar
target/classes/resources/bundles/10/org.apache.felix.scr-1.0.6.jar
target/classes/resources/bundles/15/commons-collections-3.2.1.jar
target/classes/resources/bundles/15/commons-io-1.4.jar
target/classes/resources/bundles/15/commons-lang-2.4.jar

Which means that the first two bundles will be started at OSGi run
level 10, the other 3 at level 15.

And you find those bundles in the final jar, among others:

$ unzip -l target/org.apache.sling.launchpad.app-4-incubator-SNAPSHOT.jar
...
    62356  02-04-09 14:46
resources/bundles/10/org.apache.felix.metatype-1.0.2.jar
   109747  02-04-09 14:46   resources/bundles/10/org.apache.felix.scr-1.0.6.jar
   575389  02-04-09 14:46   resources/bundles/15/commons-collections-3.2.1.jar
   109043  02-04-09 14:46   resources/bundles/15/commons-io-1.4.jar
   261809  02-04-09 14:46   resources/bundles/15/commons-lang-2.4.jar
...

So, to include you own bundles in the final app jar, simply modify the
POM to copy those bundles in the appropriate folder under
target/classes/resources/bundles/N where N is the desired start level
(I'd use 20 for application bundles). The goal is to have them in the
final jar under resources/bundles/N.

You can use the copy-dependencies goal of the maven-dependency-plugin
for that, as is done in the launchpad/bundles module.

Note that, to experiment, you can also use the launchpad/app jar as
is, and add your bundles using the OSGi console, or using the
maven-sling-plugin. Yet another option is to use the jcrinstall bundle
(found in extensions/jcrinstall/service), and copy your bundles in the
repository under /apps/myapp/install, for example - but that's another
story.

HTH,
-Bertrand

Reply via email to