Search:

Apache » Lenya
project logo
  • Project
  • Developer
  • Community
  • Version 2.2
  • Version 2.0
  • Version 1.2
  • Version 1.2
    • Installation
      • Download
      • Subversion Access
      • Install Instructions
    • Tutorial
      • Introduction
      • 1. Understanding Lenya
      • 2. Installing Lenya
      • 3. Anatomy of the Pipeline
      • 4. Editing in Lenya
      • 5. Custom Navigation in Lenya
      • 6a. Mod Proxy and Lenya
      • 6b. Mod Proxy and Lenya
    • How-To
      • FAQ
      • New Publication
      • Deploy Publication
      • Look and Feel
      • Custom Resource Type
      • Adding Mime Types
      • Site Navigation
      • LDAP Authentication
      • CMS Menus
      • CMS Screens
      • Search Publications
      • External Data
      • Unit Tests
    • Components
      • Access Control
        • Basic Terms
        • Access Controllers
        • Access Controller Resolvers
        • Authenticators
        • Authorizers
        • Policies and Policy Managers
        • Accreditable Managers
        • SSL Encryption
      • Authoring
        • Adding a new document creator
        • Image Upload
        • OpenOffice
      • Deployment
        • Proxying
      • Editors
        • HTML Form Editor
        • HTML One Form Editor
        • Bitflux Editor
        • Kupu
        • Xopus
      • Layout
        • Navigation
        • XHTML templating
        • Serving static resources
        • Lenya Menubar
      • Publication
        • PageEnvelopeModule
        • Site tree
      • Resource Types
        • Resource Types
      • Revision Control
        • Revision Controller
        • RCML
        • Check In
        • Check Out
        • Revisions
        • Rollback
      • Repository
        • WebDAV Servers
      • Search
        • Searching with Lucene
      • URI Handling
        • URI Parametrizer
        • URI Scheme
        • Usecases
      • Asset Management
        • Asset Management
      • Link Management
        • Link Management
      • Meta Data
        • Meta Data Handling
      • Multilingual Documents
        • Multilingual Document Handling
      • Tasks
        • The Task Concept
        • Defining Tasks
        • The TaskAction
        • Scheduling a Task
        • Included tasks
          • AntTask
          • DefaultFilePublisher
          • StaticHTMLExporter
          • MailTask
        • Developing Tasks
      • Workflow
        • Terms
        • The State Machine
        • Configuration
        • Implementation
      • Site Management
        • Archive
        • Copy
        • Deactivate
        • Delete
        • Delete the trash
        • Move
        • Move Up/Down
        • Rename
        • Restore
    • Miscellaneous
      • Namespaces
      • Reserved Names
      • XInclude Processor
    • 1.2 API (Javadoc)

Current Event

Meeting Bad Säckingen 2009

Built with Apache Lenya

The AntTask

Table of Contents
  • Task Parameters
  • Logging
  • Writing AntTask Buildfiles
  • Using custom Ant Tasks
  • File Locations
  • Example

The org.apache.lenya.cms.task.AntTask class can be used to invoke targets of an Ant project.

Task Parameters

The task parameters are:

  • publication-id : The publication ID
  • buildfile (optional) : The location of the build file relative to the publication directory. If this parameter is not provided, the file is loaded from the default location (see section File Locations).
  • target (optional) : The build target. If this parameter is not provided, the default target is executed.
  • properties.* : The project properties.
  • ant.* : The command-line parameters for Ant (not implemented yet!)

Logging

Every time an AntTask is invoked, a log file is created unsing the XmlLogger (manual entry, JavaDoc). For the location of the log files, see section File Locations. The log history can be viewed at the URI

http://.../<publication>/logs/tasks/index.html

Writing AntTask Buildfiles

Any Ant project file can be used as a buildfile for the AntTask. There is one implicit property that is always set when an AntTask is executed:

  • pub.dir : The absolute path of publication directory.

The runtime properties of the target can be set using task parameters with the prefix properties, e. g. properties.filename for a buildfile property named filename.

Using custom Ant Tasks

The implementation of custom Ant tasks is described in the Ant User Manual. If you want to write a general Lenya task, put it into the package org.lenya.cms.ant. If you want to write a task that is only suited for your publication, put it in the <publication>/java/src/ directory.

File Locations

Default buildfile location:

<publication>/config/tasks/targets.xml

Log files:

<publication>/logs/tasks/*.xml

Log file presentation stylesheets:

<webapp>/lenya/xslt/logs/*.xsl

Example

The following buildfile contains the target publish that can be invoked using the AntTask:

<project name="Example Project" default="publish" basedir=".">

  <!-- implicit properties (set by the AntTask) -->
  <property name="pub.dir" value=""/>

  <!-- publishing properties -->
  <property name="authoring.dir" value="content/authoring"/>
  <property name="live.dir" value="content/live"/>
  <property name="publish.sources" value=""/>

  <target name="publish">
    <echo>Publish: Copying files from ${authoring.dir} to ${live.dir}</echo>
    <copy todir="${pub.dir}/${live.dir}">
      <fileset dir="${pub.dir}/${authoring.dir}">
        <include name="${publish.sources}"/>
      </fileset>
    </copy>
  </target>

</project>

You define the task in your tasks.xconf file:

<task id="ant" class="org.lenya.cms.task.AntTask"/>

To invoke the task from your sitemap, you have to define an appropriate TaskAction instance:

<map:action name="publish"
    src="org.lenya.cms.cocoon.acting.TaskAction">
  <task id="ant"/>
</map:action>

You call the action in a pipeline:

<map:match pattern="publish.html">
  <map:act type="publish">
    ...
  </map:act>
</map:match>

And finally, go to your browser and call the URI with the appropriate parameter(s):

http://.../publish.html?properties.publish.sources=test.xml

Copyright © 1999-2009 The Apache Software Foundation. All rights reserved.