GithubHelp home page GithubHelp logo

renatoathaydes / osgi-run Goto Github PK

View Code? Open in Web Editor NEW
54.0 12.0 13.0 660 KB

Osgi-Run - A Gradle plugin to make the development of modular applications using OSGi completely painless

License: Apache License 2.0

Groovy 69.69% Java 29.98% Shell 0.33%
osgi osgi-environment gradle-plugin java

osgi-run's Introduction

osgi-run

Maven Central

Osgi-Run - A Gradle plugin to make the development of modular applications using OSGi completely painless.

Features

  • Create and run an OSGi environment using any container.
  • Deploy the Gradle project's or sub-projects' bundles to the container easily.
  • Fetch dependencies using the standard Gradle way, from any repository supported by Gradle.
  • Wrap into bundles any non-OSGi-ready dependencies automatically1.
  • Use dependencies as system libs, ie. let them live in the system classpath2.

What can I use osgi-run for?

Basically, to get your Gradle project (and sub-projects) bundles into an OSGi container as part of the Gradle build, or just run existing bundles sourced from Gradle-compatible repositories.

Here's how it works:

If you already have your bundle(s) in a Gradle-compatible repository:

  1. create a build.gradle file and apply the osgi-run plugin.
  2. add your bundles to the project dependencies with the osgiRuntime type.
  3. run gradle createOsgi.
  4. Find your OSGi environment ready to run in the build/osgi directory. Start the OSGi container with run.sh or run.bat.

If you want to start a Gradle project from scratch:

  1. create a Java Gradle build.
  2. specify compile dependencies (plain Java or OSGi libs) as usual, plus some osgiRuntime deps if you need some OSGi bundles at runtime.
  3. add a Gradle plugin such as biz.aQute.bnd.builder to turn your jar into a bundle.
  4. add the osgi-run plugin to your build.
  5. run gradle createOsgi.
  6. Find your OSGi environment ready to run in the build/osgi directory. Start the OSGi container with run.sh or run.bat.
1: osgi-run uses [Bnd](http://www.aqute.biz/Bnd/Bnd) to wrap Gradle dependencies as bundles if necessary before adding them to the OSGi runtime, including transitive dependencies, so using normal flat jars becomes as easy as possible. 2: If some of your dependencies assume a flat classpath like in regular Java and won't work any other way (eg. loads classes at runtime, scans the classpath, uses JVM internals), you can use still them as **system libs**, which are just jars added to the system classpath and visible from all bundles (see the system libs section below).

osgi-run Tutorial and learning resources

To get started quickly, see the Quick Start section further below.

For a more advanced guide, check the osgi-run tutorial.

Plenty of examples are available in the osgi-run-test directory.

Applying the osgi-run plugin

plugins {
    id "com.athaydes.osgi-run" version "2.0" // check top of the page for latest version
}

Use Maven Central to resolve plugin

If you have trouble with the Gradle Plugins Repository, use Maven Central instead:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "com.athaydes.gradle.osgi:osgi-run-core:2.0"
    }
}

apply plugin: 'com.athaydes.osgi-run'

Quick Start

Given a Gradle project whose sub-projects are OSGi bundles, create an OSGi environment containing the sub-projects' bundles, running it with Apache Felix and the default bundles:

build.gradle

runOsgi {
  bundles += subprojects
}

Or if your OSGi environment consists of the Gradle project itself, its compile-time dependencies, plus some existing bundle such as the Felix implementation of the OSGi Config Admin Service:

dependencies {
    compile group: 'org.osgi', name: 'org.osgi.enterprise', version: '5.0.0'
    osgiRuntime group: 'org.apache.felix', name: 'org.apache.felix.configadmin', version: '1.9.22'
}

runOsgi {
    javaArgs = "-Dexample.configFile=${file( 'config-example.properties' ).absolutePath}"
    bundles += project
}

From the project's root directory, type:

gradle runOsgi

This will create and run the OSGi environment during the Gradle build.

Alternatively, you can just create the OSGi environment, then run it later using the run scripts created by osgi-run:

gradle createOsgiRuntime

This will create an OSGi environment in the output directory, which by default is build/osgi.

To run it:

cd build/osgi
chmod +x run.sh  # may be necessary in Linux/Mac
./run.sh # In Windows, use 'run.bat' instead

Once the framework starts, type lb to see all bundles installed and running. To see a list of commands available, type help. Stop the OSGi framework by typing exit, stop 0 (stops the system bundle) or pressing Ctrl+C.

Notice that you can include any artifact, such as Maven dependencies, in your bundle environment.

The default OSGi container is Apache Felix, but you can easily use Equinox and Knopflerfish as well.

For complete examples, continue reading the next sections or go straight to the samples in osgi-run-test.

Declarative Services Plugin

If you use OSGi Declarative Services, you should have a look at the osgi-ds plugin, which is part of the osgi-run core distribution.

Here's an example of how you can use it:

apply plugin: 'com.athaydes.osgi-ds'

declarativeServices {
    declarations {
        component( name: 'classTrieMessageBus' ) {
            implementation( 'class': 'com.athaydes.osgi.ds.ClassTrieMessageBus' )
            service {
                provide( 'interface': 'com.athaydes.osgi.messaging.MessageBus' )
            }
        }
    }
}

For more information, have a look at the DS Plugin Demo.

Handling start levels

If your OSGi bundles for any reason need to start in a defined order you can benefit from Start Levels defined by OSGi Core specification. Currently, the implementation works for Equinox and Felix only.

There are 2 ways to define specific start levels for your bundles:

Start level for a dependency

Inside the dependencies block, you can use the osgi method as follows

dependencies {
    osgiRuntime osgi(group: "some.group.id", name: "some-artifact-id", version: "version", startLevel: 3)
    
    // or using the shorter notation
    osgiRuntime osgi('some.group.id:some-artifact-id:version:3')
}

Start level for a bundle

If you specify your bundles using the runOsgi.budles property, you can use the following syntax:

runOsgi {
    bundles = [
        [dependency: 'group:artifact:version', startLevel: 3],
        
        // or using the shorter notation
        [dependency: 'group:artifact:version:3'],
    ]
}

Tasks

  • createBundlesDir: create the bundles directory with all the configured bundles. This task depends on the jar task of the project and its sub-projects.
  • createOsgiRuntime: create the OSGi runtime based on configuration provided (or the defaults). This task depends on createBundlesDir and is the main task of this plugin.
  • runOsgi: starts the OSGi runtime (depends on createOsgiRuntime). Useful for debugging purposes.
  • cleanOsgiRuntime: deletes the outputDir directory.

Notice that Gradle lets you write the shortest unambiguous task name possible, so instead of using the full name of a task, say createOsgiRuntime, you can just do gradle crOsgi and Gradle will get it.

The cleanOsgiRuntime task will make any existing clean task (normally added by the Java plugin) depend on itself, so you just need to type gradle clean to obliterate the OSGi runtime.

Configuring osgi-run

