Blogs

SpringSource Blog

Our plans for building OSGi applications

Rob Harrop

In the recent days and weeks, we've seen an increasing amount of interest in the future of build solutions for applications made up of OSGi bundles. Due to our heavy involvement with OSGi, this is something that is near and dear to our hearts and we've spent a long time looking at customer requirements and solutions for those requirements. In this blog entry, I will outline the requirements that we have identified and present the solutions that we see to these requirements.

I'm very interested in hearing from anyone who has extra requirements, thinks the requirements we have are bogus or has better ideas for solutions.

Requirements for OSGi Build

No duplication of dependency metadata

A real problem with current OSGi builds is that dependency metadata can be duplicated in many places. For dm Server, we have dependencies described in ivy.xml, .classpath and MANIFEST.MF files. Any long-term solution for OSGi builds must require only one location for dependency metadata.

Work with existing build solutions

Given the unique nature of OSGi applications it is tempting to try and start from scratch with the build system. We entertained this idea for some time, but it became apparent that this wasn't workable technically nor was it the best solution for our users.

Our users are heavily vested in the build solution they have chosen, and making them move doesn't seem like the pragmatic approach. Instead, users want a solution that will slot nicely into their Maven or Ant builds.

Generate manifest files automatically

Probably the easiest way to move to OSGi is to start generating manifest files automatically from the associated metadata available for an application module. Ideally, this approach will lead to minimal changes to application code or to the way developers work with that code.

Derive build dependencies from OSGi manifest

Although manifest generation is a valid approach, many users are interested in treating their OSGi manifests as the canonical description of dependency metadata. These users want to drive their builds from the metadata they have written in their manifests. To support easy manifest creation, many users want to see support for manifest templates. A manifest template allows for boilerplate manifest content to be generated automatically, whilst giving users full control over important information such as versions.

This approach uses the manifest as the central dependency descriptor in the IDE and in the offline build. Developers write the OSGi manifest by hand, or with help from tooling, and the manifest is used by the build tooling in a similar way to how Maven uses the pom.xml and Ivy uses ivy.xml.

Using OSGi metadata for resolution allows for the full set of OSGi resolution rules to be applied during build. This will allow for more accurate matching of the build-time dependency resolution to the resolution that will occur at runtime.

A potential drawback of this approach is that developers will need to specify test dependencies in their manifests. Both Maven and Ivy have ways of marking dependencies for use in the test environment only, and a similar solution is needed when using manifests for dependency resolution.

Scenarios

From these requirements, we have derived four main scenarios. Interestingly, each of these scenarios is represented by one or more of the users I interact with frequently for dm Server.

1. Maven and Eclipse – pom.xml-driven

Along with the next scenario, this is the most frequent one we encounter, and it is the one we are currently spending the most time working on. With this approach, developers are carrying out their development tasks as they would for any normal Maven/Eclipse project.

The OSGi manifest file is generated by plugins for Maven and for Eclipse. The developer can choose to have the Eclipse plugin regenerate the manifest as part of the incremental build or on-demand.

Most of the metadata needed to generate the OSGi manifest can be found in the Java code (source/bytecode). However, it is not possible to derive sensible version numbers for dependencies from bytecode. In this case, versions can be extracted from the pom.xml file or from a customisable manifest template.

The manifest template can carry more information than just version numbers, allowing developers to add OSGi attributes and directives along with any custom headers.

2. Ant, Ivy and Eclipse – ivy.xml-driven

This approach is similar to the Maven, pom-driven approach except that dependency metadata will be extracted from the ivy.xml file and not from the pom.xml file.

Developers will have access to Ant tasks to perform manifest generation at the appropriate stage in the build.

The biggest drawback of this approach is the lack of compelling Ivy integration in Eclipse. For Ivy 2, the Eclipse plugin support is sadly lacking. One approach we are considering is to create the Eclipse classpath from the generated manifest. This is tooling that we already support and will be extending for the next two scenarios. Developers will write ivy.xml files, generate their manifest using the Eclipse plugin and have the Eclipse classpath updated automatically.

3. Maven and Eclipse – MANIFEST.MF-driven

In this approach, the OSGi manifest file is the definitive declaration of project dependency metadata. Developers may choose to write the entire manifest by hand, but most likely they will be writing a manifest template and letting our plugins do the rest.

