Class Snip

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class Snip
    extends org.apache.tools.ant.Task
    An Ant task designed to help with the single-sourcing of program documentation. This task extracts snippets of text from files, placing them into properties in the Ant project. These properties can then be used by any other Ant task, and are particularly useful when referenced by <filter>s within the <copy> task.

    The <snip> task takes one or more nested <fileset>s that indicate the files to process. Any text between lines containing "@@snip:myProperty@@" and "@@endSnip@@" will be stored in a property called snip.myProperty.

    Example Usage:

     
     <taskdef
         name="snip"
         classname="com.martiansoftware.snip.Snip" 
         classpath="snip-0.11.jar"/>
                    
     <snip>
         <fileset dir="src" includes="**/*.txt" />
     </snip>
     

    Multiple snippets may be defined within a single file. Snippets may not be nested.

    Author:
    Marty Lamb
    • Field Summary

      • Fields inherited from class org.apache.tools.ant.Task

        target, taskName, taskType, wrapper
      • Fields inherited from class org.apache.tools.ant.ProjectComponent

        description, location, project
    • Constructor Summary

      Constructors 
      Constructor Description
      Snip()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addFileSet​(org.apache.tools.ant.types.FileSet fs)
      Adds a FileSet to this Task
      void execute()
      Reads all snippets from the previously specified FileSets, storing their contents in project properties.
      void setXmlsafe​(boolean xmlSafe)
      Sets whether properties set by this task should be "xml-safe" - that is, should have any greater-than or less-than signs xml-encoded
      • Methods inherited from class org.apache.tools.ant.Task

        bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
      • Methods inherited from class org.apache.tools.ant.ProjectComponent

        clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Snip

        public Snip()
    • Method Detail

      • addFileSet

        public void addFileSet​(org.apache.tools.ant.types.FileSet fs)
        Adds a FileSet to this Task
        Parameters:
        fs - the FileSet to add
      • setXmlsafe

        public void setXmlsafe​(boolean xmlSafe)
        Sets whether properties set by this task should be "xml-safe" - that is, should have any greater-than or less-than signs xml-encoded
        Parameters:
        xmlSafe -
      • execute

        public void execute()
                     throws org.apache.tools.ant.BuildException
        Reads all snippets from the previously specified FileSets, storing their contents in project properties.
        Overrides:
        execute in class org.apache.tools.ant.Task
        Throws:
        org.apache.tools.ant.BuildException - if any I/O errors occur while reading files.