osgi-run accepts the following configuration:

  • runOsgi: allows configuration of the OSGi runtime. It contains the following settable properties (all properties are optional):

    • configSettings: String, one of ['equinox', 'felix', 'knopflerfish', 'none'] (default "felix"). This is used to generate a default config file for the OSGi container selected and affects the defaults used for most other properties. Always make this the first property you declare otherwise it will overwrite other properties with the default values for the container selected. Set to none if you want to provide your own config file.
      You can configure several environments and select which to use by passing a Gradle property, e.g. gradle runOsgi -Pequinox. See the build-with-subprojects example.
    • outDir: output directory (default: "osgi"). Can be a String (relative to the project buildDir) or a File (used as-is).
    • bundles: Bundles to include in the OSGi environment (defaults: in Felix and Equinox: runOsgi.FELIX_GOGO_BUNDLES, in Knopflerfish: []). Each item can be anything accepted by Project.files(Object... paths).
    • osgiMain: Main OSGi run-time (default: FELIX, set to EQUINOX, or KNOPFLERFISH depending on configSettings). Accepts anything accepted by Project.files(Object... paths) or a URI pointing to the framework jar.
    • javaArgs: String with arguments to be passed to the java process (default: "").
    • programArgs: String with arguments to be passed to the main Java class (main args).
    • bundlesPath: String with path where the bundles should be copied to (default for Felix: "bundle", Equinox: "plugins", Knopflerfish: "jars"").
    • config: Map of properties that should be added to the container's config file. This property is ignored if configSettings is set to 'none'.
    • wrapInstructions: instructions for wrapping non-bundles. See the relevant section below.
    • excludedBundles: List of regular expressions to match against bundle file names which must not be added to the OSGi runtime. Defaults to [ 'osgi\\..*', 'org\\.osgi\\..*' ].
    • copyManifestTo: Copies the bundle's Manifest to the given location. This is useful to keep an up-to-date, auto-generated version of the Manifest in a location where the IDE can use it to provide OSGi support.

The default config for Felix is:

If a startLevel is defined for any bundle, then the config file will list all bundles in the environment specifying the start-level as applicable, similarly to the Equinox config file.

'felix.auto.deploy.action'  : 'install,start',
'felix.log.level'           : 1,
'org.osgi.service.http.port': 8080,
'obr.repository.url'        : 'http://felix.apache.org/obr/releases.xml'

The default config for Equinox is (notice osgi.bundles is set dynamically based on the bundles property:

eclipse.ignoreApp : true,
osgi.noShutdown   : true,
osgi.bundles      : [bundle1-location@start,bundle2-location@start,...]

The default config for Knopflerfish is (notice bundle-1 and fragment-1 are actually derived from the bundles property):

-Dorg.knopflerfish.framework.main.verbosity  =  0
-Forg.knopflerfish.framework.debug.resolver  =  false
-Forg.knopflerfish.framework.debug.errors  =  true
-Forg.knopflerfish.framework.debug.classloader  =  false
-Forg.osgi.framework.system.packages.extra  =  
-Forg.knopflerfish.startlevel.use  =  true
-init   
-launch   

-istart $bundle-1
-install $fragment-1

Notice that to use Knopflerfish, you need to add its Maven Repository to your build file. See the Knopflerfish Demo for a working example.

The following constants can be used to provide values for the above properties:

  • FELIX: the Apache Felix main jar. Can be used to set osgiMain.
  • FELIX_GOGO_BUNDLES: the Felix Gogo bundles. Can be used with bundles.
  • EQUINOX: The Eclipse Equinox main jar. Can be used to set osgiMain.
  • KNOPFLERFISH: The Knopflerfish Framework jar. Can be used to set osgiMain.

Here's an example setting most properties (notice that normally you won't need to set nearly as many):

runOsgi {
    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() + 'my:custom-bundle:1.0' // bundles are: this project + subprojects + custom bundle
    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
}

The syntax of the bundles property

The bundles property takes a List with items having the following formats:

  • a String with the format of any Gradle dependency declaration.
  • a Project as in bundles = [project] or bundles = subProjects.
  • a Map with the following entries:
    • dependency (mandatory): String or Map dependency declaration.
    • transitive (optional, defaults to true): whether or not to include transitive dependencies.
    • exclusions (optional): transitive dependencies to exclude, specified as Map: [group: 'xxx', module: 'xxx'].
    • startLevel (optional): start level for the bundle.

Gradle configurations additions

osgi-run adds the following Gradle configurations to the project:

  • osgiMain: same as the runOsgi.osgiMain property, but declaring this configuration in a project's dependencies overrides that property. It is preferrable to use that property over this configuration.
  • osgiRuntime: has the same purpose as the runOsgi.bundles property. Both the property and the configuration are applied. Notice that properties and configurations, by default, consider all transitive dependencies of the bundles/jars. Non-bundles (simple jar) are wrapped into OSGi bundles automatically by default. If you do not want any transitive dependency of an artifact to be included in the OSGi runtime, you can do:
  • systemLib: system libs which should be added to the runtime not as bundles, but as simple jars in the system classpath. All system libs are excluded automatically from the bundle directory and export all their packages as system packages (using the org.osgi.framework.system.packages.extra config property).
dependencies {
    // all your usual dependencies
    ...
    
    osgiRuntime( "your:dependency:1.0" ) {
        transitive = false // transitive dependencies not included in OSGi runtime
    }
}

Wrapping non-bundles (flat jars)

If any of the artifacts you include in the OSGi environment are not OSGi bundles (ie. they are flat jars which do not contain OSGi meta-data), they will be automatically wrapped by osgi-run into OSGi bundles which export all of their contents.

This allows you to use any Java artifact whatsoever, so you are not limited to only OSGi bundles.

The actual wrapping is done by Bnd.

If you want to provide extra meta-data for Bnd to improve the wrapping results, you can use wrapInstructions as follows:

runOsgi {
    bundles += project

    wrapInstructions {
        // use regex to match file name of dependency
        manifest( "c3p0.*" ) {
            // import everything except the log4j package - should not be needed
            instruction 'Import-Package', '!org.apache.log4j', '*'
            instruction 'Bundle-Description', 'c3p0 is an easy-to-use library for making traditional ' +
                    'JDBC drivers "enterprise-ready" by augmenting them with functionality defined by ' +
                    'the jdbc3 spec and the optional extensions to jdbc2.'
        }
    }
}

The example above is used in the quartz-sample to provide extra meta-data for wrapping the c3p0 jar, which is required by the Quartz bundle.

System Libs

If the library you want to use cannot work within the OSGi environment even as a wrapped bundle (as discussed above), then you have only one option: add your jar to the system classpath by making it a system lib.

In short, system libs allow you to run some parts of your application in a regular Java environment (single classpath), while others run inside the OSGi container, allowing you to benefit from both worlds.

You get the modular design and awesome features of OSGi where you want it, but can still benefit from any JVM component whatsoever.

For example, if you want to add Frege (Haskell in the JVM) scripting to your OSGi application, you'll find that it's basically impossible because it uses its own complex classloader to load modules.

However, by turning the Frege REPL into a system lib, it will start just as if it were in a regular Java application:

dependencies {
    systemLib 'org.frege-lang:frege-repl-core:1.2'
}

All your bundles will be able to import and use the packages provided by Frege's regular jars.

See the frege-as-system-lib sample for a working example.

More usage examples

The best way to understand how you can configure your OSGi runtime is through examples.

Let's have a look at some common use-cases:

Use your Gradle project itself as a bundle

runOsgi {
  bundles += project
}

As FELIX_GOGO_BUNDLES is the default value of bundles, the above is equivalent to:

runOsgi {
  bundles = FELIX_GOGO_BUNDLES + project
}

If you don't want the default bundles installed, just use:

runOsgi {
  bundles = [ project ]
}

Use Gradle sub-projects as bundles

runOsgi {
  bundles += subprojects
}

Use Maven artifacts as runtime bundles

dependencies {
  // add all the Apache Felix Gogo bundles to the OSGi runtime
  osgiRuntime 'org.apache.felix:org.apache.felix.gogo.runtime:1.1.4'
  osgiRuntime 'org.apache.felix:org.apache.felix.gogo.jline:1.1.8'
  osgiRuntime 'org.apache.felix:org.apache.felix.gogo.command:1.1.2'
}
Solving unresolved constraint errors
Including Apache Commons Logging 1.1.1 into your OSGi environment

As another example, suppose you want to run the PDF Box library in an OSGi environment. That seems pretty easy, as PDF Box jars are already OSGi bundles! So you might expect that it should just work if you declare a dependency to it:

dependencies {
    compile 'org.apache.pdfbox:pdfbox:1.8.6' // won't work
}

However, when you do gradle clean runOsgi, you will find out it requires Apache Commons Logging at run-time (which will be automatically wrapped as a bundle by run-osgi), but this jar itself requires other things:

(org.osgi.framework.BundleException: Unresolved constraint in bundle org.apache.pdfbox.fontbox [2]: 
  Unable to resolve 2.0: missing requirement [2.0] osgi.wiring.package; 
  (osgi.wiring.package=org.apache.commons.logging) 
  [caused by: Unable to resolve 1.0: missing requirement [1.0] osgi.wiring.package;
  (osgi.wiring.package=javax.servlet)])

To understand why osgi-run could not figure out we needed not only commons-logging, but also some bundle to provide javax.servlet, let's ask Gradle to show us the dependencies of our module:

compile - Compile classpath for source set 'main'.
+--- org.osgi:org.osgi.core:4.3.1
\--- org.apache.pdfbox:pdfbox:1.8.6
     +--- org.apache.pdfbox:fontbox:1.8.6
     |    \--- commons-logging:commons-logging:1.1.1
     +--- org.apache.pdfbox:jempbox:1.8.6
     \--- commons-logging:commons-logging:1.1.1

As you can see, it looks as if the commons-logging dependency had no dependencies at all. So osgi-run has no way of knowing there are other needs for commons-logging to work.

Inspecting the POM file of commons-logging reveals what's going on... it declares several optional dependencies:

<dependency>
  <groupId>log4j</groupId>
  <artifactId>log4j</artifactId>
  <version>1.2.12</version>
  <optional>true</optional>
</dependency>
<dependency>
  <groupId>logkit</groupId>
  <artifactId>logkit</artifactId>
  <version>1.0.1</version>
  <optional>true</optional>
</dependency>
<dependency>
  <groupId>avalon-framework</groupId>
  <artifactId>avalon-framework</artifactId>
  <version>4.1.3</version>
  <optional>true</optional>
</dependency>
<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>servlet-api</artifactId>
  <version>2.3</version>
  <scope>provided</scope>
  <optional>true</optional>
</dependency>

So this is one case where we need to add a little meta-data by hand.

But that's easy, knowing that we probably won't be needing servlets or the Avalon Framework and the other Apache dependencies, we can simply tell osgi-run that these packages should not be imported at all:

runOsgi {
    bundles += project

    wrapInstructions {
        manifest( /commons-logging.*/ ) {
            instruction 'Import-Package', '!javax.servlet,!org.apache.*,*'
        }
    }
}

The wrap instruction tells run-osgi that the commons-logging bundle should not import the packages javax.servlet and org.apache.* (notice that you may use wildcards), but should import everything else that is required when wrapped into an OSGi bundle.

A working project demonstrating this can be found in the Installing non-bundles demo).