The dm Server tools already come with an Eclipse classpath container that is driven by the manifest and this will be extended to support accurate transitive dependency resolution.

To support testing is this environment, the plugins will allow for both MANIFEST.MF and TEST.MF files to be written, with TEST.MF describing dependencies that apply only for testing and MANIFEST.MF describing dependencies that apply during test and production.

The last remaining piece for this scenario is how to plug into Maven. We are currently investigating two approaches: replacing/integrating with the Maven dependency resolver or generating a pom.xml file. I'm interested in hearing your opinions on which approach you think has most merit and would be most beneficial to you.

4. Ant, Ivy and Eclipse – MANIFEST.MF-driven

This approach is very similar to using Maven in a manifest-driven way. Unlike scenario 2, this scenario does not suffer from the lack of decent Ivy/Eclipse integration because we will using the same manifest-driven Eclipse classpath container as in scenario 3.

Tools for OSGi build

To address the requirements outlined we are building a suite of tools that work alongside Maven, Ant and Ivy to provide an integrated solution for building OSGi applications.

Bundlor

Bundlor is a tool that we have been using internally for some time to generate OSGi manifests. We used it predominantly to create all the bundles that you see in our Enterprise Bundle Repository. Bundlor can be used to generate manifests for legacy libraries that were created without much consideration for OSGi. Bundlor can also be used for generating manifests for bundles that you are creating specifially with OSGi in mind. Bundlor removes most of the donkey-work involved in creating high quality bundle manifests.

Bundlor supports the notion of a manifest template that allows you to customize the generated manifests. Using the template you can add versions and attributes to package imports and exports, exclude packages from exports, add imports when automatic detection is impossible and also add extra manifest headers. The code snippet below shows a manifest from one of our sample applications.

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: GreenPages Service
Bundle-SymbolicName: greenpages
Bundle-Vendor: SpringSource Inc.
Bundle-Version: 1.0
Import-Template: org.springframework.*;version="[2.5.6.A,3.0)"
Excluded-Exports: greenpages.internal

In this sample, the Excluded-Exports header is being used to prevent greenpages.internal from being exposed. The Import-Template header is used to set a version for all package names that match the org.springframework.* pattern. The project code is scanned to determine the set of possible imports and exports. The template file is then used to control which of the imports/exports in this set actually make it into the manifest and what versions they have. Importantly, the generation process will correctly generate uses metadata for you, removing one of the most tedious jobs.

Bundlor will actually support the creation of two manifest files: MANIFEST.MF and TEST.MF. The TEST.MF file will be used to describe dependencies that are needed only during test. This is important for developers who want to use manifest-driven builds but don't want to pollute production manifests with test dependencies.

In the next few weeks we will be releasing our first public milestone of Bundlor. In this release, you will be able to generate manifests for projects from within Ant and Maven, and you'll be able to customise those manifests using a manifest template. In the next few milestones after that, we'll be adding support for automatically detecting versions for dependencies from pom.xml and ivy.xml files.

We'll be switching most of our samples from hand-written manifests to use Bundlor and manifest templates in time for Bundlor 1.0 final. In addition, we will be moving dm Server to Bundlor as well, discarding all our hand-written manifests.

BundlorEclipse

BundlorEclipse is an Eclipse plugin that makes the Bundlor features available directly in your Eclipse IDE. Using this plugin, you can have fully-incremental manifest generation performed as part of your normal Eclipse build lifecycle. If, like me, you are a bit too free and easy with the save button, you can configure BundlorEclipse to only generate manifests on demand.

When combining this with the forthcoming dm Server in-container test framework, you'll be able to launch full dm Server test environments, complete with manifest files for all your bundles, all from within Eclipse.

Offline dependency resolver

OSGi has its own rules for how dependencies between modules are resolved and how these are validated and turned into a consistent class space. Outside of OSGi, build tools work on a flat classpath which lists the JARs and directories to search for classes.

To support a manifest-driven build, we'll be creating an offline dependency resolver that performs OSGi resolution without starting Equinox or dm Server. We'll be pairing this with a tool that will flatten on OSGi resolution graph into a simple classpath for compile and test. This flattening process will be fully configurable by users who will be able to supply policy information to govern how multiple versions in the OSGi graph are mapped to a single version in the classpath.

Manifest classpath container

