If you're interested in functional programming, you might also want to checkout my second blog which i'm actively working on!!

Monday, May 3, 2010

Apache Cocoon: Quick start

Prerequisites:

- JDK1.5
- Maven2

(1) Open a shell (cygwin/dos/...) and move into your workspaces folder
(2) Run following command (Maven2 Cocoon archetype) to create a new project based on the 'Cocoon block' archetype which comes with some samples.


D:\workspaces>mvn archetype:generate -DarchetypeCatalog=http://cocoon.apache.org
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [archetype:generate] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] Preparing archetype:generate
[INFO] No goals needed for project - skipping
[INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.
[INFO] Setting property: velocimacro.messages.on => 'false'.
[INFO] Setting property: resource.loader => 'classpath'.
[INFO] Setting property: resource.manager.logwhenfound => 'false'.
[INFO] [archetype:generate]
[INFO] Generating project in Interactive mode
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
Choose archetype:
1: http://cocoon.apache.org -> cocoon-22-archetype-block-plain (Creates an empty Cocoon block; useful if you want to add another block to a Cocoon application)
2: http://cocoon.apache.org -> cocoon-22-archetype-block (Creates a Cocoon block containing some small samples)
3: http://cocoon.apache.org -> cocoon-22-archetype-webapp (Creates a web application configured to host Cocoon blocks. Just add the block dependencies)
Choose a number: (1/2/3): 2
Define value for groupId: : com.ciber
Define value for artifactId: : cocoontutorial
Define value for version: 1.0-SNAPSHOT: :
Define value for package: com.ciber: :
Confirm properties configuration:
groupId: com.ciber
artifactId: cocoontutorial
version: 1.0-SNAPSHOT
package: com.ciber
Y: : y
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating OldArchetype: cocoon-22-archetype-block:1.0.0
[INFO] ----------------------------------------------------------------------------
[INFO] OldArchetype created in dir: D:\workspaces\spider\cocoontutorial
....
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 4 seconds
[INFO] Finished at: Mon May 03 16:16:37 CEST 2010
[INFO] Final Memory: 8M/14M
[INFO] ------------------------------------------------------------------------


(3) Now move into the newly created folder 'cocoontutorial' and run


D:\workspaces\cocoontutorial>mvn eclipse:eclipse
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'eclipse'.
[INFO] ------------------------------------------------------------------------
[INFO] Building cocoontutorial
[INFO] task-segment: [eclipse:eclipse]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing eclipse:eclipse
[INFO] No goals needed for project - skipping
[INFO] [eclipse:eclipse]
[INFO] Using as WTP server : null
[INFO] Adding default classpath contaigner: org.eclipse.jdt.launching.JRE_CONTAINER
[INFO] Using source status cache: D:\workspaces\cocoontutorial\target\mvn-eclipse-cache.properties
[INFO] Not writing settings - defaults suffice
[INFO] Wrote Eclipse project for "cocoontutorial" to D:\workspaces\cocoontutorial.
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------
------
[INFO] Total time: 10 seconds
[INFO] Finished at: Mon May 03 16:23:54 CEST 2010
[INFO] Final Memory: 16M/29M
[INFO] ------------------------------------------------------------------------


Now we're ready to import the newly created project into Eclipse.

(4) Right-click in the package explorer and select 'Import' -> 'existing Projects into workspace' -> press Next -> Browse and select the new project -> press Finish


(5) Create a new run configuration (see screenshots)



(6) Press the run button to start jetty



(7) Point your browser to http://localhost:8888/cocoontutorial/





































No comments:

Post a Comment