Using Groovy's SwingBuilder inside an OSGi environment

For yet another example, let's consider a bundle which uses Groovy to create a Swing UI. Using Groovy's SwingBuilder, writing UIs is pretty easy! However, if you try to start your bundle, you will be greeted by a really horrible error at runtime:

... 42 more    (too long to show the rest)
Caused by: java.lang.ClassNotFoundException: sun.reflect.ConstructorAccessorImpl
 not found by groovy-all [6]
        at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDele
gation(BundleWiringImpl.java:1550)
        at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringIm
pl.java:77)
...

Nothing is more annoying than these runtime ClassNotFoundException's you get in OSGi, especially when the offending class is clearly part of the JRE!

For cases like this, there's an easy fix... Just add the package of the class that cannot be found to OSGi's extra system packages:

runOsgi {
    config += [ 'org.osgi.framework.system.packages.extra': 'sun.reflect' ]
}

TODO rewrite IPojo-DOSGi Demo without IPojo as IPojo has not been maintained for many years.

Done! Now you can use the SwingBuilder without any concern. And you can see an actual working demo in the IPojo-DOSGi Demo, which includes a SwingBuilder-created UI in bundle code-runner-ui.

Using Equinox as the OSGi container

Simplest possible Equinox setup:

runOsgi {
  configSettings = 'equinox'
}

Notice that this will only start the Equinox Framework with the default bundles deployed. You can install bundles manually using the Gogo Shell (which is currently used by both Felix and Equinox).

But if you want to deploy some bundles automatically (your subprojects, for example) to your OSGi environment, try something like this:

runOsgi {
  configSettings = 'equinox'
  bundles = subprojects
}

This will deploy and start all your bundles (subprojects) when you run gradle runOsgi. This is done through the configuration/config.ini file which is generated automatically by osgi-run. If you do not wish to use this behavior, just set configSettings to "none" and copy your own config file to "${runOsgi.outDir}/<configFileLocation>".

Using a different version of Felix/Equinox or another OSGi container

If you want to declare exactly which version of Felix or Equinox (or you want to use some other OSGi container) you want to use, you can set runOsgi.osgiMain to the artifact coordinates of the container.

Using an older/newer version of Apache Felix
def felixVersion = '7.0.3' // or some other version

runOsgi {
  osgiMain = "org.apache.felix:org.apache.felix.main:$felixVersion"
}
Using an older/newer version of Equinox
// find the URI of the latest Equinox jar at https://download.eclipse.org/releases/
def equinoxJar = URI.create( 'https://download.eclipse.org/releases/2021-12/202112081000/plugins/org.eclipse.osgi_3.17.100.v20211104-1730.jar' )

runOsgi {
  configSettings = 'equinox'
  programArgs = '-console'
  osgiMain = equinoxJar
  bundles = [] // do not use the default bundles, older Equinox has its own console
}
Using another OSGi framework implementation

Just point to a runnable artifact which can start up your framework of choice, Knopflerfish, for example:

repositories {
  maven {
    url 'https://www.knopflerfish.org/releases/6.1.4/maven2/'
  }
}

runOsgi {
  configSettings = 'none'
  osgiMain = "org.knopflerfish.kf6:framework:8.0.11"
  bundles = subprojects // your bundles 
}

External Links

osgi-run's People

Contributors

cprieto avatar julianschuette avatar npetzall avatar renatoathaydes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

osgi-run's Issues

Object[]'s toString() used in wrapping

