Build with Ant¶
BundleBee is provided with a build system based on popular ant.
The design goals have been:
- KISS (keep it stupid simple)
- fully canned
- fast
- exact
- flexible
Projects either create a simple jar for reference or OSGi bundles meant to run within the OSGi framework.
It is KISS bc. every single projects build file is very simple (2 lines in the best case).
It is fast bc. no files are copied around unnecessarily. Everything is build right in place and at its final destination. Libraries and dependencies are fine grained enough to avoid monstrous classpathes.
The build is fully canned in the sense that everything needed is provided by svn or any other kind of deployment. No external resources have to be drawn before the build/run cycle can happen.
Checkout the Sources¶
You can checkout the latest source from:
https://dev.innoq.com/svn/bundle-bee/trunk
You need to register with
username: bundle-bee
password: bundlebee
There is also a tags URL:
https://dev.innoq.com/svn/bundle-bee/tags
The build system is composed of always two components:
- the infrastructure found in the directory
antbuild - per project/bundle build files
build.xmlosgibundle.properties(optional)
available targets¶
build: high-level build, either creates a simple jar or an OSGi bundle; coversjarandbundlerun: build the project and run the frameworkdebug: build the project and run the framework, connectable by a debuggertest: run the testsclean: well ... cleanjar: build a jar if the project is a simple jar projectbundle: build a OSGi bundle if the project providesosgibundle.propertiesforce_jar: unconditionally creates a jar, even for a OSGi bundle projectforce_bundle: unconditionally creates a bundle, even for simple jar projects, taking default OSGi propertiesassembly: create a deliverable binary
antbuild¶
This directory contains everything that is common to all builds:
common.xml: definition of common ant targetslibs.properties: definition of common jars like the OSGi framework itselfbuild.properties: version number and suchplugins: directory with all jars needed at runtime; target directory for bundle buildsdevlibs: jars only needed at build/test time
per project files¶
The build is based on a couple of assumptions that are inherited from the maven build system. These assumptions refer to the directory layout for the sourcecode. Everything is customizable on a per-project basis, but adhering to the defauls makes life easier.
src/main/java: basic sources for the jar/bundlesrc/main/resources: resources to be embodied with the jar/bundlesrc/test/java: junit test sourcesbuild: base directory for build results, created during the buildbuild/classes: raw compiler outputbuild/testclasses: raw compiler output for testsbuild/testoutput: test reportsbuild/$PROJECTNAME_$VERSION.jar: build jar
build.xml
Build description that is directly passed to ant.¶
build.xml is as simple as it can be as long as the project layout follows the basic assumptions bc. all the magic is performed from common.xml from the infrastructure. Here is a sample of a build.xml build just a simple jar:
<project name="registry" default="jar" basedir=".">
<!-- where to find the common ant build directory -->
<property name="common.dir" value="../antbuild"/>
<!--import common targets-->
<import file="${common.dir}/common.xml"/>
</project>
Obviously, nothing has to be done except properly referencing common.xml. With this build.xml, all the targets mentioned above are available.
<project name="carrier" default="bundle" basedir=".">
<description>Builds, tests, and runs the project ${ant.project.name} ${version}.</description>
<!-- where to find the common ant build directory -->
<property name="common.dir" value="../antbuild"/>
<!--import common targets-->
<import file="${common.dir}/common.xml"/>
<!--build dependent projects-->
<target name="build_dependencies">
<declare_jar_dependency.macro prjpath="../Registry" jar="registry"/>
<declare_bundle_dependency.macro prjpath="../Repository" name="repository"/>
<!--
Define the projects compile classpath.
Library paths can be found in antbuild/libs.properties for reference.
-->
<path id="project.classpath.refid">
<pathelement path="${registry.artifact}"/>
<pathelement path="${repository.artifact}"/>
</path>
</target>
</project>
This sample declares two dependencies using the declare_jar_dependency.macro and declare_bundle_dependency.macro macros. They make sure that the resp. dependency is build an provide a property holding the resp. classpath element (registry.artifact and repository.artifact in this case). Please note that the jar and name parameters for the macros determine the name of that property.
osgibundle.properties (optional)¶
Properties describing the OSGi bundle like exported/imported packages and such
top level build¶
There is a top-level build script antbuild/build.xml which deals with the BundleBee project as a whole. Cleaning and building everything or creating an assembly for binary distribution are the available targets.
Targets to use are:
cleanbuildrundebugassembly
customisation¶
The build can be customized be pre-setting ant properties or overloading ant targets. I advise to refer to antbuild/common.xml to see a list of properties that can be predefined in a projects build.xml file. E.g.
<property name="java.src.dir" value="myjavasrc"/>