views:

417

answers:

2

I'm trying to compile down a set of plug-ins (ultimately OSGi bundles) into a feature using Eclipse PDE tools. I have a custom Target Platform based on the Spring framework.

When I export the feature through Eclipse's Export Wizard the feature builds successfully, however, when I try to generate an Ant build script from the feature.xml file I receive an error about "cycles". After doing some research, I found out there's an "Allow for binary cycles in target platform" checkbox in the Export Wizard -- unchecking it produces the same result I see when trying to use PDE tools to generate the Ant build file.

I've tried saving the Ant build file from the Export Wizard, but when I execute the Ant build file I receive the same error indicating a cycle exists (and it references the target platform bundles).

Additionally, I've tried setting "allowBinaryCycles = true" in the build.properties file and also as a property on the Ant Build script -- neither affected the result.

How do I run the generated Ant build file from the Export Wizard such that binary cycles are allowed in the target platform?

Edit: To be clear, the error here exists within the Target Platform (ie: the Spring Framework!). It turns out a cycle exists in Spring Framework between the Context and ORM bundles. This is somewhat annoying, and two decent workarounds exist:

  1. Exclude the ORM bundle if it's unneeded (turns out this was my best solution)
  2. Remove the dynamic dependency on the Context bundle from the ORM bundle.

Some discussion on the Spring Forums assisted in resolving this issue.

These solutions are particular to Spring, of course. There seems to be a second issue -- this time with Eclipse as a builder -- that the option to allow these binary cycles (however wrong and awful they may be) only exists in the GUI version of the builder. One would hope that eventually this option will make its way into the Ant build tasks.

+1  A: 

It's often painful to resolve, but cycles are a code smell, if possible you should remove them rather than work round them. You'll save effort in the long term.

A hacky workaround would be to build a composite classpath from the plugins' dependencies, then compile all classes in one go. Add the resultant classes to the path and build each plugin in turn.

Rich Seller
While I agree with you that cycles are problematic at a code level, these particular cycles are a bug in the Spring Framework, and the subject of some serious discussion. While I would love to fix Spring's problems my preference is to deploy a system that successfully runs within my development environment, and ultimately there are a few workarounds that work well here...
Mark E
ok, I did say if it is possible remove them, you didn't say in your question that the cycles were in Spring code in your question, just that you were based on Spring. I've suggested an approach that may work, have you looked into it?
Rich Seller
Sorry for not being more clear -- I did mention the issue was calling out the Spring Target Platform. Since excluding the ORM bundle allows the build task to complete I haven't tried your solution...exclusion of this bundle is no more hacky than using a composite classpath.
Mark E
well at least you have a solution, and the composite classpath is definitely not an ideal approach
Rich Seller
A: 

It turns out a cycle exists in Spring Framework between the Context and ORM bundles. This is somewhat annoying, and two decent workarounds exist:

  1. Exclude the ORM bundle if it's unneeded (turns out this was my best solution)
  2. Remove the dynamic dependency on the Context bundle from the ORM bundle.

Some discussion on the Spring Forums assisted in resolving this issue.

These solutions are particular to Spring, of course. There seems to be a second issue -- this time with Eclipse as a builder -- that the option to allow these binary cycles (however wrong and awful they may be) only exists in the GUI version of the builder. One would hope that eventually this option will make its way into the Ant build tasks.

Mark E