In this build.gradle I am generating OSGi manifests for both the rsyntaxtextarea and its autocomplete. Unfortunately when I tried to change the org.fife.ui symbolic name of RSyntaxTextArea, I got symbolic name like: [Ljava.lang.Object;@69c8b868.

When I tried similar thing to change the version of things to wrap, I got also a toString of an Object array (so I had to find already OSGified versions of it).

Repetitive executions of the "runOsgi" task fail

Repetitive executions of the "runOsgi" task fail with an:

Execution failed for task ':runOsgi'.
> None of the osgiMain jars [[]] contain a Main-Class in its Manifest.
  Please specify a runnable jar as a osgiMain dependency or the osgiMain property.

./gradlew cleanOsgiRuntime runOsgi works fine.

plugins {
    id "com.athaydes.osgi-run" version "1.5.0"
}
$ ./gradlew --version
------------------------------------------------------------
Gradle 2.4
------------------------------------------------------------
Build time:   2015-05-05 08:09:24 UTC
Build number: none
Revision:     5c9c3bc20ca1c281ac7972643f1e2d190f2c943c

Groovy:       2.3.10
Ant:          Apache Ant(TM) version 1.9.4 compiled on April 29 2014
JVM:          1.8.0_101 (Oracle Corporation 25.101-b13)
OS:           Linux 4.4.0-38-generic amd64
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':runOsgi'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:310)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
    at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:90)
    at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
    at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:50)
    at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:27)
    at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:40)
    at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:169)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
    at org.gradle.launcher.Main.doAction(Main.java:33)
    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
    at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Caused by: org.gradle.api.GradleException: None of the osgiMain jars [[]] contain a Main-Class in its Manifest.
Please specify a runnable jar as a osgiMain dependency or the osgiMain property.
    at com.athaydes.gradle.osgi.OsgiRuntimeTaskCreator.selectMainClass(OsgiRuntimeTaskCreator.groovy:105)
    at com.athaydes.gradle.osgi.OsgiRuntimeTaskCreator$selectMainClass$1.callStatic(Unknown Source)
    at com.athaydes.gradle.osgi.OsgiRunner.run(OsgiRunner.groovy:19)
    at com.athaydes.gradle.osgi.OsgiRunner$run.call(Unknown Source)
    at com.athaydes.gradle.osgi.OsgiRunPlugin$_runOsgiTask_closure5.doCall(OsgiRunPlugin.groovy:95)
    at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:558)
    at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:539)
    at org.gradle.api.internal.tasks.TaskMutator$1.execute(TaskMutator.java:77)
    at org.gradle.api.internal.tasks.TaskMutator$1.execute(TaskMutator.java:73)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    ... 49 more

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

[feature request] please vote with 👍 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

OSGi DS Annotations

Firstly, I'm loving this plug-in, thank you! I'm having some trouble figuring out how to properly use DS Annotations. Felix SCR annotations are now deprecated in favor of the actual OSGi ones. It would be great if we could annotate our classes and it automatically be picked up by osgi-run ds plug-in, as opposed to declaring them in the build.gradle or elsewhere. Are you aware of which dependencies are needed (without the osgi-run ds plug-in) to properly do DS annotations?

-Charlie

Bundle all "compile" dependencies into a fat jar bundle

Is it possible to build a fat jar with all transitive dependencies (conflicts resolved similar to maven), and select just the packages that I need to export for my plugin architecture?
No matter what I try, I always get in trouble with dependency resolution, last one was about "Invalid syntax for version" when generating the manifest for "raml-parser-2".
I will rather prefer to build a core bundle with all that I need, and skip this bunch of problems. I know this is not very good OSGi paradigm, I don't care!

Exclude bundles from osgiRuntime

Hi
Is it possible to instruct osgi-run to not install some bundles in started OSGi container? I have a big dependency tree with some packages not needed actually, but calculated as necessary.

Cannot execute runOSGI task under gradle 7.3.3

When I try, I get the following errors:

Problem creating boot delegation class loader: java.lang.reflect.InaccessibleObjectException: Unable to make protected java.security.SecureClassLoader(java.lang.ClassLoader) accessible: module java.base does not "opens java.security" to unnamed module @2957fcb0
org.osgi.framework.BundleException: Unable to resolve jline [1](R 1.0): missing requirement [jline [1](R 1.0)] osgi.ee; (&(osgi.ee=JavaSE)(version=1.5)) Unresolved requirements: [[jline [1](R 1.0)] osgi.ee; (&(osgi.ee=JavaSE)(version=1.5))]
ERROR: Bundle jline [1] Error starting file:/home/angle/Documents/Programming/Java/OSGIGradleSandbox/build/osgi/bundle/jline-2.14.2.jar (org.osgi.framework.BundleException: Unable to resolve jline [1](R 1.0): missing requirement [jline [1](R 1.0)] osgi.ee; (&(osgi.ee=JavaSE)(version=1.5)) Unresolved requirements: [[jline [1](R 1.0)] osgi.ee; (&(osgi.ee=JavaSE)(version=1.5))])
	at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4148)
	at org.apache.felix.framework.Felix.startBundle(Felix.java:2118)
	at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1372)
	at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
	at java.base/java.lang.Thread.run(Thread.java:833)
org.osgi.framework.BundleException: Unable to resolve org.apache.felix.scr [2](R 2.0): missing requirement [org.apache.felix.scr [2](R 2.0)] osgi.ee; (|(&(osgi.ee=JavaSE)(version=1.6))(&(osgi.ee=JavaSE/compact1)(version=1.8))) Unresolved requirements: [[org.apache.felix.scr [2](R 2.0)] osgi.ee; (|(&(osgi.ee=JavaSE)(version=1.6))(&(osgi.ee=JavaSE/compact1)(version=1.8)))]
ERROR: Bundle org.apache.felix.scr [2] Error starting file:/home/angle/Documents/Programming/Java/OSGIGradleSandbox/build/osgi/bundle/org.apache.felix.scr-2.0.12.jar (org.osgi.framework.BundleException: Unable to resolve org.apache.felix.scr [2](R 2.0): missing requirement [org.apache.felix.scr [2](R 2.0)] osgi.ee; (|(&(osgi.ee=JavaSE)(version=1.6))(&(osgi.ee=JavaSE/compact1)(version=1.8))) Unresolved requirements: [[org.apache.felix.scr [2](R 2.0)] osgi.ee; (|(&(osgi.ee=JavaSE)(version=1.6))(&(osgi.ee=JavaSE/compact1)(version=1.8)))])
	at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4148)
	at org.apache.felix.framework.Felix.startBundle(Felix.java:2118)
	at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1372)
	at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
	at java.base/java.lang.Thread.run(Thread.java:833)
org.osgi.framework.BundleException: Unable to resolve com.athaydes.osgiaas.cli-api [4](R 4.0): missing requirement [com.athaydes.osgiaas.cli-api [4](R 4.0)] osgi.wiring.package; (osgi.wiring.package=javax.annotation) Unresolved requirements: [[com.athaydes.osgiaas.cli-api [4](R 4.0)] osgi.wiring.package; (osgi.wiring.package=javax.annotation)]
	at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4148)
ERROR: Bundle com.athaydes.osgiaas.cli-api [4] Error starting file:/home/angle/Documents/Programming/Java/OSGIGradleSandbox/build/osgi/bundle/osgiaas-cli-api-0.7.jar (org.osgi.framework.BundleException: Unable to resolve com.athaydes.osgiaas.cli-api [4](R 4.0): missing requirement [com.athaydes.osgiaas.cli-api [4](R 4.0)] osgi.wiring.package; (osgi.wiring.package=javax.annotation) Unresolved requirements: [[com.athaydes.osgiaas.cli-api [4](R 4.0)] osgi.wiring.package; (osgi.wiring.package=javax.annotation)])
	at org.apache.felix.framework.Felix.startBundle(Felix.java:2118)
	at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1372)
	at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
	at java.base/java.lang.Thread.run(Thread.java:833)
