A document has been updated: http://cocoon.zones.apache.org/daisy/documentation/1159.html
Document ID: 1159 Branch: main Language: default Name: Your first Cocoon application using Maven 2 (unchanged) Document Type: Cocoon Document (unchanged) Updated on: 6/22/08 9:30:00 PM Updated by: David Legg A new version has been created, state: draft Parts ===== Content ------- This part has been updated. Mime type: text/xml (unchanged) File name: (unchanged) Size: 7480 bytes (previous version: 8196 bytes) Content diff: (21 equal lines skipped) <tt>getting-started-app</tt>.</p> <p>The next step is to create a Cocoon block to contain your custom application. --- The development of any Cocoon web application should be done within a block. A --- Cocoon block is little different to any other kind of Maven block. It simply --- has a particular <a href="daisy:1263">directory and file structure</a>.</p> +++ The development of any Cocoon web application should be done within one or more +++ blocks. Cocoon blocks are little different to other Maven blocks except they +++ have a particular expected <a href="daisy:1263">directory and file +++ structure</a>.</p> --- <p>We could manually create the block, but a simpler route is to use Maven's --- 'archetype' plugin. This allows us to select from a list of block types and --- have Maven create them for us. The default list of archetypes is quite large. --- For convenience, a catalog of Cocoon archetypes is available on the Cocoon web --- site and we shall use that.</p> +++ <p class="note">You could manually create your blocks, but a simpler and less +++ error-prone process is to use Maven's 'archetype' plugin. This allows you to +++ select from a list of block types and have Maven create them for you. By +++ default, the list of Maven archetypes is quite large. For convenience, a +++ catalog of Cocoon specific archetypes is available on the Cocoon web site and +++ you will make use of this in the following instructions.</p> --- <p class="note">The current version of the Archetype plugin (2.0 alpha-3) has a --- bug which prevents it accessing the remote copy of the Cocoon archetype --- catalog. The following instructions will be simpler when this is fixed.</p> +++ <p>Run the following Maven command and when requested type in the answers: -</p> --- <p>First save the catalog somewhere convenient. In Windows you could open a --- browser on --- <a href="http://cocoon.apache.org/archetype-catalog.xml">http://cocoon.apache.org/archetype-catalog.xml</a> --- and save it from there.</p> +++ <pre>mvn archetype:generate -DarchetypeCatalog=http://cocoon.apache.org +++ </pre> --- <p>In Unix you could execute the command: -</p> +++ <p>Maven will then generate some output and then interactively ask you for some +++ information: -</p> --- <pre>wget http://cocoon.apache.org/archetype-catalog.xml +++ <pre>Choose archetype: +++ 1: remote -> cocoon-22-archetype-block-plain (Creates an empty Cocoon block; useful +++ if you want to add another block to a Cocoon application) +++ 2: remote -> cocoon-22-archetype-block (Creates a Cocoon block containing some small +++ samples) +++ 3: remote -> cocoon-22-archetype-webapp (Creates a web application configured to +++ host Cocoon blocks. Just add the block dependencies) +++ Choose a number: (1/2/3): <strong>2</strong> </pre> --- <p>Now run the following Maven command and when requested type in the answers --- (shown in bold): -</p> +++ <p>Maven first asks which archetype you want to create. Item 2 in this list is +++ the standard Cocoon block with some small sample files already in place.</p> --- <pre>> <strong>mvn archetype:generate -DarchetypeCatalog=file://archetype-catalog.xml</strong> --- [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] [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: local -> cocoon-22-archetype-block-plain (Creates an empty Cocoon block; useful if you want to add another block to a Cocoon application) --- 2: local -> cocoon-22-archetype-block (Creates a Cocoon block containing some small samples) --- 3: local -> cocoon-22-archetype-webapp (Creates a web application configured to host Cocoon blocks. Just add the block dependencies) --- Choose a number: (1/2/3): <strong>2</strong> --- Define value for groupId: : <strong>com.mycompany</strong> +++ <pre>Define value for groupId: : <strong>com.mycompany</strong> Define value for artifactId: : <strong>myBlock1</strong> Define value for version: 1.0-SNAPSHOT: : <strong>1.0.0</strong> --- Define value for package: : <strong>com.mycompany.myBlock1</strong> --- ... --- Y: : <strong>y</strong> --- ... --- [INFO] ------------------------------------------------------------------------ --- [INFO] BUILD SUCCESSFUL --- [INFO] ------------------------------------------------------------------------ +++ Define value for package: : <strong>com.mycompany.myBlock1 +++ </strong></pre> --- </pre> +++ <p>Maven then goes on to ask for more information. Just enter the details as +++ shown. The groupId is just a label that you can use to group all the blocks in +++ your application. The artifactId is the unique label that will identify this +++ block from all others. It is also the name of the directory that will be +++ created to contain the block's files. The package is the Java package that any +++ Java files in the block will be assigned to.</p> <p class="note">If you are using a cocoon binary build from svn trunk then you probably want to change the archetypeVersion to the most recent one, matching (23 equal lines skipped) <pre>mvn eclipse:eclipse</pre> <p>This will create the necessary project descriptors for Eclipse. In Eclipse --- you can import the project into your workspace: <em>File - Import - General - --- Existing Projects</em>.</p> +++ you can import the project into your workspace: <em>File > Import...</em> +++ </p> <p>If that's the first time you use Eclipse together with a project created by --- Maven 2, we recomment to read the +++ Maven 2, we recommend you read the <a href="http://maven.apache.org/guides/mini/guide-ide-eclipse.html">Maven Guide using Eclipse with Maven 2.x</a>.</p> <h1>Run the block as Java web application</h1> --- <p>After creating the block you probably want to run it. For this purpose there --- is a Maven plugin, that generates a minimal web application that loads your --- block. The pom.xml of your block already contains all necessary configurations. --- </p> +++ <p>After creating the Cocoon block you probably want to run it. For this purpose +++ there is a Maven plugin that generates a minimal web application that loads your +++ block. The pom.xml of your block already contains the necessary settings.</p> --- <p>You can then run</p> --- <pre>mvn jetty:run</pre> <p>and point your browser at <tt>http://localhost:8888/myBlock1/</tt> and get a (5 equal lines skipped) the jetty:run goal is executed. See the block's <tt>pom.xml </tt>for details. </p> --- <p>This process can be manually triggered with <tt>mvn cocoon:prepare</tt> too. --- </p> +++ <p class="note">This process can be manually triggered with <tt>mvn +++ cocoon:prepare</tt> too.</p> <h1>Conclusion and further information</h1> --- <p>So far you have created a block. You have also been able to run the block in --- Jetty. Of course, that was only the first step in order to get a "Hello world" --- as result. If you wonder how you can do some useful stuff like writing your own --- Cocoon pipeline or some Java code, there are more tutorials:</p> +++ <p>So far you have created a Cocoon block and been able to run it in Jetty. +++ This is only the first step to creating a full-blown Cocoon application. If you +++ would like to know more read the following tutorials: -</p> <ul> <li><a href="daisy:1290">Your first XML pipeline</a><br/> --- Cocoon has become famous for XML pipelines. At this tutorial you will learn how --- to setup your first pipeline and will learn the most important things about --- Cocoon sitemaps.</li> +++ Cocoon is well known for its XML pipelines. In this tutorial you will learn how +++ to setup your first pipeline and discover the power of Cocoon sitemaps.</li> <li><a href="daisy:1291">Adding a second block</a><br/> --- While following this tutorial, you will create a web application that has a --- dependency on one block. There are use cases that require more than one block, --- e.g. you want to have all style specific resources within a single block that --- can be easily exchanged at deployment time (aka skinning).</li> +++ This tutorial creates a web application that has a dependency on another block. +++ There are use cases that require more than one block, e.g. you want to have all +++ style specific resources within a single block that can be easily exchanged at +++ deployment time (aka skinning).</li> <li><a href="daisy:1297">Usage of the reloading classloader plugin</a><br/> The reloading classloader plugin enables rapid development of Cocoon applications since you don't have to restart the servlet container whenever one --- of your Java classes changes. Additionally it provides all settings to enable --- the reload of Cocoon resources too.</li> +++ of your Java classes changes. Additionally, it enables the reloading of Cocoon +++ resources too if they change.</li> <li><a href="daisy:1362">Deploying a Cocoon application<br/> --- </a>Although you have already been able to run this block, you most probably --- need a Java web application (war file) in order to deploy it to the servlet --- container (Tomcat, Jetty, etc.) of your choice.<a href="daisy:1263"><br/> +++ </a>Eventually, you will probably need to create a Java web application (war +++ file) in order to deploy your application to a servlet container such as Tomcat +++ or Jetty, etc. This tutorial shows you how.<a href="daisy:1263"><br/> </a></li> </ul> --- <p>For the time being, we <em>recommend</em> the usage of <em>Maven 2</em> as +++ <p>For the time being, we <em>recommend</em> you use <em>Maven 2</em> as your build system (though there is no hard dependency on it). This has the advantage that the build system is standardized and Cocoon web applications can reuse the --- toolset (create Eclipse configuration files, release, produce documentation, --- etc.) that Maven offers. More information about Maven 2 can be found at the --- project <a href="http://maven.apache.org">website</a>. Especially we recommend --- reading</p> +++ toolset (create Eclipse configuration files, create releases, produce +++ documentation, etc.). More information about Maven 2 can be found at the project +++ <a href="http://maven.apache.org">website</a>. We especially recommend reading: +++ -</p> <ul> <li> (8 equal lines skipped)