Skip to main content
Jump to: navigation, search

Hello XML World Example (Buckminster)

Revision as of 08:03, 20 November 2007 by (Talk | contribs) (The RMAP)

< To: Buckminster Project

Overview of the Example

This examples shows several Buckminster features in action. What these components actualy do when they are executed is not that interesting - there is an XML file with "worlds", there is a world producer and a class that says "hello" to worlds.

If you want to see the difference between setting up this example project manually, and how it works when running Buckminster, see the usage scenario Sharing a Project.

Here is an overview of what is going on:


  • The A component is called
    • It lives in a CVS repository
    • It is an Eclipse plugin - it has some meta data
    • A has a dependency on B
  • The B component is called org.demo.xml.provider
    • It lives in a CVS repository
    • It is an Eclipse plugin - it has some meta data
    • It requires two jars; the jar in component D, and a jar that is built by component C.
  • Component C is called org.demo.worlds
    • It lives in a CVS repository
    • Although it is an Eclipse project, it is not an Eclipse plugin.
  • Component D is a sax parser called se.tada.util.sax
    • It lives in binary form in the maven repository at Ibiblio

To run the example:

That will start the Buckminster materialization of the project.


The CQuery looks like this:

<?xml version="1.0" encoding="UTF-8"?>
      componentType="osgi.bundle" versionType="OSGi"/>

This is what the XML in the CQUERY means:

  • The first two lines are the usual XML incantations, the first two indicating that this is XML, and this is the syntax of the XML - i.e. CQuery-1.0 and the namespace is called "cq".
  • The third line declares where the resource map to use when resolving components is found (we will look at the resource map next).
  • Next line states that the wanted (root) component is called, that it is a plugin and that it follows the OSGi versioning scheme.

For more details see CQUERY


This is what the RMAP looks like:

<?xml version="1.0" encoding="UTF-8"?>

  <searchPath name="default">
        <bc:propertyRef key="buckminster.component" />

  <locator searchPathRef="default" pattern="^org\.demo\..*" />
  <redirect href="" pattern=".*"/>

This is what the RMAP XML means:

  • The 6 first lines declare the name spaces and syntax of the rmap and the repository providers needed.
  • Below that you see a search path element called default.
  • Continue down and you see a locator and a redirect declaration. The pattern of those declarations are matched in the order that they are declared. The first match wins and the match stops.
    • the locator states that if a component name starts with org.demo. then the search path named "default" in this rmap should be used.
    • the redirect states that all other names should be delegated to another rmap (and its locators and redirects).
  • Back to the default searchPath:
    • A provider for a Subversion type repository is declared with a URL that, after parameter substitution, will point to the component root.
    • This name is obtained from the preset property buckminster.component which contains the name of the component being matched.
    • The provider will provide source (source=true).

The CSPEC in Component C

Since component C - org.demo.worlds is not a plugin and thus lack meta data that describes its dependencies, and how to produce it, we need to add this information. We decide to use Buckminster's CSPEC XML language. This is what we place in a file called buckminster.cspec inside component C:

<?xml version="1.0" encoding="UTF-8"?>
<cs:cspec xmlns:cs="" name="org.demo.worlds">
    	<cs:public name="source" path="src/"/>
        <cs:public name="java.binary.archives" actor="ant">
                <cs:property key="buildFile" value="make/build.xml"/>
            <cs:prerequisites alias="input">
                <cs:attribute name=""/>
            <cs:products alias="output" base="bin/jars/">
                <cs:path path="worlds.jar"/>
        <cs:private name="">
                <cs:attribute name="source"/>
            <cs:products base="bin/classes/">
                <cs:path path="."/>
    	<cs:public name="java.binaries">
    		<cs:attribute name=""/>