ERROR: Bundle com.athaydes.osgiaas.cli-core [5] Error starting file:/home/angle/Documents/Programming/Java/OSGIGradleSandbox/build/osgi/bundle/osgiaas-cli-core-0.7.jar (org.osgi.framework.BundleException: Unable to resolve com.athaydes.osgiaas.cli-core [5](R 5.0): missing requirement [com.athaydes.osgiaas.cli-core [5](R 5.0)] osgi.wiring.package; (&(osgi.wiring.package=com.athaydes.osgiaas.api.env)(version>=0.7.0)(!(version>=1.0.0))) [caused by: Unable to resolve com.athaydes.osgiaas.common [6](R 6.0): missing requirement [com.athaydes.osgiaas.common [6](R 6.0)] osgi.wiring.package; (osgi.wiring.package=javax.annotation)] Unresolved requirements: [[com.athaydes.osgiaas.cli-core [5](R 5.0)] osgi.wiring.package; (&(osgi.wiring.package=com.athaydes.osgiaas.api.env)(version>=0.7.0)(!(version>=1.0.0)))])
org.osgi.framework.BundleException: Unable to resolve com.athaydes.osgiaas.cli-core [5](R 5.0): missing requirement [com.athaydes.osgiaas.cli-core [5](R 5.0)] osgi.wiring.package; (&(osgi.wiring.package=com.athaydes.osgiaas.api.env)(version>=0.7.0)(!(version>=1.0.0))) [caused by: Unable to resolve com.athaydes.osgiaas.common [6](R 6.0): missing requirement [com.athaydes.osgiaas.common [6](R 6.0)] osgi.wiring.package; (osgi.wiring.package=javax.annotation)] Unresolved requirements: [[com.athaydes.osgiaas.cli-core [5](R 5.0)] osgi.wiring.package; (&(osgi.wiring.package=com.athaydes.osgiaas.api.env)(version>=0.7.0)(!(version>=1.0.0)))]
	at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4148)
	at org.apache.felix.framework.Felix.startBundle(Felix.java:2118)
	at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1372)
	at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
	at java.base/java.lang.Thread.run(Thread.java:833)
ERROR: Bundle com.athaydes.osgiaas.common [6] Error starting file:/home/angle/Documents/Programming/Java/OSGIGradleSandbox/build/osgi/bundle/osgiaas-common-0.7.jar (org.osgi.framework.BundleException: Unable to resolve com.athaydes.osgiaas.common [6](R 6.0): missing requirement [com.athaydes.osgiaas.common [6](R 6.0)] osgi.wiring.package; (osgi.wiring.package=javax.annotation) Unresolved requirements: [[com.athaydes.osgiaas.common [6](R 6.0)] osgi.wiring.package; (osgi.wiring.package=javax.annotation)])
org.osgi.framework.BundleException: Unable to resolve com.athaydes.osgiaas.common [6](R 6.0): missing requirement [com.athaydes.osgiaas.common [6](R 6.0)] osgi.wiring.package; (osgi.wiring.package=javax.annotation) Unresolved requirements: [[com.athaydes.osgiaas.common [6](R 6.0)] osgi.wiring.package; (osgi.wiring.package=javax.annotation)]
	at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4148)
	at org.apache.felix.framework.Felix.startBundle(Felix.java:2118)
	at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1372)
	at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
	at java.base/java.lang.Thread.run(Thread.java:833)
> Task :runOsgi

This is without adding any bundle to the project, and only using the default osgiRuntime.

Don't remove Wrap Instruction after match

When the manifest of a "wrapInstruction" matches a file pattern, the instruction is removed from the config:

BndWrapper.groovy

  Map<String, Object[]> config = getWrapConfig( wrapInstructions, jarFile )
        def consumeValue = { String key ->
            Object[] items = config.remove( key )
            if ( items ) items.join( ',' )
            else null
        }

Hence, the instruction is not applied to subsequent jar files, matching the pattern. E.g.

runOsgi {
  bundles += subprojects

  wrapInstructions {
      manifest( ~/.*/ ) {
          instruction 'Import-Package', '!org.scalatest*', '!org.scalacheck*', '!org.specs*','*'
      }
  }
}

is only applied to the first match.

Improved version computation

For the com.thoughtworks.xstream:xstream:1.4.7 dependency there is an xpp3:xpp3_min:1.1.4c dependency, which cannot be wrapped, because the 1.1.4c is not an OSGi version format and the bnd tool fails with an exception. (Similarly to the org.apache.poi:poi-ooxml-schemas:3.10-FINAL dependency, 3.10-FINAL is not a valid OSGi version number, so bnd fails.) It would be nice if these kind of version numbers were automatically converted to an OSGi format, like 1.1.4.c or 3.10.0.FINAL.
Thanks for this great tool.

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

While trying #37 (comment)

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

Generate source bundles for eclipse/equinox

It would be nice when equinox is used in case there are no source bundles available (i.e. when wrapping or it was not uploaded to the repository) those bundles were generated. In Maven, this is done something like this, while for gradle it is probably looks like '-sources': true in this.
Thanks for considering it.

Remove dependency on the Gradle OSGi Plugin

Including the Gradle OSGi Plugin automatically was a decision that made sense when there was only one Gradle plugin for OSGi and to make it a tiny little bit easier for developers to use osgi-run (as they cannot forget to make their jars into bundles this way).

However, the Gradle OSGi Plugin only uses Bnd to create a manifest, not to modify the jar in any other way that is supported by Bnd, such as including nested jars (see #32 ), so this dependency on the Gradle OSGi Plugin is causing more damage than good for some users.

Removing this dependency should be really easy anyway.. Current users who don't explicitly declare apply plugin: 'osgi' just need to add this line to their build files and everything will work as before.

NoSuchMethodError for "createOsgiRuntime" task

"createOsgiRuntime" task failes with NoSuchMethodError. Works with 1.5.0.

plugins {
    id "com.athaydes.osgi-run" version "1.5.1"
}
$ ./gradlew --version
------------------------------------------------------------
Gradle 2.4
------------------------------------------------------------
Build time:   2015-05-05 08:09:24 UTC
Build number: none
Revision:     5c9c3bc20ca1c281ac7972643f1e2d190f2c943c

Groovy:       2.3.10
Ant:          Apache Ant(TM) version 1.9.4 compiled on April 29 2014
JVM:          1.8.0_101 (Oracle Corporation 25.101-b13)
OS:           Linux 4.4.0-38-generic amd64
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':createOsgiRuntime'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:310)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
    at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:90)
    at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
    at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:50)
    at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:27)
    at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:40)
    at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:169)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
    at org.gradle.launcher.Main.doAction(Main.java:33)
    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
    at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Caused by: java.lang.NoSuchMethodError: org.codehaus.groovy.runtime.StringGroovyMethods.find(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;
    at com.athaydes.gradle.osgi.util.FileNameUtils.versionFrom(FileNameUtils.groovy:11)
    at com.athaydes.gradle.osgi.util.FileNameUtils$versionFrom.call(Unknown Source)
    at com.athaydes.gradle.osgi.util.JarUtils.versionOf(JarUtils.groovy:108)
    at com.athaydes.gradle.osgi.util.JarUtils$versionOf$3.call(Unknown Source)
    at com.athaydes.gradle.osgi.bnd.BndWrapper.wrapNonBundle(BndWrapper.groovy:39)
    at com.athaydes.gradle.osgi.OsgiRuntimeTaskCreator$_copyBundles_closure13.doCall(OsgiRuntimeTaskCreator.groovy:183)
    at com.athaydes.gradle.osgi.OsgiRuntimeTaskCreator.copyBundles(OsgiRuntimeTaskCreator.groovy:180)
    at com.athaydes.gradle.osgi.OsgiRuntimeTaskCreator$_createOsgiRuntimeTask_closure1.doCall(OsgiRuntimeTaskCreator.groovy:35)
    at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:558)
    at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:539)
    at org.gradle.api.internal.tasks.TaskMutator$1.execute(TaskMutator.java:77)
    at org.gradle.api.internal.tasks.TaskMutator$1.execute(TaskMutator.java:73)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    ... 49 more

