Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Create a simple OSGi environment using groovyx.osgi.runtime module
// these are necessary for current version (3.6.1) of Equinox
@GrabResolver(name='ebrRelease', root='')
@GrabResolver(name='ebrExternal', root='')
@GrabResolver(name='githubJetztgradNet', root='')
@Grab(group='groovyx.osgi', module='groovyx.osgi.runtime', version='0.1'),
@Grab(group='org.eclipse.osgi', module='org.eclipse.osgi', version='3.6.1.R36x_v20100806'),
@Grab(group='org.apache.commons', module='', version='1.1.1')
import groovyx.osgi.runtime.OsgiRuntimeBuilder {
framework 'equinox'
bundle 'mvn:org.apache.felix:org.apache.felix.configadmin:1.2.4'
bundle 'mvn:org.apache.felix:org.apache.felix.fileinstall:3.0.2'
beforeStart = {
println "starting OSGi runtime"
afterInstallBundles = { runtime ->
def bundleContext = runtime.bundleContext
if (bundleContext) {
println "installed bundles:"
bundleContext?.bundles?.each { bundle ->
println "[${bundle.bundleId}] ${bundle.symbolicName} ${bundle.version}"
else {
println "failed to list bundles"
doRun = {
// wait one minute
println "stopping OSGi runtime after one minute"
Thread.sleep 60000
afterStop = {
println "stopped OSGi runtime"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment