Provision your build directory as an OSGi bundle
During last week I added a new OSGi url handler member to OPS4J Pax URL family.
There are probably numerous use cases when you could use the new ”assembly” protocol but one stands out:
During development of your projects you usually have the sources on the file system, sources that are compiled by your build system, such as Maven or ANT, or your IDE, and stored somewhere on the file system in a directory. As an example lets take Maven case: the compiled classes are stored under “/target/classes”. If you use an IDE such as IntelliJ IDEA on this Maven project, as soon as sources get changes, they are automatically compiled to the same directory.
Now, what would you want to do is to have the sources of this project, assembled together as bundle and deployed as a bundle in an OSGi framework. To do this you will have to (usually) generate an OSGi bundle (jar) our of this classes and deploy the generated bundle.
But why not directly deploy the directory as a bundle? Because most of OSGi frameworks only supports a jar as deployment artifact. And here is where the “assembly” protocol will shine. Will allow you to do just that: transparently deploy the directory as a bundle on ANY OSGi framework. More then that doing a bundle update will re-generate the bundle content automatically. And all of this with a simple URL like:
Now, you should not understand from this example that it can be used only with Maven. You can use any directory, include or exclude files you want and much more.
Sounds interesting? Read more about it on Pax URL “assembly” url handler documentation. Do not forget to scroll down to see some tips & tricks.