The compilation fails.

  • What went wrong:
    Task 'install' not found in root project 'osgi-run-core'.

the stacktrace is:

FAILURE: Build failed with an exception.

Cannot use a Jar file dependency as a OSGi bundle

When doing:

runOsgi {
    bundles = [ files(myDirWithJar) ]
}

An Exception is thrown because the plugin tries to configure the dependency (with "transitive" and "exclusions").

The plugin should only do that for bundles that are of type Dependency.

build broken with latest grade (3.4.1)

When using the master brunch of the osgi-run tutorial found in
https://sites.google.com/a/athaydes.com/renato-athaydes/posts/osgi-runtutorial-runyourjavakotlinfregecodeinosgi
with having grade version 3.4.1. installed
the first step fails.
This is
$ gradle crO
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
:createOsgiRuntime FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':createOsgiRuntime'.

Configuration with name '__osgiRuntime0' not found.

Other configuration than @start for equinox bundles

Hello,

OsgiRuntimeTaskCreator.groovy:140 always creates equinox configs with all bundles set to "..:@start". This will result in ugly exceptions when trying to start fragment bundles, or even prevent configurations from running properly when bundles are required to be installed, but not started.

Is there any way to write configs with bundles not set to "..@start"?

Thank you!

default console configuration for Equinox

Just by chance ran into http://stackoverflow.com/questions/25733843/how-to-start-osgi-console, that gave me answer why possible I could not run one of my first examples against Equinox

The solution is pasted below. Can this be default e.g. for #37 run-any

Make a run folder that would look like:

  • somedir/
    • configuration/
      • config.ini
    • org.eclipse.osgi.jar
    • org.eclipse.equinox.console.jar
    • org.apache.felix.gogo.shell.jar
    • org.apache.felix.gogo.command.jar
    • org.apache.felix.gogo.runtime.jar

Then edit config.ini as:

osgi.bundles=org.apache.felix.gogo.runtime@start, org.apache.felix.gogo.command@start, org.apache.felix.gogo.shell@start, org.eclipse.equinox.console@start

After done this, run java -jar org.eclipse.osgi.jar -console in your command line and the osgi console will start.

Split task to copy OSGi bundles to bundlesPath from createOsgiRuntime

It might be useful to run a task to just copy all runtime bundles to a specific directory, without creating a full runtime (with system libs, the system bundle, run scripts etc).

This can be easily done by moving some functionality from the createOsgiRuntime task into a new task, say createOsgiBundlesDir.

Provided dependencies

How to exclude some dependencies / ensure that it will be not wrapped?

I included some compile dependency which is dependant of slfj-api. Dependency is being automatically wrapped and deployed as bundle.

But in one of my projects, I also want to use slf4j, and I added compile dependency to it. After that I have two bundles slf4j deployed on instance. How to prevent such situation?

`apply` line in README is missing `plugin: `

About the "Quick Start" section.

I couldn't make it work until I added plugin:. Here is a minimal example of osgi-run for Equinoxe:

buildscript {
  repositories {
    jcenter()
  }
  dependencies {
    classpath "com.athaydes.gradle.osgi:osgi-run-core:1.0"
  }
}

apply plugin: 'osgi-run'

repositories {
  mavenCentral()
}

runOsgi {
  osgiMain = EQUINOX
  bundles = subprojects
  javaArgs = '-console'
  configSettings = 'equinox'
  bundlesPath = 'plugins'
}

task wrapper(type: Wrapper) {
  gradleVersion = '2.1'
}

[examples] generated-sources/MANIFEST.MF in one line (but is OK inside .jar bundle)

generated-sources/MANIFEST.MF in build-with-subprojects has only

Manifest-Version: 1.0


This is possibly issue of org.dm.bundle project or snippets below needs to be changed

afterEvaluate { project ->
    project.jar.doLast {
        project.jar.manifest.writeTo( project.file( 'generated-sources/MANIFEST.MF' ) )
    }
}

vs

jar {
}.doLast {
    // copy manifest to location where the IDE can use it to let us know when we breach OSGi restrictions!
    jar.manifest.writeTo( project.file( 'generated-sources/MANIFEST.MF' ) )
}

Doesnt work under gradle 4.4.1

Hi,

It seems, that it doesnt work under gradle 4.4.1. We migrated from gradle 3.4. Main issue is, that generated configuration.ini and content of folder plugins is different.

The main difference, that start level is changed (I really dont know why) and osgiaas-cli-core is added:

__osgiRuntime__0
--- org.apache.felix:org.apache.felix.scr:2.0.12

__osgiRuntime__1
--- com.athaydes.osgiaas:osgiaas-cli-core:0.7
+--- com.athaydes.osgiaas:osgiaas-cli-api:0.7
| +--- com.athaydes.osgiaas:osgiaas-common:0.7
| --- org.apache.felix:org.apache.felix.shell:1.4.3
--- jline:jline:2.14.2

It looks like, that dependencies are handled by different way. Why?

It looks like, that level for start level is copied to transitive deps

Please help, with best regards, jiri

[examples] quartz-sample fails when swithcing to 'org.dm.bundle' plugin

in quartz-sample-nested-jars example:

https://github.com/paulvi/osgi-run/tree/master/osgi-run-test/quartz-sample-nested-jars

there's error, so resulted bundle is not ACTIVE in felix, and can't be started.

full log

# parseClassFile(): path=org/xml/sax/ErrorHandler.class resource=:file:/C:/Program%20Files/Java/jdk1.8.0_74/jre/lib/rt.j
ar!/org/xml/sax/ErrorHandler.class:
:quartz-sample-nested-jars:createOsgiRuntime
> Building 83% > :quartz-sample-nested-jars:runOsgi

:quartz-sample-nested-jars:runOsgi
org.osgi.framework.BundleException: Unable to resolve com.athaydes.gradle.osgi.quartz-sample-nested-jars [6](R 6.0): mis
sing requirement [com.athaydes.gradle.osgi.quartz-sample-nested-jars [6](R 6.0)] osgi.wiring.package; (osgi.wiring.packa
ge=commonj.work) Unresolved requirements: [[com.athaydes.gradle.osgi.quartz-sample-nested-jars [6](R 6.0)] osgi.wiring.p
ackage; (osgi.wiring.package=commonj.work)]
ERROR: Bundle com.athaydes.gradle.osgi.quartz-sample-nested-jars [6] Error starting file:/D:/Workspaces/GitHub/osgi-run/
osgi-run-test/quartz-sample-nested-jars/build/osgi/bundle/quartz-sample-nested-jars-1.0.jar (org.osgi.framework.BundleEx
ception: Unable to resolve com.athaydes.gradle.osgi.quartz-sample-nested-jars [6](R 6.0): missing requirement [com.athay
des.gradle.osgi.quartz-sample-nested-jars [6](R 6.0)] osgi.wiring.package; (osgi.wiring.package=commonj.work) Unresolved
 requirements: [[com.athaydes.gradle.osgi.quartz-sample-nested-jars [6](R 6.0)] osgi.wiring.package; (osgi.wiring.packag
e=commonj.work)])
        at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4111)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:2117)
        at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1371)
        at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
        at java.lang.Thread.run(Thread.java:745)
____________________________
Welcome to Apache Felix Gogo

