Loading...

September 5, 2008

Using Cocoon 2.2 without installing Cocoon

Cocoon is a very powerful XML publishing framework. With version 2.2 Cocoon switched from a "checkout the source, set your environment variables and run the build script" installation to building with Maven 2. And that makes life so much easier. We now only have to create a Maven project described by a pom.xml file. In this file we define our dependencies for Cocoon. So we don't need to download the source code and build it, we only have to define a Cocoon dependency. Maven will make sure the dependencies are downloaded if necessary and we are ready to go.

So if we don't have to download the source code anymore, how do we get Cocoon libraries in our project? Well that is the "magic" of Maven. The Cocoon libraries are available on the internet in Maven repositories. Maven will download the libraries from these repositories to our local computer. And once they are downloaded to our local computer we can use them for compiling and running our Cocoon application.

The following code is an example extract for a Cocoon application with the core dependencies defined:

<dependency>
 <groupId>org.apache.cocoon</groupId>
 <artifactId>cocoon-core</artifactId>
 <version>2.2.0</version>
</dependency>
<dependency>
 <groupId>org.apache.cocoon</groupId>
 <artifactId>cocoon-servlet-service-components</artifactId>
 <version>1.0.0</version>
</dependency>