This article shows how to build a typical application based on SevenHats framework
A typical project based on SevenHats usually consists of several bundles. We are going to create the build for the first SevenHats tutorial application. It is organized as follows:
- org.sevenhats.temperature. Exports some interfaces. It also uses logging bundle from SevenHats platform.
- org.sevenhats.temperature.fahrenheit. Contains the implementations for the interfaces exported by org.sevenhats.temperature.
- org.sevenhats.temperature.kelvin. Contains the implementations for the interfaces exported by org.sevenhats.temperature.
- org.sevenhats.temperature.logging.config. Configures the SevenHats logging.
You can find the source code for these bundles at <SevenHats Home>/Projects/Tutorial1/code
SevenHats provides several ant tasks which can be used to build such project. We are going to use bundleCompile task to compile all the bundles. In fact, bundleCompile does the following things:
- Checks if all the bundle dependencies can be resolved. At this stage all the bundles are taken account: those to be compiled and platform bundles.
- Compiles the source code of every bundle and packs it into JAR. Each JAR is named after the appropriate bundle's symbolic name. So if bundle has the following entry in MANIFEST.MF:
then output JAR file will be named org.sevenhats.temperature.jar. (todo consider moving to Spring naming format http://www.springsource.com/repository/app/faq#q12 )
bundleCompile task requires several arguments. First of all, we need to define the bundles source code location in bundlesFolderPath attribute. This can be achieved by creating ant path element, which includes all the folders containing sources organized as follows:
- <bundle source folder>/
- src//this folder contains bundle sources
- META-INF //this folder contains MANIFEST.MF file for this bundle
The second thing required for bundleCompile task is the ant path containing all the jars considered as 'platform' bundles. It is specified in platformFolderPath attribute.
destFolder attribute is used to specify the destination folder where newly packed JARs will be placed to. This folder will be created if it does not exist.
staticResources attribute define the ant pattern which specify the static resources to be copied from source folder to JAR.
There are also fork, target and debug attributes which can be specified for bundleCompile task, but they are pretty similar to the same attributes Javac ant task, so they don't need additional description.
Let us create the build file now.
Now, executing ant -f builddemo.xml command will lead to compiling and packing the bundles into four JARs: org.sevenhats.temperature.jar, org.sevenhats.temperature.kelvin.jar, org.sevenhats.temperature.fahrenheit.jar, org.sevenhats.temperature.logging.config.jar.
In the next part we are going to launch this application using some ant tasks.