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

gradle arguments are not visible within runOsgi block / configSettings = 'equinox' is overwritten #39

Closed paulvi closed 8 years ago

paulvi commented 8 years ago

While trying https://github.com/renatoathaydes/osgi-run/issues/37#issuecomment-208057926

all

gradle -Dequinox=true runOsgi 
gradle -Dequinox runOsgi 
gradle -Pequinox runOsgi 
gradle runOsgi -Pequinox

did not work

if (hasProperty('equinox')) {
    println 'equinox'
}

runOsgi {
    // https://github.com/renatoathaydes/osgi-run/issues/37 
    // run any with
    // gradle -Dequinox=true 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...    
    }

    bundles += subprojects
    config += [ 'org.osgi.framework.storage.clean': 'onFirstInit' ]
}

It always launches Felix

D:\Workspaces\Enide-2015-7\osgi-run-my>gradle runOsgi -Pequinox
equinox
:build-with-subprojects:my-api:compileJava UP-TO-DATE
:build-with-subprojects:my-api:processResources UP-TO-DATE
:build-with-subprojects:my-api:classes UP-TO-DATE
:build-with-subprojects:my-api:jar UP-TO-DATE
:build-with-subprojects:my-consumer:compileJava UP-TO-DATE
:build-with-subprojects:my-consumer:compileGroovy UP-TO-DATE
:build-with-subprojects:my-consumer:processResources UP-TO-DATE
:build-with-subprojects:my-consumer:classes UP-TO-DATE
:build-with-subprojects:my-consumer:jar UP-TO-DATE
:build-with-subprojects:my-impl:compileJava UP-TO-DATE
:build-with-subprojects:my-impl:compileGroovy UP-TO-DATE
:build-with-subprojects:my-impl:processResources UP-TO-DATE
:build-with-subprojects:my-impl:classes UP-TO-DATE
:build-with-subprojects:my-impl:jar UP-TO-DATE
:build-with-subprojects:createOsgiRuntime
:build-with-subprojects:runOsgi
Started MyConsumer
Got service ref null
Detected registration of a Service!
Got service with message: This is a MyService implementation of class com.athaydes.myimpl.MyServiceImpl
Exported MyService implementation
____________________________
Welcome to Apache Felix Gogo

> Building 93% > :build-with-subprojects:runOsgi
paulvi commented 8 years ago

The problem is likely different, as for 1.4.3, 1.4.2, 1.4.0 felix is used always (even when 'org.eclipse.osgi:org.eclipse.osgi:3.7.1' is downloaded )

runOsgi {
    configSettings = 'equinox'
        osgiMain = 'org.eclipse.osgi:org.eclipse.osgi:3.7.1'
        // https://bintray.com/search?query=org.eclipse.osgi
        //osgiMain = 'org.eclipse.tycho:org.eclipse.osgi:3.10.101.v20'
        javaArgs = '-DmyProp=someValue'
        programArgs = '-console'
        config += [ 'osgi.clean': true ]      // add properties to the Equinox config
renatoathaydes commented 8 years ago

Hi..

The syntax is gradlew runOsgi -Pequinox.

See this project: https://github.com/renatoathaydes/osgi-run/tree/master/osgi-run-test/ipojo-dosgi

It uses -Pclient to launch a client (and launches the server in case client is not set). See the build file: https://github.com/renatoathaydes/osgi-run/blob/master/osgi-run-test/ipojo-dosgi/build.gradle#L26

renatoathaydes commented 8 years ago

This is not a bug, it's just a side-effect of my latest changes to this demo project (build-with-subprojects), whereas I applied osgi-run to all sub-projects. When you run gradle runOsgi from the top-level directory, it will run each project, in turn, starting from the top-level one, then each subproject... As you only made the top-level project run with Equinox, the others run with the default, Felix, as expected.

renatoathaydes commented 8 years ago

@paulvi See the README I created explaining how to do this correctly.