Apache » Cocoon »

  Cocoon Maven Plugin
      1.0
   homepage

Cocoon Maven Plugin 1.0

Using the Reloading Classloader

These instructions should work with any Cocoon block. The sample configurations are based on the Getting Started guide.

Step 1: Enable the plugin in pom.xml

In the pom.xml you have to add the plugin:

<project>
  <build>
    <plugins>
      [...]
      <plugin>
        <groupId>org.apache.cocoon</groupId>
        <artifactId>cocoon-maven-plugin</artifactId>
        <version>1.0.0-M2</version>
      </plugin>
      [...]
    </plugins>
  </build>
</project>   

Step 2: Configure the plugin

You can also provide configuration properties. Use the goal documentation generated from the Javadoc comments to find out more.

The central configuration file is rcl.properties which has to be put into the root directory of the block that you want to run, e.g.

com.mycompany.myBlock1.block%classes-dir=./target/classes

The property names consist of the name of the block servlet which is the unique name of the Spring bean + %classes_dir . The value is the relative or absolute filesystem path.

Step 3: Invoke the plugin

The Maven 2 plugin can be invoked by calling

mvn cocoon:prepare

This creates a web application into ./target/rcl/webapp for your block.

If you want to avoid this additional step, you can invoke it automatically, e.g. by

If you want to invoke it automatically, add it to the execution section of your plugin definition, e.g.

<plugin>
  <groupId>org.apache.cocoon</groupId>
  <artifactId>cocoon-maven-plugin</artifactId>
  <version>1.0.0-M2</version>
  <executions>
    <execution>
      <phase>compile</phase>
      <goals>
        <goal>prepare</goal>
      </goals>
    </execution>
  </executions>       
</plugin>

Step 4: Create Eclipse project files

Move to getting-started-app/ and invoke

mvn eclipse:eclipse

and import the new Eclipse project into your Eclipse workspace.

Step 5: Start the servlet container

Alternative A: The Maven Jetty plugin

Now you can configure the Maven 2 Jetty plugin to use the web application that was created by the block in target/rcl/webapp:

<project>
  <build>
    <plugins>
      [...]
      <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>maven-jetty-plugin</artifactId>
        <version>6.1.7</version>
        <configuration>
          <connectors>
            <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
              <port>8888</port>
              <maxIdleTime>30000</maxIdleTime>
            </connector>
          </connectors>
          <webAppSourceDirectory>${project.build.directory}/rcl/webapp</webAppSourceDirectory>
          <contextPath>/</contextPath>
          <systemProperties>
            <systemProperty>
              <name>org.apache.cocoon.mode</name>
              <value>dev</value>
            </systemProperty>
          </systemProperties>
        </configuration>
      </plugin>
      [...]
    </plugins>
  </build>
</project>   

Call mvn jetty:run and point your browser to http://localhost:8888/block1/ in  your browser.

Alternative B: Use the Eclipse Jetty plugin

There is a tutorial that describes how to debug Cocoon.

Step 6: Change a class file

Now it's time to see the reloading classloader in action. Open getting-started-app/myBlock1/src/main/java/com/mycompany/??? and change it. Refresh your browser and you should see the changed values there.