Shapeshifter

Contact

PDF-ikonen

View page as PDF

Off-line page generation with Cocoon 2.1.7

Offline page generation with Cocoon is very easy to achieve, using the steps described here.

Build Site.bat

I modified the build.bat in the Cocoon package, and made a buildSite.bat. I modified the section below. As you see, the ant build now calls build_newsite.xml

call %ANT_HOME%\bin\ant -buildfile build_newsite.xml
-Djava.endorsed.dirs=lib\endorsed
-logger org.apache.tools.ant.NoBannerLogger
-emacs %1 %2 %3 %4 %5 %6 %7 %8 %9
 

The entire buildSite.bat file:

(From the Cocoon distribution)

@echo off
rem Copyright 1999-2004 The Apache Software Foundation
rem
rem  Licensed under the Apache License, Version 2.0 (the "License");
rem  you may not use this file except in compliance with the License.
rem  You may obtain a copy of the License at
rem
rem      http://www.apache.org/licenses/LICENSE-2.0
rem
rem  Unless required by applicable law or agreed to in writing, software
rem  distributed under the License is distributed on an "AS IS" BASIS,
rem  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem  See the License for the specific language governing permissions and
rem  limitations under the License.
rem
rem----------------------------------------------------------------------------
rem build.bat - Win32 Build Script for Apache Cocoon
rem
rem $Id: build.bat 54516 2004-10-11 08:27:11Z cziegeler $
rem----------------------------------------------------------------------------
 
rem ----- Ignore system CLASSPATH variable
set OLD_CLASSPATH=%CLASSPATH%
set CLASSPATH=
for %%i in (lib\endorsed\*.jar) do call tools\bin\appendcp.bat %%i
 
rem ----- Use Ant shipped with Cocoon. Ignore installed in the system Ant
set OLD_ANT_HOME=%ANT_HOME%
set ANT_HOME=tools
 
call %ANT_HOME%\bin\ant
-buildfile build_newsite.xml
-Djava.endorsed.dirs=lib\endorsed
-logger org.apache.tools.ant.NoBannerLogger
-emacs %1 %2 %3 %4 %5 %6 %7 %8 %9
 
rem ----- Restore ANT_HOME and ANT_OPTS
set ANT_HOME=%OLD_ANT_HOME%
set OLD_ANT_HOME=
 
rem ----- Restore CLASSPATH
set CLASSPATH=%OLD_CLASSPATH%
set OLD_CLASSPATH=

 

Build XML.

The build XML file that builds Cocoon can also be used as it is (almost)

Just alter the cocoon.context to point at your project.

<property name="cocoon.context"
value="E:\Program\Apache Software Foundation\Tomcat 5.5\webapps\kocoon"/>

 

The entire build XML file

(From the Cocoon distribution)

 

<?xml version="1.0"?>
<project default="cocoon" basedir=".">
 <property name="cocoon.context"
  value="E:\Program\Apache Software Foundation\Tomcat 5.5\webapps\kocoon"/>
 <path id="cocoon.classpath">
  <dirset dir="${cocoon.context}/WEB-INF/classes"/>
  <fileset dir="${cocoon.context}/WEB-INF/lib" includes="*.jar"/>
 </path>
 <taskdef name="cocoon"
  classname="org.apache.cocoon.CocoonTask"
  classpathref="cocoon.classpath"/>
 <target name="cocoon">
    <cocoon verbose="true" 
     classpathref="cocoon.classpath"
     follow-links="true"
     precompile-only="false"
     confirm-extensions="false"
     context-dir="${cocoon.context}"
     config-file="WEB-INF/cocoon.xconf"
     work-dir="build/work"
     dest-dir="build/dest"
     default-filename="index.html"
     accept="*/*">
     <broken-links type="xml"
      file="brokenlinks.xml"
      generate="false"
      extension=".error"/>
     <logging log-kit="${cocoon.context}/WEB-INF/logkit.xconf" logger="cli" level="DEBUG" />
     <uris name="site" follow-links="true">
     <uri type="append"
      src-prefix=""
      src="index.html"
      dest="${cocoon.context}/build/dest/"/>
   </uris>       
  </cocoon>
 </target>
</project>

 

Executing the offline page generation

First, set some environment variables to point at your build.

E:\cocoon-2.1.7>SET COCOON_HOME=e:\cocoon-2.1.7E:\cocoon-2.1.7>SET COCOON_LIB=E:\Program\Apache Software Foundation\Tomcat 5.5\
webapps\kocoon\WEB-INF\lib
E:\cocoon-2.1.7>SET JETTY_WEBAPP=E:\Program\Apache Software Foundation\Tomcat 5.5\webapps\kocoon

Then, start the Jetty server for Cocoon

E:\cocoon-2.1.7>cocoon servlet -c webapp -w temp\work

Now, you should have Jetty running at port 8888. (Not immediately, of course)

Then, you might have to copy the servlet.jar to your web application.

From:

E:\cocoon-2.1.7\tools\jetty\lib\servlet*.jar

To:

E:\Program\Apache Software Foundation\Tomcat 5.5\webapps\kocoon\WEB-INF\lib

Execute the build

E:\cocoon-2.1.7>buildSite

 

Main menu bar