cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [DAISY] Created: BD: Tutorial: Creating, extending and running a block
Date Wed, 11 Jan 2006 21:09:59 GMT
A new document has been created.

Document ID: 796
Branch: main
Language: default
Name: BD: Tutorial: Creating, extending and running a block
Document Type: Cocoon Document
Created: 1/11/06 9:09:41 PM
Creator (owner): Reinhard Pötz
State: publish


Mime type: text/xml
Size: 4889 bytes

<p class="fixme">This page contains mostly pseudo code for now. This will of
course change so that readers can follow the tutorial step by step.</p>

<p>This document describes how you can use <strong>Maven 2 </strong>to develop
your <strong>Cocoon 2.2 </strong>applications. It describes following steps:</p>

<li>creating your block skeleton</li>
<li>configuring your block in general (dependencies on other blocks and
libraries, ...)</li>
<li>running your block without having to grapple with servlet containers or Java
web applications (war files)</li>
<li>extending your block (own pipelines and components)</li>
<li>installing your block to your local Maven repository</li>

<h1>Install Maven 2</h1>

<p>Make sure that you have installed Maven 2. If you are not sure, open a
console and enter</p>

<pre>$ mvn -version
Maven version: 2.0

<p>If this doesn't work, install Maven 2 first. There is an
<a href="">Getting
Started Guide</a> that describes this in great detail.</p>

<h1>Create your block skeleton</h1>

<p>A Cocoon 2.2 application is a composition of blocks. This means that
everything that should run based on Cocoon 2.2 is a block. So what you need is
creating your own block. Cocoon 2.2 provides an Maven archetype that creates a
skeleton that already contains a working block. In order to use it, open an
console window, create an empty directory and enter</p>

<pre>mvn archetype:create \
  -DarchetypeGroupId=org.apache.cocoon \
  -DarchetypeArtifactId=block \ 
  -DarchetypeVersion=1.0 \
  -DgroupId=com.mycompany \

<p class="fixme"><em>explain the directory structure, and explain what block.xml
and pom.xml are for.</em></p>

<h1>Run your block</h1>

<p>You want to see your new block it in action? You are only one command away!
Move again into the root directory of your block and enter</p>

<pre>mvn cocoon:simple-deploy jetty6:run

<p>Open your favorite browser and enter</p>


<h1>Use other blocks from within your block</h1>

<h2>Configure your block to use other blocks</h2>

<p>The main configuration file of a block is block.xml. It contains</p>

<li>general information about the block (name, author, licencse, state, ...)
<li>path to the block's base sitemap</li>
<li>requirements of other blocks (dependencies)</li>
<li>implemented contracts</li>

<p>If you want, that your block depends on another block, it has to point to it:

<pre>&lt;block xmlns=""&gt;

<p>If you have compile-time dependencies on the required blocks, you also have
to add the dependency to pom.xml:</p>

<pre>&lt;project xmlns="" xmlns:xsi=""

<p class="note">If your block doesn't have a compile-time dependency, you don't
need to add it as Maven dependency.</p>

<h2>Create project descriptors for Eclipse and IDEA</h2>

<p>So far you have only been using the block skeleton provided by the Maven
archetype. That's fine but I'm sure you want to do more. So let's extend the
existing block a bit and also implement a Cocoon action.</p>

<p>If you want to use Eclipse or IDEA, Maven already provides the necessary
goals to create the project files:</p>

<pre>mvn eclipse:eclipse</pre>


<pre>mvn idea:idea</pre>

<h2>Use a pipeline of another block</h2>


<h2>Use a component of another block</h2>


<h2>Write your own component that can be used from another block</h2>


<h1>Install your block into your local Maven 2 repository</h1>

<p>In order to make your block locally available, you have to install it into
your local Maven 2 repository:<br/>
mvn install<br/>
This step is necessary, if you want to continue with the second tutorial

<h1>Further readings</h1>

<p>If you want to know more about Maven 2 than this document explains, have a
look at the <a href="">Maven documentation </a>and
especially the excellent Maven 2
<a href="">Getting
Started Guide</a>.</p>


The document belongs to the following collections: documentation

View raw message