Using the dependency resolver, we'll be able to improve our manifest classpath container to create a full, transitive classpath for each Eclipse project.

Maven/Ivy dependency resolver/pom.xml/ivy.xml generator

The dependency resolver will also form the core part of our dependency resolver/pom.xml/ivy.xml generator tool. The critical observation here being that as a developer you should expect to get consistent results inside Eclipse and in your build tool.

Why Bundlor and not Bnd?

As you may be aware, Peter Kriens, OSGi Technical Director, makes available a tool called bnd that serves a similar purpose to Bundlor. Our original position was to use bnd for our own projects and to use it as part of our tooling. Indeed, the Spring Dynamic Modules was using bnd to create its bundles long before Bundlor came along. So why did we decide to create Bundlor?

The main reason for creating for creating Bundlor was that we had to support some additional features that weren't present in bnd such as:

  • JDT-based source code scanning
  • Partial code handling
  • Incremental manifest creation

These features are used to support BundlorEclipse. We use JDT-based scanning in place of bytecode scanning in Eclipse to improve the user experience and to get much better integration into the Eclipse build lifecycle. Eclipse handles partially correct code quite well, and we wanted Bundlor to be able to support partial code in much the same way.

In BundlorEclipse, it is possible to configure Bundlor to run every time you save changes in the IDE. To make this performant, we support incremental manifest generation. When you make changes to your code, Bundlor can track what changes have to be made to manifest files and avoid having to recreate all manifests.

Working with IDEs other than Eclipse

We are aware that, although Eclipse is the dominant IDE for Java developers, there is still a significant number of developers running IDEs such as IntelliJ and NetBeans.

Whilst we won't be committing to build any plugins for these IDEs ourselves we will be making all the tools described available as open source enabling other people to create plugins for their favorite IDEs.

Our approach to building our tools has been to try and encapsulate as much functionality as possible in general-purpose libraries. We are committed to working with the NetBeans and IntelliJ teams to help them integrate our tool libraries into their IDEs.

The ideal end result is that no matter what IDE you are using, you can still get access to the same underlying OSGi tools.

Further requirements

The requirements for OSGi build don't stop with the 4 scenarios that I've outlined. There are many more features and enhancements that can improve the experience for developers working with OSGi applications.

Bulk bundle generation

Many shops will have a large backlog of JAR artifacts that are not OSGi bundles. We plan to extend Bundlor to support bulk bundle generation. In this mode, you will be able to save time by pointing Bundlor at a directory of JARs and having Bundlor create bundles for all of them. In addition, to this, Bundlor will be able to use the relationships between these artifacts to work out what the version ranges for dependencies should be. This will reduce the amount of template code you have to write whilst still resulting in high-quality bundles.

Repository-driven code completion

When building dm Server applications with manifest-driven builds, you have to write the initial manifest imports by hand. With support for repository-driven code completion, you will be able to get Eclipse code completion against the dm Server repository that will generate both Java imports and manifest imports. Using this feature, you'll be able to build up your manifest dependencies as needed, without having to switch to the manifest file.

Similar Posts

Share this Post
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • DZone
  • LinkedIn
  • Slashdot
  • Technorati
  • Twitter
 