> Building 83% > :quartz-sample-nested-jars:runOsgilb
g! g! g! START LEVEL 1
   ID|State      |Level|Name
    0|Active     |    0|System Bundle (5.4.0)|5.4.0
    1|Active     |    1|c3p0 (0.9.1.1)|0.9.1.1
    2|Active     |    1|Apache Felix Gogo Command (0.16.0)|0.16.0
    3|Active     |    1|Apache Felix Gogo Runtime (0.16.2)|0.16.2
    4|Active     |    1|Apache Felix Gogo Shell (0.12.0)|0.12.0
    5|Active     |    1|quartz (2.2.1)|2.2.1
    6|Installed  |    1|com.athaydes.gradle.osgi.quartz-sample-nested-jars (1.0.0)|1.0.0
    7|Active     |    1|slf4j-api (1.6.6)|1.6.6
    8|Resolved   |    1|slf4j-simple (1.6.6)|1.6.6
> Building 83% > :quartz-sample-nested-jars:runOsgistart 6
org.osgi.framework.BundleException: Unable to resolve com.athaydes.gradle.osgi.quartz-sample-nested-jars [6](R 6.0): mis
sing requirement [com.athaydes.gradle.osgi.quartz-sample-nested-jars [6](R 6.0)] osgi.wiring.package; (osgi.wiring.packa
ge=commonj.work) Unresolved requirements: [[com.athaydes.gradle.osgi.quartz-sample-nested-jars [6](R 6.0)] osgi.wiring.p
ackage; (osgi.wiring.package=commonj.work)]
> Building 83% > :quartz-sample-nested-jars:runOsgi

ref #32 , TomDmitriev/gradle-bundle-plugin#54
@TomDmitriev @rotty3000

My TODO is raise on stackoverflow.com

Getting a 'Cannot read Declarative Services declarations from null' error

Environment:

  • Windows 10
  • Intellij
  • Gradle 6.6.1
  • Groovy 2.5.12
  • In build.gradle, added the following in the plugins block: id "com.athaydes.osgi-ds" version "1.3.1"

Running gradlew.bat build, and getting the following error:
Execution failed for task ':example:jar'.

Cannot read Declarative Services declarations from null

Would appreciate any help in understanding this.
(BTW, my goal is to make my jar an OSGI bundle. The native gradle osgi plugin was removed, so I wanted to use your plugin instead. If your plugin is not a substitute for the native plugin, can you please let me know which plugin would be relevant?).

Thanks!

[Gradle 3.0 support] Caused by: org.gradle.api.artifacts.UnknownConfigurationException: Configuration with name '__osgiRuntime__0' not found.

I'm receiving the following error. I have previously used osgi-run successfully, but recently I've run into this problem. I'm currently running Gradle 3.0 with a simple root project. Any help would be greatly appreciated.

org.gradle.tooling.BuildException: Could not run build action using Gradle installation '/home/georgec/Programs/gradle-3.0'. at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:59) at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54) at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46) at org.gradle.tooling.internal.consumer.DefaultBuildActionExecuter.run(DefaultBuildActionExecuter.java:47) at org.netbeans.gradle.model.GenericModelFetcher.getModels(GenericModelFetcher.java:166) at org.netbeans.gradle.project.model.NbGradle18ModelLoader$ProjectModelFetcher.getModels(NbGradle18ModelLoader.java:371) at org.netbeans.gradle.project.model.NbGradle18ModelLoader.loadModels(NbGradle18ModelLoader.java:69) at org.netbeans.gradle.project.model.GradleModelLoader.loadModelWithProgress(GradleModelLoader.java:566) at org.netbeans.gradle.project.model.GradleModelLoader.access$800(GradleModelLoader.java:71) at org.netbeans.gradle.project.model.GradleModelLoader$6.run(GradleModelLoader.java:396) at org.netbeans.gradle.project.tasks.GradleDaemonManager.runNonBlockingGradleTask(GradleDaemonManager.java:35) at org.netbeans.gradle.project.tasks.GradleDaemonManager.access$100(GradleDaemonManager.java:22) at org.netbeans.gradle.project.tasks.GradleDaemonManager$2.execute(GradleDaemonManager.java:125) at org.jtrim.concurrent.AbstractTaskExecutorService$FunctionWrapper.execute(AbstractTaskExecutorService.java:270) at org.jtrim.concurrent.AbstractTaskExecutorService$TaskOfAbstractExecutor.execute(AbstractTaskExecutorService.java:340) at org.jtrim.concurrent.Tasks$RunOnceCancelableTask.execute(Tasks.java:342) at org.jtrim.concurrent.SingleThreadedExecutor$QueuedItem.runTask(SingleThreadedExecutor.java:919) at org.jtrim.concurrent.SingleThreadedExecutor$QueuedItem.access$1200(SingleThreadedExecutor.java:898) at org.jtrim.concurrent.SingleThreadedExecutor$Impl$Worker.executeTask(SingleThreadedExecutor.java:815) at org.jtrim.concurrent.SingleThreadedExecutor$Impl$Worker.processQueue(SingleThreadedExecutor.java:827) at org.jtrim.concurrent.SingleThreadedExecutor$Impl$Worker.run(SingleThreadedExecutor.java:861) at org.jtrim.concurrent.SingleThreadedExecutor$Impl$1.run(SingleThreadedExecutor.java:453) at java.lang.Thread.run(Thread.java:745) Caused by: org.gradle.internal.exceptions.LocationAwareException: A problem occurred configuring root project 'CAMP'. at org.gradle.initialization.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:74) at org.gradle.initialization.MultipleBuildFailuresExceptionAnalyser.transform(MultipleBuildFailuresExceptionAnalyser.java:47) at org.gradle.initialization.StackTraceSanitizingExceptionAnalyser.transform(StackTraceSanitizingExceptionAnalyser.java:30) at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:100) at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:92) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63) at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:92) at org.gradle.initialization.DefaultGradleLauncher.getBuildAnalysis(DefaultGradleLauncher.java:88) at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.configure(InProcessBuildActionExecuter.java:102) at org.gradle.tooling.internal.provider.runner.ClientProvidedBuildActionRunner.run(ClientProvidedBuildActionRunner.java:45) at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) at org.gradle.tooling.internal.provider.runner.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:58) at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28) at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:82) at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:49) at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:59) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:49) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74) at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72) at org.gradle.util.Swapper.swap(Swapper.java:38) at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.HintGCAfterBuild.execute(HintGCAfterBuild.java:44) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50) at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:240) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54) at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40) Caused by: org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'CAMP'. at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:79) at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:74) at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:61) at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:573) at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:125) at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42) at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:38) at org.gradle.initialization.DefaultGradleLauncher$2.run(DefaultGradleLauncher.java:124) at org.gradle.internal.Factories$1.create(Factories.java:22) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:53) at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:121) at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32) at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:98) ... 42 more Caused by: org.gradle.api.artifacts.UnknownConfigurationException: Configuration with name '__osgiRuntime__0' not found. at org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer.createNotFoundException(DefaultConfigurationContainer.java:92) at org.gradle.api.internal.DefaultNamedDomainObjectCollection.getByName(DefaultNamedDomainObjectCollection.java:229) at org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer.getByName(DefaultConfigurationContainer.java:82) at org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer.getByName(DefaultConfigurationContainer.java:37) at org.gradle.api.internal.DefaultNamedDomainObjectCollection.getAt(DefaultNamedDomainObjectCollection.java:241) at org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer.getAt(DefaultConfigurationContainer.java:37) at org.gradle.api.artifacts.ConfigurationContainer$getAt.call(Unknown Source) at com.athaydes.gradle.osgi.ConfigurationsCreator$_configBundles_closure1$_closure3.doCall(ConfigurationsCreator.groovy:21) at com.athaydes.gradle.osgi.ConfigurationsCreator$_configBundles_closure1.doCall(ConfigurationsCreator.groovy:20) at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:70) at org.gradle.util.ConfigureUtil.configureTarget(ConfigureUtil.java:160) at org.gradle.util.ConfigureUtil.configureSelf(ConfigureUtil.java:148) at org.gradle.api.internal.AbstractNamedDomainObjectContainer.configure(AbstractNamedDomainObjectContainer.java:74) at org.gradle.api.internal.AbstractNamedDomainObjectContainer.configure(AbstractNamedDomainObjectContainer.java:29) at org.gradle.api.internal.project.DefaultProject.configurations(DefaultProject.java:932) at org.gradle.api.Project$configurations$3.call(Unknown Source) at com.athaydes.gradle.osgi.ConfigurationsCreator.configBundles(ConfigurationsCreator.groovy:18) at com.athaydes.gradle.osgi.ConfigurationsCreator$configBundles.call(Unknown Source) at com.athaydes.gradle.osgi.OsgiRunPlugin$_createTasks_closure1.doCall(OsgiRunPlugin.groovy:30) at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:40) at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25) at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:44) at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:79) at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:30) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) at com.sun.proxy.$Proxy12.afterEvaluate(Unknown Source) at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:67) ... 54 more

