Reputation: 61091
How can I create a simple bundle with an Activator in bndtools? It keeps saying that:
The JAR is empty: The instructions for the JAR named com.myproj did not cause any content to be included, this is likely wrong bnd.bnd /com.myproj Unknown Bndtools Problem Marker
Unused Private-Package instructions, no such package(s) on the class path: [com.myproj] bnd.bnd /com.myproj Unknown Bndtools Problem Marker
The way I create this project in Eclipse is:
Activator.java
in package com.myproj
.com.myproj
to private packagescom.Activator
Here is my bnd file:
Bundle-Activator: com.myproj.Activator
Private-Package: com.myproj
My generated jar is empty. Any tips?
P.S.: Here is my eclipse project (exported as a zip-archive) in case it sheds any light on things: https://dl.dropbox.com/u/9162958/scraper.zip
Upvotes: 1
Views: 2623
Reputation: 1841
scraper.zip
.cnf
project was automatically created.bnd
is configured to use the bin
directory for compiled *.class
files while your Eclipse project is configured to use target/classes
. Therefore, I had to change this settings in cnf/build.bnd
by adding a single line:########################
## BND BUILD SETTINGS ##
########################
bin: target/classes
bnd
creates generated/scraper.jar
that contains your Activator.class
.bin
directory instead of target/classes
but I assume that you will use Maven later on.bndtools
, it sometimes helps when you start with an empty workspace and import your projects one-by-one.Upvotes: 1
Reputation: 15372
My guess is that "Convert to Maven project" is the trouble. This likely has changed the Eclipse classpath for the project from the bnd default bin folder to 'target/classes'. Can you confirm that it works without converting to maven?
bnd can work with other places for the bin folder, you must set the ${bin}
property (preferably in cnf/build.bnd
). There are some writeups how to use bndtools with maven. The reason that bnd does not follow Eclipse's settings here is that they are not available without Eclipse and a design goal of bnd is that it builds anywhere: the bnd file must therefore be the final arbiter of information.
Anyway one more tip ... activators are not the right way to build OSGi builds since they are an evil singleton. Declarative services is far superior and we should actually have used a similar mechanism when we designed OSGi.
Upvotes: 3