Versions of Software Used
- Mac OS X Leopard 10.5.6
- Maven 2.0.10
STEPS
Upgrade Maven on Leopard
- Download latest Maven version from Apache: Maven – Download Maven 2.0.10
- Follow these excellent steps for upgrading Maven on the Mac: Gridshore ยป Upgrading maven on the mac
Download Cocoon
- Follow instructions from Apache Cocoon “Getting Started” site: Cocoon 2.2 Site – Your first Cocoon application using Maven 2
Loading Cocoon Block into Eclipse
- Read the following article: Maven – Guide to using Eclipse with Maven 2.x
- From the menu bar, select Window > Preferences. Select the Java > Build Path > Classpath Variables page.
- M2_REPO=
From the Command Line
mvn archetype:generate -DarchetypeCatalog=http://cocoon.apache.org
cd /Users/smetker/development/cocoon_dev/svn
mkdir getting-started-app
mvn archetype:generate -DarchetypeCatalog=http://cocoon.apache.org
Choose a number: (1/2/3): 2
Define value for groupId: : com.rwd.infomaestro
Define value for artifactId: : myBlock1
Define value for version: 1.0-SNAPSHOT: : 1.0.0
Define value for package: com.rwd.infomaestro: : com.rwd.infomaestro.myBlock1
mvn archetype:generate -DarchetypeCatalog=http://cocoon.apache.org
Choose a number: (1/2/3): 2
Define value for groupId: : com.rwd.infomaestro
Define value for artifactId: : myBlock1
Define value for version: 1.0-SNAPSHOT: : 1.0.0
Define value for package: com.rwd.infomaestro: : com.rwd.infomaestro.myBlock2
cd myBlock1
mvn eclipse:eclipse
Create the 2nd eclipse project settings
cd ../myBlock2
mvn eclipse:eclipse
cd ..
Choose a number: (1/2/3): 3
Define value for groupId: : com.rwd.infomaestro
Define value for artifactId: : myWebApp
Define value for version: 1.0-SNAPSHOT: : 1.0.0
Define value for package: com.rwd.infomaestro: : com.rwd.infomaestro.myWebApp
cd ..
In order to use blocks as dependencies you need to install them into Maven’s local repository. First go to myBlock1/ and myBlock2/ directory and execute following command:
cd myBlock1
mvn install
cd ..
mvn install
So far the web application myCocoonWebapp doesn’t have any information about the existense of the block myBlock1 and myBlock2. Change this by opening getting-started-app/myCocoonWebapp/pom.xml and add the block as dependency:
<project>
[...]
<dependencies>
<dependency>
<groupId>com.rwd.infomaestro</groupId>
<artifactId>myBlock1</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.rwd.infomaestro</groupId>
<artifactId>myBlock2</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
[...]
</project>
Running Jetty from Command Line (Jetty bundled with Cocoon block)
mvn jetty:run
Debugging Cocoon in Eclipse
Follow the instructions under this link first: Cocoon Main Site – Debugging Cocoon in Eclipse
Using the Jetty launcher is much simpler and you don’t have to create a Java project for each Cocoon application that you want to debug.If you prefer using Jetty 6, you can start Jetty as Java application from within Eclipse. For this purpose
- download Jetty 6
- and extract it into a directory of choice. You only have to make sure that it is not a subdirectory of an Eclipse project that is added to your Eclispe workspace.
- now create a new Java project (e.g. “Jetty6″) in your workspace and add jetty-6.x.jar, jetty-util-6.x.jar, servlet-api.2.5.x.jar and start.jar as library dependencies (all 4 files are part of the official Jetty distribution)
- add the project(s) that you want to debug as Project References and as Java Build Path – Projects references. This makes it necessary that these projects are added to the current workspace.
- provide a minimal Jetty configuration file jetty-debug-cocoon.xml, e.g. in the root directory of your “Jetty6″ project