ipojo-plugin: Upload version 1.1 to Bintray

The current version of ipojo-plugin is 1.0 on Bintray and therefore doesn't include commit 0b2b7bb, which fixes a bug that prevents rebuilding without removing the existing generated bundle. ipojo-plugin 1.1 should be made available to fix this issue.

Do not include jars for packages starting with 'osgi.*' in bundles directory

When using dependencies like osgi core or compendium, they should not be included in the osgi/bundle directory.

For example:

    compile 'org.osgi:osgi.core:6.0.0'
    compile 'org.osgi:osgi.cmpn:6.0.0'

Results in having osgi.cmpn-6.0.0.jar and osgi.core-6.0.0.jar in osgi/bundle. The main output also complains about not being able to start the bundle (and that is perfectly right, in my opinion):

  ERROR: Bundle osgi.cmpn [11] Error starting file:[...]/build/osgi/bundle/osgi.cmpn-6.0.0.jar     (org.osgi.framework.BundleException: Unable to resolve osgi.cmpn [11](R 11.0): missing requirement [osgi.cmpn [11](R 11.0)] osgi.compile.time.only; (&(must.not.resolve=*)(!(must.not.resolve=*))) Unresolved requirements: [[osgi.cmpn [11](R 11.0)] osgi.compile.time.only; (&(must.not.resolve=*)(!(must.not.resolve=*)))])
org.osgi.framework.BundleException: Unable to resolve osgi.cmpn [11](R 11.0): missing requirement [osgi.cmpn [11](R 11.0)] osgi.compile.time.only; (&(must.not.resolve=*)(!(must.not.resolve=*))) Unresolved requirements: [[osgi.cmpn [11](R 11.0)] osgi.compile.time.only; (&(must.not.resolve=*)(!(must.not.resolve=*)))]
    at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4111)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2117)
    at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1371)
    at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
    at java.lang.Thread.run(Thread.java:745)

Relative bundle paths (Equinox)

Hello,

I am using createOsgiRuntime to generate an Equinox config, which works perfectly well. However, in the generated config.ini, bundles are given by absolute paths which makes it impossible to run the generated config from anywhere else then from target dir.

Bundles should be referred to by paths relative to the OSGi root. Does anything speak against replacing

        def bundleJars = new FileNameByRegexFinder().getFileNames(
                bundlesDir.absolutePath, /.+\.jar/ )

by

        def bundleJars = new FileNameByRegexFinder().getFileNames(
                new File(${osgiConfig.bundlesPath}").path, /.+\.jar/ )

in OsgiRuntimeTaskCreator.groovy:138 ?

Equinox cannot find the plugins directory on startup

It looks like since the OSGi container jars were moved to system-libs in the 1.5.0 version, Equinox no longer can find the plugins directory without extra configuration because it looks like it expects that directory to be somewhere else.

Help welcome with this one as I don't know much about Equinox.

Jars which do not have any OSGi metadata should not be deployed

Currently, transitive dependencies get deployed to the bundle folder.

But if there is not OSGi metadata, it seems it is pointless to do it unless the jars are wrapped into bundles exporting everything they have. Maybe this should be an option for users to decide whether to enable or not (so that it can be really easy to get anything at all into an OSGi environment).

multiline javaArgs breaks run.sh script

example build.gradle fragment:

runOsgi {
    [...]
    javaArgs = '''
        -Djersey=true
        -Dosgi.clean=true 
    ''''

works for ./gradlew runOsgi but run.sh script looks like this:

[...]
"$JAVA"
                -Djersey=true
                -Dosgi.clean=true 
         -jar org.apache.felix.main-5.4.0.jar  "$@"

There should be '' at line ends.

Cannot override manifest headers

I am using your plugin to build my bundles but when I try to override manifest header, then incorrect value is being generated:


jar {
    manifest {
        instruction 'Bundle-Name', project.description
        instruction 'Bundle-SymbolicName', 'adm'
        instruction 'Private-Package', "com.mypackage.adm.api.*;version=${project.version}"
    }
}

MANIFEST.mf

Bundle-SymbolicName: com.mypackage.adm,adm

expected:

Bundle-SymbolicName: adm

runOsgi can not be started from IntelliJ

The task runOsgi can not be started from within IntelliJ, because it reads from system.in. Is there a way to allow user input by IntelliJ? Even if not, I think it should be possible to disable user input and let the task wait for an exit signal sent from the IDE.

:simplest-build:runOsgi FAILED
:simplest-build:runOsgi (Thread[Daemon worker,5,main]) completed. Took 0.114 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':simplest-build:runOsgi'.
> No line found

* Try:
Run with --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':simplest-build:runOsgi'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
    at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
    at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:154)
    at org.gradle.internal.Factories$1.create(Factories.java:22)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:151)
    at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
    at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99)
    at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
    at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:46)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.tooling.internal.provider.runner.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:58)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
    at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)
    at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:45)
    at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:52)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
    at org.gradle.util.Swapper.swap(Swapper.java:38)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:66)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
    at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: java.util.NoSuchElementException: No line found
    at java_util_Scanner$nextLine.call(Unknown Source)
    at com.athaydes.gradle.osgi.OsgiRunner.delegateProcessTo(OsgiRunner.groovy:56)
    at com.athaydes.gradle.osgi.OsgiRunner.run(OsgiRunner.groovy:41)
    at com.athaydes.gradle.osgi.OsgiRunner$run.call(Unknown Source)
    at com.athaydes.gradle.osgi.OsgiRunPlugin$_runOsgiTask_closure3.doCall(OsgiRunPlugin.groovy:75)
    at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:554)
    at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:535)
    at org.gradle.api.internal.tasks.TaskMutator$1.execute(TaskMutator.java:77)
    at org.gradle.api.internal.tasks.TaskMutator$1.execute(TaskMutator.java:73)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    ... 70 more


BUILD FAILED

Total time: 8.738 secs
Stopped 0 compiler daemon(s).
No line found
10:58:22: External task execution finished ':simplest-build:runOsgi --info --stacktrace'.

´´´

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.