This meta data does the following:

  • First two lines declare that this is XML, and that it follows the CSPEC format, and it describes a component called org.demo.worlds
  • Next section lists the component attributes that are artifacts (i.e. a static declaration of paths).
    • There is only one declaration, a public attribute called source that is mapped to a directory called src. Notice that the name ends with a slash to denote that we refer to the directory.
  • Next section lists the component attributes that are implemented as actions (i.e. computed attribute values).
    • java.binary.archives is the first
      • It is implemented using an ANT action, and parameters are set
      • Then there is one pre-requisite - the local attribute is needed before this action can execute.

The CSPEX in the B Component

The B components component meta data is created from the information in the Eclipse plug-in. But there are things we want to add that can not be declared in the regular plug-in meta data. Buckminster makes it possible to extend the generated CSPEC by adding a file buckminster.cspex. This file follows the CSPEC format. In this example this is straight forward as we are only adding things. Here is the content of the CSPEX file for component B (org.demo.xml.provider).

<?xml version="1.0" encoding="UTF-8"?>
		<cs:dependency name="org.demo.worlds" componentType="osgi.bundle"/>
		<cs:dependency name="se.tada.util.sax"  versionDesignator="1.0.0" versionType="OSGi"/>


		<cs:private name="buckminster.prebind" actor="ant">

				<cs:property key="buildFile" value="make/prebind.xml" />

				<cs:attribute component="se.tada.util.sax" alias="tada-sax.jar" name="java.binary.archives"/>
				<cs:attribute component="org.demo.worlds" alias="worlds.jar" name="java.binary.archives"/>

			<cs:products alias="output">
				<cs:path path="jars/" />



This extension works as follows:

  • Lines 1-4 is the XML stuff and declaration of namespaces. Note the use of a cspecExtension element as the top most element.
  • Next, two component dependencies are listed, on the component org.demo.worlds (a plugin ("osgi.bundle")), and on the tada sax-parser se.tada.util.sax.
  • The following actions section declares a private "prebind" action - this action kicks in before the component content is bound to the Eclipse workspace. As you can see, the action is an ant action, and it uses a make/prebind.xml file with the instructions for the build.
    • There are two pre-requisites - on the sax parser, and on a jar file called worlds-jar that is obtained from the attribute java.binary.archives in the component org.demo.worlds
    • The products section declares that the result is called output and where the output is produced.

Demo flow

The following takes place when Buckminster resolves the query.

  1. Resolving the CSPEC for all components
    1. The name of the top component in the CQUERY is resolved to the default searchPath in the RMAP.
    2. The SVN provider of this RMAP is chosen (it's the only one)
    3. The eclipse.project componentType will obtain the ProjectDescriptor (the .project) from the eclipse project.
    4. From the natures of that descriptor, it will conclude that the component is a plugin.
    5. The component type will use a PluginBuilder to create a CSPEC from the plugin manifest files.
    6. This CSPEC will contain a dependency to the org.demo.xml.provider component.
    7. Buckminster now resolves that component in the exact same #1 to #6
    8. The CSPEC from org.demo.xml.provider is augmented with a CSPEC extension (CSPEX) that adds the jar dependencies (since those cannot be fully expressed in the plugin manifest)
    9. The first jar dependency is resolved using the same provider as before but the ProjectDescriptor has no plugin nature this time so the CSPEC that has been checked in with the component instead.
    10. The second jar is resolved using the maven search path and the maven repository.
  2. Materializing and binding the components
    1. All components are copied (by Buckminster) to the local disk using the chosen providers.
    2. The bind phase starts and components are bound in dependency order.
    3. The first component that becomes known to Eclipse is org.demo.worlds (i.e. C)
    4. The CSPEX of the second component, org.demo.xml.provider (i.e. B) contains a prebind action that:
      1. Builds component C to a jar and copies that jar into the jars directory of component B.
      2. Copies the component D from a cache location into the jars directory of component B.
    5. Once the prebind actions have completed, the B component bound to the workspace.
    6. Component A is bound last.
    7. Eclipse receives a lot of events and thus, rebuilds the workspace.

Note that the tada-sax (i.e. D) was never bound to the workspace since it is not an Eclipse project.

Back to the top