renatoathaydes / osgi-run

Osgi-Run - A Gradle plugin to make the development of modular applications using OSGi completely painless
Apache License 2.0
54 stars 13 forks source link

[feature request] run any time any osgi container with runOsgiFelix, runOsgiEquinox, runOsgiKnopflerfish - please vote #37

Open paulvi opened 8 years ago

paulvi commented 8 years ago

[feature request] please vote with :+1: from the top right menu

run any time any osgi container with runOsgiFelix, runOsgiEquinox, runOsgiKnopflerfish

Currently this plugin makes a great job to run one of 3 major OSGi containers. However what container to run is written inside build.gradle. To try other container user have to change.

What if user could run any time any osgi container with gradle runOsgiFelix, gradle runOsgiEquinox, gradle runOsgiKnopflerfish

That would still require some preferences inside build.gradle, but they may look similar to

runOsgi {
    felix{
    }
    equinox{
        configSettings = 'equinox'            // use Equinox's config file instead of Felix's
        osgiMain = 'org.eclipse.osgi:org.eclipse.osgi:3.7.1' // use a specific version of Equinox
        javaArgs = '-DmyProp=someValue'       // pass some args to the Java process
        programArgs = '-console'              // pass some arguments to the Equinox starter
    }
    bundles += allprojects.toList() + IPOJO_BUNDLE // bundles are: this project + subprojects + IPojo
    config += [ 'osgi.clean': true ]      // add properties to the Equinox config
    outDir = 'runtime'                    // the environment will be built at "${project.buildDir}/runtime"
    copyManifestTo file( 'auto-generated/MANIFEST.MF' ) // make the manifest visible to the IDE for OSGi support
}

that is additional preferences not to runOsgi, but specific container option.

then there can be runOsgi.default = felix (or runOsgi { felix { default = true ...) to specify for use with $ gradle runOsgi

renatoathaydes commented 8 years ago

@paulvi I like this idea! But I think you can already achieve something really similar using existing Gradle features.

Try something like this:

runOsgi {
    if (hasProperty('equinox')) {
        configSettings = 'equinox'
        osgiMain = 'org.eclipse.osgi:org.eclipse.osgi:3.7.1'
        javaArgs = '-DmyProp=someValue'
        programArgs = '-console'
        config += [ 'osgi.clean': true ]      // add properties to the Equinox config
    } else {  // use felix, which is already the default
        // maybe specify which felix version to use here...    
    }

    // properties used for all containers
    bundles += allprojects.toList() + IPOJO_BUNDLE // bundles are: this project + subprojects + IPojo
    outDir = 'runtime'                    // the environment will be built at "${project.buildDir}/runtime"
    copyManifestTo file( 'auto-generated/MANIFEST.MF' ) // make the manifest visible to the IDE for OSGi support
}

To run with Equinox, do:

gradle -Dequinox=true runOsgi

To run with Felix:

gradle runOsgi

PS. didn't try, but pretty sure this works. Let me know if you run into trouble.

paulvi commented 8 years ago

This is already nice, can be in README but with #39 fix,
however this one users can't self discover the feature, because when there are added tasks (runOsgiFelix, runOsgiEquinox, runOsgiKnopflerfish) they are visible in gradle tasks CLI and in IDEs

On the other hand implementing this will make some users believe, that this should all work out-of-box and raise dummy question like I do..

Can this be open for a while to see if more users want this