Giter Club home page Giter Club logo

Comments (5)

pkriens avatar pkriens commented on September 28, 2024

Export-Package has 2 functions. It selects a set of packages to include from the class path and to export, Private-Package also includes but does not export. This was the original design.

However, since the annotations, the modern way is to include the full project classes and then use annotations to indicate which are exported with @Export and @Version in the package-info file. Under the hood, this uses the following instructions:

  • -includepackage – Include the given packages and process the annotations, default are all the classes in the project. However, notice that the packages may come anywhere from the class path. I.e. if bundle foo is on the class/build path, you can include its packages.
  • -privatepackage – Include the given packages but do not process the annotations, default empty
  • -exportcontents – Do not include anything but after -includeresource, and other instructions filled the JAR, export the given packages. Default empty

You can only get the default model (= all project classes) when you do not set any of them. If you touch one or *-Package, etc. you have to set them all.

Now, imho defaults work best. Why on earth do you want to use the Bundle-ClassPath? This is almost always a bad idea. I might be missing something but in your setup, there is absolutely no reason to have any setup in bnd. Just take the defaults and add the package-info.java with the export annotations to the APIs.

from bnd.

pkriens avatar pkriens commented on September 28, 2024

I think this is answered, please reopen if thre are more questions.

from bnd.

thahnen avatar thahnen commented on September 28, 2024

Hi @pkriens,

thanks for your response! This was very helpful, and in the end, I went with the -exportcontents instruction as this is what I wanted to accomplish in the first place!

I've seen this before, but from the instructions documentation page, it only contains so little info that I wasn't sure if the mentioned class path would include the Bundle-ClassPath as well.

Maybe the actual documentation of the instruction could be enhanced a bit? Thinking of the -includeresource documentation that contains a lot of different use cases and combinations with macros. Should I open a new issue ticket for that and maybe propose a small draft - in this case, with my point of view mostly for a combination of Bndtools with Maven?

To answer your valid question why on earth do we use the Bundle-ClassPath πŸ˜„
We have a shared library built with Maven that is in no way compliant with OSGi and its annotations that are used among different Java IDEs, in my case, consumed by Eclipse. Its developers have no clue about OSGi (or anything Eclipse / bundle magic related).
We use the Bundle-ClassPath so that the bundle that is then used on the Eclipse side is only one (and not many, not one per module) that we can easily exchange and shade other stuff into (this is done via Maven). So using the Bundle-ClassPath is firstly for simplification, secondly for convenience, and thirdly due to the developers having no clue of OSGi, and I'm the only one responsible for creating this Eclipse-specific OSGi bundle. So basically plugging in OSGi in a mostly non-OSGi environment to satisfy the needs of Eclipse ^^

from bnd.

chrisrueger avatar chrisrueger commented on September 28, 2024

Should I open a new issue ticket for that and maybe propose a small draft - in this case, with my point of view mostly for a combination of Bndtools with Maven?

@thahnen
Yes please, documentation improvements are very much appreciated :) A PR would be fine. You can describe the problem solved in the PR description.

from bnd.

pkriens avatar pkriens commented on September 28, 2024

Please submit a PR. However, realize that you might be surprised that the information is already there. A problem with OSGi is that some of its foundational concepts are quite new and that makes them hard to recognize. Once you have tried to explain it to others, it is clear to you why the existing documentation suddenly makes sense.

However, it is true that -includepackage and -privatepackage are relatively new, and also the default to include the project is new. I've described it in several places but it might be nice to have a single page that pulls all this together.

Please make a draft and i will try to contribute to this.

from bnd.

Related Issues (20)

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.