You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@forrest.apache.org by je...@apache.org on 2002/10/30 09:39:17 UTC

cvs commit: xml-forrest/src/resources/forrest-shbat forrest.build.xml

jefft       2002/10/30 00:39:17

  Added:       src/resources/forrest-shbat forrest.build.xml
  Removed:     .        forrest.build.xml
  Log:
  Move forrest.build.xml into the forrest-shbat directory where it belongs
  
  Revision  Changes    Path
  1.1                  xml-forrest/src/resources/forrest-shbat/forrest.build.xml
  
  Index: forrest.build.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <!--
  FORREST SITE BUILDER
  
   - The runtime part of Forrest
   - Contains actions Forrest can peform on any Forrest-using project.
   - This is typically called by forrest.bat or forrest
  -->
  
  
  <project default="site" basedir="." name="Forrest template targets">
  
    <description>
      *=======================================================*
      |                Forrest Site Builder                   |
      *=======================================================*
                                by
                    Marc Portier (mpo@apache.org)
                    Jeff Turner (jefft@apache.org)
    
               Call this through the 'forrest' command
    </description>
    
    
  
  <!-- ***************************************************************** -->
  <!-- ***************************************************************** -->
  <!-- **                                                             ** -->
  <!-- **                                                             ** -->
  <!-- **                    COMMON SETTINGS                          ** -->
  <!-- **                                                             ** -->
  <!-- **                                                             ** -->
  <!-- ***************************************************************** -->
  <!-- ***************************************************************** -->
  
    <!-- ===============================================================
         Loads user defined settings.
         Steps back to defaults when they are not set.
         Echo's the settings if requested.
         =============================================================== -->
    <target name="init-props">
    
      <!-- setting defaults for parameters -->
      <!-- people should use -D switch, or <ant><property>s to override these   -->
  
      <property name="project.home" location="." />
  
      <echo message="Loading project specific properties from ${project.home}/forrest.properties" />
      <property file="${project.home}/forrest.properties" />
  
      <!-- people should use forrest.properties to override following defaults  -->
      <property name="forrest.home"        location="." />
      <property name="project.name"        value="my-project"    />
      <property name="project.site-dir"    value="${project.home}/build/site"    />
      <property name="project.war" value="${project.home}/build/${project.name}.war" />
      <property name="project.webapp"      value="${project.home}/build/webapp" />
      <property name="project.siteplan"    value="${project.home}/siteplan.xml"  />
  
      <property name="project.temp-dir"    value="${project.home}/build/tmp"     />
      <property name="project.work-dir"    value="${project.temp-dir}/work"      />
      <property name="project.ctxt-dir"    value="${project.temp-dir}/context"   />
  
      <property name="project.brokenlinkfile" value="${project.temp-dir}/brokenlinks.txt"/>
      <property name="project.debuglevel"  value="ERROR"                         />
      <property name="project.start-uri"   value="index.html"                    />
  
      <!-- use of these property should be removed when the siteplan becomes active -->
      <property name="project.skin"        value="forrest-site" />
      <property name="project.status"      value="${project.home}/status.xml" />
      <property name="project.content-dir" value="${project.home}/src/documentation" />
      <property name="project.sitemap"     value="${project.content-dir}/sitemap.xmap" />
      <property name="project.xdocs-dir"   value="${project.content-dir}/content/xdocs" />
      <property name="project.stylesheets-dir" value="${project.content-dir}/resources/stylesheets" />
      <property name="project.images-dir"  value="${project.content-dir}/resources/images" />
      <property name="project.schema-dir" value="${project.content-dir}/resources/schema" />
      <property name="project.skins-dir"   value="${project.content-dir}/skins" />
      <property name="project.skinconf"    value="${project.content-dir}/skinconf.xml" />
      <available property="project.skinconf.present" file="${project.skinconf}" type="file"/>
      <property name="project.conf-dir"     value="${project.content-dir}/conf" />
      <property name="project.lib-dir"     value="${project.content-dir}/lib" />
      <property name="project.classes-dir" value="${project.content-dir}/classes" />
  
      <!-- checks for presence of required classes and/or resources -->
      <property name="tools.jar"           location="${java.home}/../lib/tools.jar"/>
      <available file="${tools.jar}"       property="tools.jar.present"/>
  
      <!-- echo settings in -Dforrest.echo=true mode -->
      <antcall target="echo-settings" />
  
    </target>
  
    <!-- Load properties from user's skinconf.xml, if it is defined -->
    <target name="load-project-props" depends="init-props" if="project.skinconf.present">
      <xmlproperty file="${project.skinconf}" collapseattributes="true"
        validate="true"/>
    </target>
  
    <!-- Load properties from Forrest's default skinconf.xml, unless a user's is defined -->
    <target name="load-forrest-props" depends="init-props" unless="project.skinconf.present">
      <xmlproperty file="${forrest.home}/context/skinconf.xml"
        collapseattributes="true" validate="true"/>
    </target>
  
    <!-- Define filters equating to elements in the skinconf.xml file. Skins can
    include tokens corresponding to skinconf.xml elements, and have them replaced
    at runtime.-->
    <target name="init-skinprops" depends="load-project-props, load-forrest-props">
      <mkdir dir="${project.temp-dir}"/>
      <property name="skinfilters" value="${project.temp-dir}/skinfilters.properties"/>
      <echoproperties prefix="skinconfig" destfile="${skinfilters}"/>
      <filter filtersfile="${skinfilters}"/>
    </target>
  
    <!-- Sets up properties and filters -->
    <target name="init" depends="init-props, init-skinprops"/>
  
    <!-- ===============================================================
         Echo's the settings if requested. [-Dforrest.echo=true]
         =============================================================== -->
    <target name="echo-settings" if="forrest.echo">
      <echo>
        ------------------------------------------------
        | Forrest template run.
        | Running from $${forrest.home} = ${forrest.home}
        | Working on   $${project.home} = ${project.home}
        ------------------------------------------------
        | //where to put the result
        | project.site-dir    = ${project.site-dir} 
        | //uri to start crawling/generation process
        | project.start-uri   = ${project.start-uri}
        | //masterplan for building site (dreamware)
        | project.siteplan    = ${project.siteplan} 
        | //cocoon.xconf location
        | project.configfile  = ${project.configfile}
        | //logkit.xconf location
        | project.logkitfile  = ${project.logkitfile}
        | //temp dir to throw stuf in (i.e. work and ctxt)
        | project.temp-dir    = ${project.temp-dir} 
        | //temp working directory for generation process
        | project.work-dir    = ${project.work-dir} 
        | //temp context directory for generation process
        | project.ctxt-dir    = ${project.ctxt-dir} 
        | //debuglevel for logging (INFO, DEBUG, WARN, ERROR, FAIL)
        | project.debuglevel  = ${project.debuglevel}
        | //list of broken links put in:
        | project.brokenlinkfile = ${project.brokenlinkfile}
        | //check if you have tools.jar installed.
        | tools.jar.present   = ${tools.jar.present} 
        ------------------------------------------------
        | Following could be removed from future builds
        | //which skin to apply
        | project.skin        = ${project.skin} 
        | //where your documentation xml is
        | project.content-dir = ${project.content-dir} 
        ------------------------------------------------
      </echo>
    </target>
  
  
    <!-- ===============================================================
         Set class-path.
         =============================================================== -->
    <target name="prepare-classpath" depends="prepare-context" >
      <path id="forrest.cp">
        <pathelement location="${project.ctxt-dir}/WEB-INF/classes"/>
        <fileset dir="${project.ctxt-dir}/WEB-INF/lib" includes="*.jar"/>
        <pathelement location="${forrest.home}/WEB-INF/classes"/>
        <fileset dir="${forrest.home}/lib/endorsed" includes="*.jar"/>
        <fileset dir="${forrest.home}/WEB-INF/lib" includes="*.jar" />
        <pathelement location="${tools.jar}"/>
      </path>
    </target>
  
  
  <!-- ***************************************************************** -->
  <!-- ***************************************************************** -->
  <!-- **                                                             ** -->
  <!-- **                                                             ** -->
  <!-- **                  SITE BUILDING ACTIONS                      ** -->
  <!-- **                                                             ** -->
  <!-- **                                                             ** -->
  <!-- ***************************************************************** -->
  <!-- ***************************************************************** -->
  
  
    <!-- ===============================================================
         Fills the Cocoon context dir to work in 
         with the forrest-predefines.
         param: name of the skin to use ${project.skin} (now)
         param: location to make temporary context-dir ${project.ctxt-dir} 
         =============================================================== -->
    <target name="bare-context" depends="init" >
      <filter token="skin"              value="${project.skin}" />
  
      <!--
      These filters defined for backwards-compatibility with old skins.
      New skins should use the skinconfig.* filters, or actively parse the
      skinconf.xml file themselves. (JT)
      -->
      <filter token="link1"      value="${skinconfig.trail.link1.name}"/>
      <filter token="link1.href" value="${skinconfig.trail.link1.href}"/>
      <filter token="link2"      value="${skinconfig.trail.link2.name}"/>
      <filter token="link2.href" value="${skinconfig.trail.link2.href}"/>
      <filter token="link3"      value="${skinconfig.trail.link3.name}"/>
      <filter token="link3.href" value="${skinconfig.trail.link3.href}"/>
      <filter token="year"       value="${skinconfig.year}"/>
      <filter token="vendor"     value="${skinconfig.vendor}"/>
      <filter token="group-logo.src"  value="${skinconfig.group-logo}"/>
      <filter token="group-logo.href" value="${skinconfig.group-url}"/>
      <filter token="group-logo.alt"  value="${skinconfig.group-name} logo"/>
      <filter token="project-logo.src"  value="${skinconfig.project-logo}"/>
      <filter token="project-logo.href" value="${skinconfig.project-url}"/>
      <filter token="project-logo.alt"  value="${skinconfig.project-name} logo"/>
  
      <!-- NOW: filter-copy the empty-forrest-context -->
      <!-- WITH SitePlan: smaller empty-context, 1 unfiltered copy
                          + generate more stuff from siteplan -->
  
      <copy toDir="${project.ctxt-dir}/" filtering="off">
        <fileset dir="${forrest.home}/context" >
          <exclude name="sitemap.xmap" />
          <exclude name="skins/**" />
        </fileset>
        <fileset dir="${forrest.home}/context" >
          <include name="skins/**/images/**" />
        </fileset>
      </copy>
  
      <copy toDir="${project.ctxt-dir}/" filtering="on">
      <!-- everything in the skins, except the images , and the sitemap -->
        <fileset dir="${forrest.home}/context" >
          <include name="sitemap.xmap" />
          <include name="skins/**" />
          <exclude name="skins/**/images/**" />
        </fileset>
      </copy>
  
      <mkdir dir="${project.ctxt-dir}/WEB-INF"/>
  
      <copy todir="${project.ctxt-dir}/WEB-INF" filtering="true">
        <fileset dir="${forrest.home}/WEB-INF">
          <include name="*.xconf" />
        </fileset>
      </copy>
  
      <!--Hack to stop the classpath definition breaking. If the project has any
      custom jars or classes, they will be added to these dirs -->
      <mkdir dir="${project.ctxt-dir}/WEB-INF/lib"/>
      <mkdir dir="${project.ctxt-dir}/WEB-INF/classes"/>
    </target>
  
  
    <!-- ===============================================================
         Fills the Cocoon context dir to work in 
         with the project-content-parts 
           (now: copy stuff from param ${project.content-dir}
            with siteplan: based on that plan; should allow more different parts)
         param: location to find the content ${project.content-dir}(now)
         param: location of siteplan ${project.siteplan} (future)
         param: location to find project descriptors == ${project.home} 
         param: location to make temporary context-dir ${project.ctxt-dir} 
         =============================================================== -->
    <target name="project-context" depends="init, bare-context, examine-proj, copy-conf, copy-sitemap,
      copy-xdocs, copy-stylesheets, copy-images, copy-schema, copy-lib, 
      copy-classes, copy-skins, copy-skinconf, copy-status"/>
  
    <target name="examine-proj">
      <available property="conf.present" file="${project.conf-dir}" type="dir"/>
      <available property="sitemap.present" file="${project.sitemap}"/>
      <available property="xdocs.present" file="${project.xdocs-dir}" type="dir"/>
      <available property="images.present" file="${project.images-dir}" type="dir"/>
      <available property="schema.present" file="${project.schema-dir}" type="dir"/>
      <available property="stylesheets.present" file="${project.stylesheets-dir}" type="dir"/>
      <available property="lib.present" file="${project.lib-dir}" type="dir"/>
      <available property="classes.present" file="${project.classes-dir}" type="dir"/>
      <available property="skins.present" file="${project.skins-dir}" type="dir"/>
      <available property="skinconf.present" file="${project.skinconf}"/>
      <available property="status.present" file="${project.status}"/>
    </target>
  
    <target name="copy-conf" if="conf.present">
      <copy toDir="${project.ctxt-dir}/WEB-INF" filtering="true"
        overwrite="true" failonerror="false">
        <fileset dir="${project.conf-dir}"/>
      </copy>
    </target>
  
    <target name="copy-sitemap" if="sitemap.present">
      <copy file="${project.sitemap}" toDir="${project.ctxt-dir}" filtering="true"
        overwrite="true" failonerror="false"/>
    </target>
  
    <target name="copy-xdocs" if="xdocs.present">
      <copy toDir="${project.ctxt-dir}/content/xdocs" filtering="false"
        overwrite="true">
        <fileset dir="${project.xdocs-dir}"/>
      </copy>
    </target>
  
    <target name="copy-stylesheets" if="stylesheets.present">
      <copy toDir="${project.ctxt-dir}/resources/stylesheets" filtering="false"
        overwrite="true" failonerror="false">
        <fileset dir="${project.stylesheets-dir}"/>
      </copy>
    </target>
  
    <target name="copy-images" if="images.present">
      <copy toDir="${project.ctxt-dir}/resources/images" filtering="false"
        overwrite="true" failonerror="false">
        <fileset dir="${project.images-dir}"/>
      </copy>
    </target>
  
    <target name="copy-schema" if="schema.present">
      <echo>Copying schemas..</echo>
      <copy toDir="${project.ctxt-dir}/resources/schema" filtering="false"
        overwrite="true" failonerror="false">
        <fileset dir="${project.schema-dir}"/>
      </copy>
    </target>
  
    <target name="copy-lib" if="lib.present">
      <copy toDir="${project.ctxt-dir}/WEB-INF/lib" filtering="false"
        overwrite="true" failonerror="false">
        <fileset dir="${project.lib-dir}"/>
      </copy>
    </target>
  
    <target name="copy-classes" if="classes.present">
      <copy toDir="${project.ctxt-dir}/WEB-INF/classes" filtering="false"
        overwrite="true" failonerror="false">
        <fileset dir="${project.classes-dir}"/>
      </copy>
    </target>
  
    <target name="copy-skins" if="skins.present">
      <copy toDir="${project.ctxt-dir}/skins" filtering="off" overwrite="true" failonerror="false">
         <fileset dir="${project.skins-dir}" >
          <include name="**/images/**" />
        </fileset>
      </copy>
      <copy toDir="${project.ctxt-dir}/skins" filtering="on" overwrite="true" failonerror="false">
        <fileset dir="${project.skins-dir}" >
          <exclude name="**/images/**" />
        </fileset>
      </copy>
    </target>
  
    <target name="copy-skinconf" if="skinconf.present">
      <copy file="${project.skinconf}"
        toDir="${project.ctxt-dir}" filtering="false"
        overwrite="true" failonerror="false"/>
    </target>
  
    <target name="copy-status" if="status.present">
      <copy file="${project.status}" todir="${project.ctxt-dir}" filtering="false"/>
    </target>
  
  
    <!-- ===============================================================
         Makes the Cocoon context dir to work in and fills it completely.
         That is by depending on:
           bare-context     // for forrest predefines.  
           project-context  // for project's actual content
             (now: copy stuff from extra param defining the content dir
              with siteplan: based on that)
           control-context  // for derivatives from siteplan 
             (now: no need, waiting on siteplan future)
              with siteplan: e.g. sitemap and catalog)
         param: name of the skin to use ${project.skin} (now)
         param: location to find the content ${project.content-dir}(now)
         param: location of siteplan ${project.siteplan} (future)
         param: location to make temporary context-dir ${project.ctxt-dir} 
         =============================================================== -->
    <target name="prepare-context" depends="init, bare-context, project-context" />
  
  
    <!-- ===============================================================
         Cleans the site.  (typically before generating the new version)
         param: location to clean ${project.site-dir}
         =============================================================== -->
    <target name="clean-site">
      <delete dir="${project.site-dir}"/>
    </target>
  
    <!-- ===============================================================
         Checks if the current project contains Forrest docs, and sets
         the 'project.empty' property if no docs are found.
         =============================================================== -->
    <target name="check-contentdir" depends="init-props">
      <available property="project.content.present" file="${project.xdocs-dir}"
        type="dir"/>
    </target>
  
    <target name="ensure-nocontent" depends="check-contentdir"
      if="project.content.present">
      <echo>
  ------------------------------------------------
  This project already has content in ${project.xdocs-dir}.
  ------------------------------------------------
      </echo>
      <fail message="Project already has content"/>
    </target>
  
    <target name="ensure-content" depends="check-contentdir"
      unless="project.content.present">
      <echo>
  ------------------------------------------------
  This project has no content in ${project.xdocs-dir}.
  Use the 'seed' target to create a template project structure.
  ------------------------------------------------
      </echo>
      <fail message="Project has no content"/>
    </target>
  
    <!-- ===============================================================
         Makes the site.
         param: name of the skin to use ${project.skin} (now)
         param: location to find the content ${project.content-dir}(now)
         param: location of siteplan ${project.siteplan} (future)
         param: location to make temporary context-dir ${project.ctxt-dir} 
         param: location to make temporary work-dir ${project.content-dir}
         param: debuglevel for logging ${project.debuglevel}
         param: location of log-file ${project.logkitfile}
         =============================================================== -->
   <target name="site" depends="ensure-content, validate, init, prepare-context, clean-site, prepare-classpath"
     if="project.content.present"
           description="Generates a static HTML website for this project">
      <!-- clean out the temp space, if we don't cocoon fails on this
           actually clears the cache, not yet clear why it is really needed? -->
      <delete dir="${project.work-dir}"/>
      <mkdir dir="${project.work-dir}"/>
      <java classname="org.apache.cocoon.Main" fork="true"
            dir="." failonerror="true"
            classpathref="forrest.cp"
            >
        <jvmarg
          value="-Djava.endorsed.dirs=${forrest.home}/lib/endorsed${path.separator}${java.endorsed.dirs}"/>
        <arg value="-c${project.ctxt-dir}"/>   <!-- input to the process -->
        <arg value="-d${project.site-dir}"/>   <!-- output to be put -->
        <arg value="-w${project.work-dir}"/>   <!-- temp dir to use for e.g. cache -->
        <arg value="-u${project.debuglevel}"/> <!-- threshold for log messages -->
        <arg value="-C${project.ctxt-dir}/WEB-INF/cocoon.xconf"/>      <!-- cocoon.xconf file to use -->
        <arg value="-b${project.brokenlinkfile}"/>  <!-- output list of broken links -->
        <arg value="-k${project.ctxt-dir}/WEB-INF/logkit.xconf"/>  <!-- output list of broken links -->
        <arg value="${project.start-uri}"/>              <!-- starting page -->
        <arg value="-V" />                          <!-- be verbose -->
      </java>
      <echo>
  ------------------------------
  Static site generated at:
    ${project.site-dir}
  
  Please check the file
  ${project.brokenlinkfile}
  for any broken links in the generated site.
  ------------------------------
      </echo>
    </target>
  
  
    <target name="project.webapp.defined" unless="project.webapp">
      <echo>
        ------------------------------------------------
        Error: $${project.webapp} variable has not been set. This is where the
        webapp will be assembled. Please define it in the calling script.
        ------------------------------------------------
      </echo>
      <fail message="project.webapp variable not set"/>
    </target>
  
    <!-- ===============================================================
         Builds a cocoon webapp for your project.
         param: location to put generated webapp ${project.webapp}
         =============================================================== -->
    <target name="webapp" depends="init, project.webapp.defined, prepare-context,
           load-project-props"
     description="Generates a dynamic servlet-based website (an unpackaged webapp)">
      <!-- this will need revisions in the case of the siteplan
      extra project-custom classes then will need to be warred in as well. -->
      <mkdir dir="${project.webapp}/WEB-INF"/>
      <copy file="${forrest.home}/WEB-INF/web.xml" todir="${project.webapp}/WEB-INF"/>
      <copy todir="${project.webapp}">
        <fileset dir="${project.ctxt-dir}" >
          <exclude name="*.xconf" /> <!-- CLI wants them there, webapp finds them in WEB-INF -->
        </fileset>
      </copy>
  
      <copy todir="${project.webapp}/WEB-INF">
        <!-- Note: no overwriting, so user's libs and classes get preference -->
        <fileset dir="${forrest.home}/WEB-INF">
          <include name="lib/**"/>
          <include name="classes/**"/>
        </fileset>
      </copy>
  
      <echo>
  ---------------------------------
  Webapp generated in ${project.webapp}
  
  To run in Tomcat, add this to the config file (usu. server.xml):
  
  &lt;Context path='/${skinconfig.project-name}'
              docBase='${project.webapp}'
              reloadable='true'/&gt;
  
  If using JDK 1.4 or above, make sure to set the Java environment variable
  -Djava.endorsed.dirs=${forrest.home}/lib/endorsed
  Eg, in the TOMCAT_OPTS (3.3.x) or CATALINA_OPTS (4.x) env variable.
  ---------------------------------
      </echo>
    </target>
  
    <!-- ===============================================================
         Builds a cocoon .war for your project based on the siteplan.
         param: location to put generated war ${project.war}
         =============================================================== -->
   <target name="war" depends="webapp"
     description="Generates a dynamic servlet-based website (an packaged .war file)">
  
     <jar destfile="${project.war}" basedir="${project.webapp}"/>
     <echo>
  ---------------------------------
  Webapp .war file generated:
  ${project.war}
  ---------------------------------
     </echo>
    </target>
  
  
  
  <!-- ***************************************************************** -->
  <!-- ***************************************************************** -->
  <!-- **                                                             ** -->
  <!-- **                                                             ** -->
  <!-- **          PROJECT-TEMPLATE BUILDING ACTIONS                  ** -->
  <!-- **                                                             ** -->
  <!-- **                                                             ** -->
  <!-- ***************************************************************** -->
  <!-- ***************************************************************** -->
  
  
  
    <!-- ===============================================================
          Copies a template structure over to your project dir.
         =============================================================== -->
    <target name="seed" depends="ensure-nocontent"
      description="Seeds a directory with a template project doc structure">
      <unzip src="${forrest.home}/fresh-site.zip" 
        dest="${project.home}"
        overwrite="false"/>
      <echo>
  -------------------------------
  ~~ Template project created! ~~
  
  Here is an outline of the generated files:
  
  /                         # ${basedir}
  /status.xml               # File listing project developers, todo list and change log
  /forrest.properties       # Optional file describing this site's layout to Forrest
  /src/documentation/       # Doc-specific files
  /src/documentation/skinconf.xml    # Info about your project used by the skin
  /src/documentation/content/xdocs   # XML content.
  /src/documentation/content/xdocs/index.xml  # Home page
  /src/documentation/content/xdocs/book.xml   # Navigation file defining site structure
  /src/documentation/content/xdocs/tabs.xml   # Skin-specific 'tabs' file.
  /src/documentation/resources/images         # Project images (logos, etc)
  
  
  What to do now?
  
  - Try rendering this template to HTML by typing 'forrest'. View the generated HTML
    in a browser to make sure everything works.
  - Edit status.xml and src/documentation/skinconf.xml and customize for your project.
  - Replace src/documentation/resources/images/project-logo.gif with your project logo.
  - Start adding content in xdocs/, remembering to add new files to book.xml
  - Give any feedback you have to forrest-dev@xml.apache.org
  
  Thanks for using Apache Forrest
  -------------------------------
      </echo>
    </target>
  
    <!-- ===============================================================
         Validates all XML documents in the projects-context dir.
         =============================================================== -->
    <target name="validate" depends="init-props">
      <xmlvalidate failonerror="no" lenient="yes" warn="yes">
        <xmlcatalog>
          <catalogfiles dir="${project.schema-dir}">
            <include name="catalog" />
          </catalogfiles>
          <catalogfiles dir="${forrest.home}/context/resources/schema">
            <include name="catalog" />
          </catalogfiles>
        </xmlcatalog>
        <fileset dir="${project.xdocs-dir}">
          <include name="*.x*" />
          <exclude name="*build.xml"/>
        </fileset>
      </xmlvalidate>
    </target>
  
  </project>