36 responses


  1. Wouldn't be nice to bring dependencies to an higher level introducing the concept of libraries. I know Spring DM server already have this: is there any plan to make libraries part of the OSGi standard?

    Andrea


  2. I could not be more excited about this direction. Existing build tools such as Maven and Ivy excel at automating application dependency management at build time. However, these tools simply do not address dependency management *at runtime*. What Rob has outlined enables a consistent approach to automating dependency management that supports buildtime *and* runtime resolution needs, with no duplication of dependency metadata between these scopes. This goes further than we ever have before in the Enterprise Java community, and it is extremely exciting work!


  3. @Andrea
    Libraries are obviously a way to group a set of related and compatible bundles together and as you know we have done this with Spring and AspectJ.
    But one of the beautiful things about libraries is that user could assemble their own relatively simple, by creating a .libd file describing such set of related bundles and place it in repositories/libraries/usr directory. One example would be to assemble a library which consists of bundles related to your application and not some other concept (such as framework or product)
    For example:
    org.bar-library-1.0.0.libd – would consists of :

    Library-SymbolicName: org.bar
    Library-Version: 1.0.0
    Library-Name: Bar Application
    Import-Bundle:
    foo.bar;version="[1.0.0, 2.0.0]",
    abc.xyz;version="[1.0.0, 2.0.0]


  4. Rob, thanks for excellent article. I was waiting for a long time for discussion of those issues. But one thing is missing here: there is no mention about "Spring Build" in your article. "Spring Build" is a mysterious term, that pops up from time to time, but it's virtually impossible to find any info about it. From what I assume, it is a system used for building Spring Framework itself. I always thought that creating it (instead of simply using Maven, for example) was dictated by OSGI needs. So how do you actually build Spring 3.0, which is, I guess, already OSGI-aware? Is there some relation between "Spring Build" and, say, Bundlor? Also it seemed to me that "Spring Build" uses Ant Ivy, and I was curious what was the reasons for this choice against Maven: but your article gives the impression, that you don't see any significant difference between Ant Ivy and Maven… This makes it even more mysterious :)

    When I first came across OSGI, my first impression was: that's pretty impressive system, and looks like ideal solution of run-time modularization and dependency management. I already got used to Maven at that time, and it worked very good for me as build-time modularization and dependency management. So my immediate thought was "why not marry those two?". I started to search for information about such work, but found actually nothing. Unfortunately, I still had no time to learn much about OSGI and dig into Maven internals to do some research on it (I tried to study Maven code once, but wasn't able to understand single bit of it). The strange thing is that long time passed, and still there is not much info about any progress in this area. I've only found some thread on maven-dev list related to it some time ago: http://mail-archives.apache.org/mod_mbox/maven-dev/200805.mbox/.
    My feeling is that OSGI is standard now, and Manifest metadata are therefore standard too, wheras pom.xml or ivy.xml are not. So I would say, that proper direction is to remove dependencies declaration from pom.xml (or ivy.xml) and store them in one, standard place: manifest file. Then all tools can use it, both at build and run time: Maven, Ivy, Eclipse, Netbeans, dm Server, etc. There are some drawbacks obviously: properties file syntax used in manifest is a bit limited and ugly compared to XML (though Maven bloated syntax is not much better IMHO). There is also problem with test dependencies: solution is to use other file (TEST.MF? MANIFEST-TEST.MF?) or put it into manifest with different section/keys. It can be then stripped off during build, but actually don't have to: their presence will not harm anyway. This approach can even be extended. I always believed that maven advantage over ant is that it gives to other tools the kind of API for project metadata, which can be used by e.g. IDEs to automatically find information about project structure (where is source directory, where is test directory, where is target directory), about project name, version, packaging type etc. This is powerful capability. But actually all those metadata could be standardized (by some JCR?), at put for example into manifest file (again, project structure metadata could be stripped off during build, but project name, version etc – not). Some of those metadata already exists in manifest: Bundle-Name, Bundle-SymbolicName could replace maven's name, groupId, and artifactId metadata (BTW: how did they came at Maven to this horrible idea of artifactId and groupId instead of just using base package as ID??? that's one of the most annoying "small issues" in maven IMHO). So we would end up with manifest file as the central place of storing project metadata. Some of them could be used by tools like maven, and, eclipse or netbeans, and some at runtime by OSGI. This would simplify also project portability between IDEs.


  5. @Gregor,

    Thanks for your great comments. I'll try to address all your queries as best I can.

    With regards to Maven vs. Ivy, I personally don't really have much of an opinion. I use Spring Build (more on that later) for building dm Server, which is Ivy-based. I also use Maven for building some of our samples. Indeed, we'll be releasing a sample application to accompany our forthcoming dm Server Getting Started Guide that using Maven for its build.

    The one thing that Maven and Ant/Ivy share in common is that the overall experience frustrates me. I hope that our tools can go a long way towards making the modular build experience painless.

    What is clear to me is that a lot of people are passionate about Maven and a lot are passionate about Ant/Ivy. I don't think there is any 'right' answer and I'm certainly happy to try to support both camps.

    Spring Build is an implementation of Ant and Ivy that we use to build our products. It uses Bundlor internally, and will of course grow to encompass more of our build components. I don't foresee a world where Spring Build is ever really packaged up for end user consumption, but you can never say never. Certainly, if you are planning to use Ant and Ivy for your build, Spring Build is one of the best implementations I have seen. Spring Build is good reference material when creating an Ant build.

    There are some strong feelings on both sides of the argument about whether or not manifests are a good location for canonical metadata. My hope is that Bundlor templates will become *the* way to write manifests. Then users can choose whether they want to bolster the template information with Maven/Ivy metadata or whether they want to go all the way and use the manifest as their dependency master file. My own personal preference tilts between the two options. Because of this I realized that the best approach is to do both artifact-first and manifest-first as well as they can be done, and then let the users decide which is best.

    Regards,

    Rob


  6. Will the above mentioned tools be integrated into Spring IDE or only SpringSource Tools Suite ?


  7. Rob,
    I think your reasons for not using BND and instead "roll your own" is very weak, and probably not the actual reasons behind the decision. What those are, I can only speculate, "Not Invented Here" is a strong candidate, "Control-mania" is another…

    Never-the-less, I think you are doing Monkey-Service to the OSGi community with this fracture, instead of in a collaborative manner build upon and evolve tools many of us are already using.

    Sorry, but I will not recommend people down this path.


  8. Is Bundlor documented somewhere?


  9. BTW, what was the reasoning behind introducing yet more non-standard headers such as "Import-Template" and "Excluded-Exports" rather than re-using some of the grammar/syntax from bnd? I can understand re-implementing the back-end tooling to support new features such as partial code, but AFAIK that doesn't stop you from taking the best bits from the bnd instructions.

    Sounds like a good topic for the OSGi Tool Summit – a standard build grammar/syntax for adding versions to packages, removing spurious imports, marking exports, etc. would be very helpful to avoid locking developers into a single tool-chain. WDYT?

    Would also mean less to learn when moving between the different OSGi build tools :)


  10. Recently there was a discussion "OSGi and future directions for Enterprise Java" on theserverside (http://www.theserverside.com/news/thread.tss?thread_id=53803).
    In my opinion one of the biggest problems with OSGi/Maven2 is the mess in M2 repositories, and SpringSource has added a little to this mess :) What do you think about repackaging existing M2 artifacts (e.g. commons-logging) under different artifactId with OSGi metadata added? Why this metadata isn't external? I know – if I'm using OSGi, I should user SpringSource Enterprise Repository. But what if I don't? I just want to use Spring3.

    I also know, that this issue with Spring3 was raised on JIRA (and recently SPR-5385 was moved from 3.0 RC1 to 3.0 M3) – but the solution with duplicating POMs is (for me) not such a good idea – though my POMs with Spring3 dependencies (based on repo1.maven.org) would work, I would feel uneasy that there are other POMs for the same artifacts. Yes – it's about aforementioned Spring-Build…

    Grzegorz Grzybek


  11. @Stuart,

    There will be complete user documentation and a blog entry accompanying the forthcoming release of Bundlor. This release is planned for the near future.


  12. Recently there was a discussion on theserverside "OSGi and future directions for Enterprise Java" (http://www.theserverside.com/news/thread.tss?thread_id=53803).
    I think that one of the biggest problems with OSGi/Maven2 is the mess in M2 repositories, and SpringSource added a little to this mess.
    What do you think about duplicating M2 artifacts by repackaging old JARs (e.g. commons-logging) with new artifactId and OSGi metadata? Shouldn't this metadata be external to existing JARs?
    There's a JIRA issue (SPR-5385) which recently was moved from 3.0 RC1 to 3.0 M3 (which means is important) about duplicating Spring3 POMs (for SpringSource Enterprise Repository and repo1.maven.org). I know – now (with 3.0 M3) my POMs depending on Spring3 would work without tons of s but I would feel a little uneasy knowing that there are other Spring3 POMs. And yes – I'm also wondering what Spring-Build is and why it is not just maven2 build with POM packaging. Maybe Spring3 is sooo difficult to build, but why Spring-Integration? (Spring-WS has nice M2 build).

    with best regards
    Grzegorz Grzybek


  13. Sory for two almost-same posts – your captcha did not show an image :)


  14. @Cameron

    BundlorEclipse will be released either as a standalone plugin or as part of Spring IDE. In fact, we may well release it in both forms.

    Regards,

    Rob


  15. @Rob

    "a standalone plugin" means a Maven plugin / Ant task, right?

    Regards,
    Ollie


  16. @Stuart,
    We are very open to a discussion on standardizing template headers etc.. The bnd headers are equally non-standard (there are no OSGi RFPs or RFCs on this topic to date), though of course they have a de-facto status by being the only option to date. Our preferred route for standardization is always to get solutions out into the community, learn from the experience, and then standardize what has been proven to work. For the record, we did have discussions with Peter as far back as January of last year (2008) before setting off on our own path with Bundlor.


  17. @Ollie

    "a standalone plugin" means an Eclipse plugin that you could install without necessarily having to install all of SpringIDE (if for example you wanted to use Bundlor without also developing Spring applications). We will in addition have a maven plugin and ant task.

    – Adrian.


  18. Excellent news, really waiting for OSGi tool-chain to finally take shape.

    However, as with some others here, I'm a bit puzzled as to why not working with the existing stuff, instead of rolling your own?

    As Niclas pointed out, "bnd" could have been used as basis for some stuff.
    And you could have worked together with Paremus to improve Sigil (http://sigil.codecauldron.org/). Or perhaps share some components.

    Sigil seems to share a lot with your (manifest-first) approach:
    * works well with Ivy (uses OSGi resolution mechanism for CLI building)
    * works well with Eclipse (uses OSGi resolution mechanism for IDE building)

    What you say? ;-)

    Rgds,
    Neeme


  19. I've been posting a few questions about SpringSource's and Sonatype's roadmap surrounding OSGi build support for a little while so I'm really glad to see this post. What's unclear for me still is what is your recommendation for today? This concerns me as we're about to start a project which would be a good first attempt for our company to use OSGi.

    I can see that if we're strictly concerned with Eclipse, the workflow – especially if we chose to deploy to Spring DM Server – would be pretty smooth. How should we handle the automated builds _today_, though? What would the situation be WRT CI, unit testing, code coverage? We've been successfully using Maven 2 with the m2eclipse plugin for Eclipse integration, so far. It's been working pretty well for us (minus the odd hiccup). Sonatype has created Tycho to work alongside Maven to address OSGi needs, but they, sort of like SpringSource, seem to be going down an individual path for achieving their respective end. With Sonatype's toolset, I can't easily take advantage of some of the Spring specific extensions to OSGi – at least not in a combined, command-line/Eclipse environment. Jason, from Sonatype, mentioned that they're resource constrained and so have enough on their plate in supporting standard OSGi, let alone SpringSource extensions. This is perfectly understandable, but, even though officially denied by both sides, I can't help but notice that there is not a lot of love going on out there and that there isn't as much co-operation between the two companies as there could be. I suppose they might be feeling that you are encroaching on their territory with this stuff – some might agree.

    I'm curious how you advise clients at present when they're considering development for Spring DM Server. Is there anyone out there who considers that building solely from the Eclipse environment is good enough? Are you recommending they create builds using the Spring build as an example and are they willing to do this even though they might be Maven shops?

    I guess, if we had a better feel for when some good enough, Maven, command-line support would be available, we might choose to work from within Eclipse only if it was a matter of just a few weeks. Hard to know how to proceed as things stand.

    Cheers,

    Adrian


  20. @Adrian,

    thanks for your comments. Building solely from Eclipse is definitely not the way to go for enterprise projects. Our end goal is to provide tools and integrations that enable developers to use the build system and IDE environment that they choose, to build, test and publish OSGi applications.

    If Maven works well for you today there is no need to move off that path going forward. As Rob mentioned earlier we'll publish a Getting Started Guide that will highlight how you can use Maven, Bundlor and our dm Server Tools (incl. BundlorEclipse) to build OSGi applications in an Artifact-first fashion (manage dependencies in your pom.xml).

    Related to your comment of SpringSource "seem to be going down an individual path" I can tell you that I'll be attending a Tool Summit organized by the OSGi Alliance next week to discuss the current movement in the OSGi tooling space.

    Regards,

    Christian


  21. @Christian

    I guess I wasn't clear enough wrt Maven – it has worked for us for non OSGi development. Now that we'd like to get started with this, I don't see a satisfactory present day solution that allows for Maven use for headless builds and includes Eclipse support for development – hence my question about what does SpringSource advise customers who, right now, want to get going with OSGi and Spring DM Server development. If using Maven in this command-line/IDE integrated mode is not a possibility today what are the options? Or, do you simply advise that it is still too early to get going on significant projects because at present you either get a decent command-line build or a decent Eclipse build, but not the two together.

    Thanks for any insight,
    Adrian


  22. This is great news for the company that I work for. This artifact-first, pom.xml-driven way of doing osgi development is really what we need. All of our builds are done through maven and it is what glues our entire development process together. To throw all that away to be able to do OSGi would have been a sacrifice I would not have been willing to make.

    @Rob
    You wrote that you were tempted to write your own new build system. Just out of curiosity, what was so tempting? What do you feel would have been an improvement? Or are you just *that* frustrated about maven? ;)

    @Christian
    I saw some 'bundlor' packages being installed with STS, correct? Does that mean that STS will incorporate bundlor right when it is released?

    Anyway, I will be awaiting the release of bundlor anxiously :)


  23. @Hans

    We originally had a grand idea for a build system that had intimate knowledge of and be built on OSGi. The dependency resolution mechanism would be built on top of the OSGi resolver and all metadata would be driven by manifests. Likewise, we wanted something that required a little less configuration than Maven does for some of the more complex cases.

    In the end though, the requirement to run on existing build systems was just too great.

    Regards,

    Rob


  24. Rob,

    In response to "We originally had a grand idea for a build system that had intimate knowledge of and be built on OSGi. The dependency resolution mechanism would be built on top of the OSGi resolver and all metadata would be driven by manifests."

    This has existed for a couple years in the form of Tycho. We use the OSGi resolver, we use JDT to enforce modularity and it can use MANIFEST.MF files directly and there is not that much configuration. It's all open and it all works pretty well. You can find it here.

    http://svn.sonatype.org/m2eclipse/tycho/trunk/

    We have been building our Eclipse plugins with it, so we have fully automated builds running in Hudson. Server side usages is not much different then this. We also have full P2 repository support with Nexus. If you take a look at:

    http://osgi.sonatype.org

    You'll see that we already have Orbit, ApsectJ, Ganymede, Subclipse and m2e itself in there. So we have full round-trip support for Maven users that want to build in a MANIFEST-first. There is support in Tycho for POM-first but we focused on MANIFEST-first mode. So we can publish bundles to Nexus and consume bundles.

    We were lucky that AGFA graciously donated the initial code and it has been in production use for many years. We are trying to continue to improve those tools and try and make standard OSGi tools all Maven users can use.

    Thanks,

    Jason van Zyl


  25. Where do Eclipse PDE headless builds fit into all this? For our ongoing product development, we are building both a server-side Equinox/Spring-DM application (wrapped into a Windows service) as well as an RCP/Spring-DM application, and PDE/Build handles this quite nicely (after getting over the somewhat painful setup of the headless build, Eclipse's weird target setup and Spring Framework's surprising circular dependencies, which PDE/build can't handle). Bits & pieces of ant, make and Visual Studio devenv (gasp!) are thrown in for the more esoteric components.

    For us, this turns out to be a reasonable way to combine interactive IDE development with automated builds, and have all the target, source and configuration come out of revision control. Is this kind if setup too Eclipse-specific for you to worry about?


  26. @Jan,

    we use PDE heavily for building Spring IDE, dm Server Tools and STS ourselves, but I don't think that PDE build is a solution that can be considered a general purpose OSGi build system: IMHO PDE build is too focused around building Eclipse features and plugins. But I can envision integration of our ANT tasks (Bundlor Manifest generation, etc.) into an PDE build environment. We'll make sure to keep that path as open as possible for our users.

    BTW. have you tried using "allowBinaryCycles=true" in your build.properties to allow PDE handle cyclic binary dependencies? That should solve the problem with some of the Spring bundles.

    Christian


  27. @Hans,

    you are right. There are some Bundlor packages inside STS and we'll bundle BundlorEclipse with STS very timely. But – as Rob and Adrian – pointed out, BundlorEclipse will be available under the EPL-license as a separate installable set of Eclipse plugins. Stay tuned for more on the Bundlor Eclipse integration.

    Regards,

    Christian


  28. I think the ongoing discussion is too much focused on tools. Which tools should I use? Who provides those tools? Do we need new tools or can we extend existing tools?

    I see at least two much more fundamental problem areas which must be tackled prior to ever being able to have a satisfying set of tools for all of us:

    1. Compatibility of dependency meta models

    Before deciding whether we better store dependency meta data in OSGi manifests, pom.xml or ivy.xml it is necessary to understand the differences between their dependency meta models, see if there exists a one-to-one correspondence between all of them and if not, decide which meta model (not tooling) should be the standard dependency meta model for Java development in the future.

    In OSGi alone the question if we think in packages (Import-Package) or in bundles (Require-Bundle) when it comes to dependencies is not yet answered. The question which approach to use cannot easily be answered because both have pros and cons. The pragmatic solution to combine both (Import-Bundle) by introducing a new header as done in dm Server is understandable, but it just blurs the two concepts without answering the underlying theoretical question, which concept is better (from a meta model point of view, not from a programmer's view, who wants to write as few lines as possible).

    2. Bundle vendor chaos

    We cannot solve organizational problems with technical solutions. If I could not register a domain and provide an authoritative DNS server, I could not guarantee that everybody who wants to see my website, can actually see my website. If we could not use globally unique IP addresses, not even the best algorithm could help us to establish an internet.

    If I want to use commons-logging with OSGi and am spoilt for choice between tons of different bundles packaged by different vendors which basically provide the same functionality, I need not be surprised, when at some point I will run into dependency resolutions problems because two bundles I want to use have a different conception about resolving their dependency to commons-logging. Of course, at this point "Import-Package" seems to be the most robust and flexible solution to cope with that mess. But the mess is not removed, it's just covered a little.

    We should not weaken the strictness of the dependency resolution mechanism by using a fuzzy notion like "package" (a package name is not yet a specification for which implementations are interchangeable). But we should increase the strictness by introducing authoritative bundle vendors/repositories. This is an organizational challenge, not a technical. We have a convention for package names so that packages are related to top level domains. If we use the same convention for bundle names, we could give every domain owner the possibility to define the authoritative repositories for bundles belonging to the respective domain.

    org.apache could for example appoint the SpringSource Enterprise Bundle Repository as the authoritative repository for commons-logging. Or they provide their own repository, which is easily found by everyone who wants to use commons-logging by basically using the same mechanism as DNS. In such a world, "Require-Bundle" would not break things because everyone would use the same bundles.

    I highly appreciate SpringSource's active and pragmatic approach, but would like to see even more interaction with the community before introducing non-standard concepts like "Import-Bundle" or by completely reimplementing tools for which a de facto standard exists because in a global perspective, this makes the Java world more complex again, eating up the improvements definitely made in a local perspective.


  29. I really favour the pom.xml-driven variant described above. But to it seems as there is one major disadvantage which was not discussed here:

    If pom.xml is the only place where I declare my dependencies, it has to be possible to add SpringSource EBR to the Maven Indexes of m2eclipse. Otherwise I think adding dependency declarations by hand is too cumbersome. I thinke there is already a request for this in JIRA.


  30. When will the Offline Dependency Resolver be available? It will be a great tool.

    Before it is avaiable, is this function available as part of spring dm, Felix, or Equinox ? That can be accessed as a Java API or a standalone tool?

    Stanley


  31. @Stanley

    We haven't made a huge amount of progress on integrating the resolver into a build tool simply because the demand was not as great as we imagined. If you are looking for an offline OSGi resolver, you can use the Equinox resolver offline. Its actually pretty easy to get going with the resolver in Equinox.

    Rob


  32. Thanks Rob.

    Do you have pointers or links to get started on the Equinox offline resolver?

    I want to start as a standalone Java app to explore. And later on, I may build a plug-in to integrate that with other build/installation toolings.


  33. @Stanley,

    The best code example I can think of is the code we wrote in dm Server to do resolver-driven provisioning. You can find the latest incarnation of this here: http://bit.ly/pJDOA

    Regards,

    Rob


  34. @Rob : what do you think about tycho. it seems to have solved some of your issues already .

    chris


  35. Hi All,

    Regarding Tooling

    In my quest to find a better solution I stumbled on Gradle (http://www.gradle.org). It uses ANT and Ivy but without the XML. It knows about Maven and Ivy repos and it is open for extension.

    Just my $.02


  36. Where I can find documentation about "Offline dependency resolver" ?
    Is there a way I can use this with Maven or Ant or from command line?

4 trackbacks

Leave a Reply