ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core AbstractAntTask.java AbstractAvailableCondition.java AntCallTask.java AntParam.java AntTask.java ClassAvailableCondition.java ConditionTask.java Equals.java ExtFileNameMapper.java Fail.java FileTokenSet.java FlatFileNameMapper.java IfTask.java LoadProperties.java Log.java PrefixFileNameMapper.java Property.java PropertyDump.java PropertyLoader.java PropertyTokenSet.java ResourceAvailableCondition.java Resources.properties SingletonTokenSet.java StringToEnumConverter.java StringToFileConverter.java TryCatchTask.java
Date Sun, 14 Apr 2002 10:55:09 GMT
donaldp     02/04/14 03:55:09

  Added:       antlib/src/java/org/apache/antlib/extensions
                        ExtensionAdapter.java ExtensionSet.java
                        ExtensionUtil.java ExtraAttribute.java
                        JarLibDisplayTask.java JarLibManifestTask.java
                        LibFileSet.java LibraryDisplayer.java
                        Resources.properties
               antlib/src/java/org/apache/antlib/runtime ConverterDef.java
                        Facility.java Import.java Resources.properties
                        TypeAvailableCondition.java TypeDef.java
               antlib/src/java/org/apache/antlib/build BuildNumber.java
                        Checksum.java Patch.java Resources.properties
                        SleepTask.java UpToDateCondition.java
               antlib/src/java/org/apache/antlib/core AbstractAntTask.java
                        AbstractAvailableCondition.java AntCallTask.java
                        AntParam.java AntTask.java
                        ClassAvailableCondition.java ConditionTask.java
                        Equals.java ExtFileNameMapper.java Fail.java
                        FileTokenSet.java FlatFileNameMapper.java
                        IfTask.java LoadProperties.java Log.java
                        PrefixFileNameMapper.java Property.java
                        PropertyDump.java PropertyLoader.java
                        PropertyTokenSet.java
                        ResourceAvailableCondition.java
                        Resources.properties SingletonTokenSet.java
                        StringToEnumConverter.java
                        StringToFileConverter.java TryCatchTask.java
  Log:
  Some more antlibs.
  
  Revision  Changes    Path
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/extensions/ExtensionAdapter.java
  
  Index: ExtensionAdapter.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.extensions;
  
  import org.apache.avalon.excalibur.extension.DeweyDecimal;
  import org.apache.avalon.excalibur.extension.Extension;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.framework.DataType;
  
  /**
   * Simple class that represents an Extension and conforms to Ants
   * patterns.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/14 10:55:07 $
   * @ant.data-type name="extension"
   */
  public class ExtensionAdapter
      implements DataType
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( ExtensionAdapter.class );
  
      /**
       * The name of the optional package being made available, or required.
       */
      private String m_extensionName;
  
      /**
       * The version number (dotted decimal notation) of the specification
       * to which this optional package conforms.
       */
      private DeweyDecimal m_specificationVersion;
  
      /**
       * The name of the company or organization that originated the
       * specification to which this optional package conforms.
       */
      private String m_specificationVendor;
  
      /**
       * The unique identifier of the company that produced the optional
       * package contained in this JAR file.
       */
      private String m_implementationVendorID;
  
      /**
       * The name of the company or organization that produced this
       * implementation of this optional package.
       */
      private String m_implementationVendor;
  
      /**
       * The version number (dotted decimal notation) for this implementation
       * of the optional package.
       */
      private DeweyDecimal m_implementationVersion;
  
      /**
       * The URL from which the most recent version of this optional package
       * can be obtained if it is not already installed.
       */
      private String m_implementationURL;
  
      /**
       * Set the name of extension.
       *
       * @param extensionName the name of extension
       */
      public void setExtensionName( final String extensionName )
      {
          m_extensionName = extensionName;
      }
  
      /**
       * Set the specificationVersion of extension.
       *
       * @param specificationVersion the specificationVersion of extension
       */
      public void setSpecificationVersion( final String specificationVersion )
      {
          m_specificationVersion = new DeweyDecimal( specificationVersion );
      }
  
      /**
       * Set the specificationVendor of extension.
       *
       * @param specificationVendor the specificationVendor of extension
       */
      public void setSpecificationVendor( final String specificationVendor )
      {
          m_specificationVendor = specificationVendor;
      }
  
      /**
       * Set the implementationVendorID of extension.
       *
       * @param implementationVendorID the implementationVendorID of extension
       */
      public void setImplementationVendorID( final String implementationVendorID )
      {
          m_implementationVendorID = implementationVendorID;
      }
  
      /**
       * Set the implementationVendor of extension.
       *
       * @param implementationVendor the implementationVendor of extension
       */
      public void setImplementationVendor( final String implementationVendor )
      {
          m_implementationVendor = implementationVendor;
      }
  
      /**
       * Set the implementationVersion of extension.
       *
       * @param implementationVersion the implementationVersion of extension
       */
      public void setImplementationVersion( final String implementationVersion )
      {
          m_implementationVersion = new DeweyDecimal( implementationVersion );
      }
  
      /**
       * Set the implementationURL of extension.
       *
       * @param implementationURL the implementationURL of extension
       */
      public void setImplementationURL( final String implementationURL )
      {
          m_implementationURL = implementationURL;
      }
  
      /**
       * Convert this adpater object into an extension object.
       *
       * @return the extension object
       */
      Extension toExtension()
          throws TaskException
      {
          if( null == m_extensionName )
          {
              final String message = REZ.getString( "extension.noname.error" );
              throw new TaskException( message );
          }
  
          String specificationVersion = null;
          if( null != m_specificationVersion )
          {
              specificationVersion = m_specificationVersion.toString();
          }
          String implementationVersion = null;
          if( null != m_implementationVersion )
          {
              implementationVersion = m_implementationVersion.toString();
          }
          return new Extension( m_extensionName,
                                specificationVersion,
                                m_specificationVendor,
                                implementationVersion,
                                m_implementationVendorID,
                                m_implementationVendor,
                                m_implementationURL );
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/extensions/ExtensionSet.java
  
  Index: ExtensionSet.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.extensions;
  
  import java.util.ArrayList;
  import org.apache.avalon.excalibur.extension.Extension;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.framework.DataType;
  
  /**
   * The Extension set lists a set of "Optional Packages" /
   * "Extensions".
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/14 10:55:07 $
   * @ant.data-type name="extension-set"
   */
  public class ExtensionSet
      implements DataType
  {
      /**
       * ExtensionAdapter objects representing extensions.
       */
      private final ArrayList m_extensions = new ArrayList();
  
      /**
       * Filesets specifying all the extensions wanted.
       */
      private final ArrayList m_extensionsFilesets = new ArrayList();
  
      /**
       * Adds an extension that this library requires.
       *
       * @param extensionAdapter an extension that this library requires.
       */
      public void addExtension( final ExtensionAdapter extensionAdapter )
      {
          m_extensions.add( extensionAdapter );
      }
  
      /**
       * Adds a set of files about which extensions data will be extracted.
       *
       * @param fileSet a set of files about which extensions data will be extracted.
       */
      public void addLibfileset( final LibFileSet fileSet )
      {
          m_extensionsFilesets.add( fileSet );
      }
  
      /**
       * Extract a set of Extension objects from the ExtensionSet.
       *
       * @throws TaskException if an error occurs
       */
      public Extension[] toExtensions()
          throws TaskException
      {
          final ArrayList extensions = ExtensionUtil.toExtensions( m_extensions );
          ExtensionUtil.extractExtensions( extensions, m_extensionsFilesets );
          return (Extension[])extensions.toArray( new Extension[ extensions.size() ] );
      }
  
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/extensions/ExtensionUtil.java
  
  Index: ExtensionUtil.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.extensions;
  
  import java.io.File;
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.jar.JarFile;
  import org.apache.avalon.excalibur.extension.Extension;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.tools.todo.types.DirectoryScanner;
  import org.apache.tools.todo.types.ScannerUtil;
  
  /**
   * A set of useful methods relating to extensions.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/14 10:55:07 $
   */
  public class ExtensionUtil
  {
      /**
       * Convert a list of extensionAdapter objects to extensions.
       *
       * @param adapters the list of ExtensionAdapterss to add to convert
       * @throws TaskException if an error occurs
       */
      static ArrayList toExtensions( final ArrayList adapters )
          throws TaskException
      {
          final ArrayList results = new ArrayList();
  
          final int size = adapters.size();
          for( int i = 0; i < size; i++ )
          {
              final ExtensionAdapter adapter =
                  (ExtensionAdapter)adapters.get( i );
              final Extension extension = adapter.toExtension();
              results.add( extension );
          }
  
          return results;
      }
  
      /**
       * Generate a list of extensions from a specified fileset.
       *
       * @param librarys the list to add extensions to
       * @param fileset the filesets containing librarys
       * @throws TaskException if an error occurs
       */
      static void extractExtensions( final ArrayList librarys,
                                     final ArrayList fileset )
          throws TaskException
      {
          if( !fileset.isEmpty() )
          {
              final Extension[] extensions = getExtensions( fileset );
              for( int i = 0; i < extensions.length; i++ )
              {
                  librarys.add( extensions[ i ] );
              }
          }
      }
  
      /**
       * Retrieve extensions from the specified librarys.
       *
       * @param librarys the filesets for librarys
       * @return the extensions contained in librarys
       * @throws TaskException if failing to scan librarys
       */
      private static Extension[] getExtensions( final ArrayList librarys )
          throws TaskException
      {
          final ArrayList extensions = new ArrayList();
          final Iterator iterator = librarys.iterator();
          while( iterator.hasNext() )
          {
              final LibFileSet fileSet = (LibFileSet)iterator.next();
              final DirectoryScanner scanner = ScannerUtil.getDirectoryScanner( fileSet );
              final File basedir = scanner.getBasedir();
              final String[] files = scanner.getIncludedFiles();
              for( int i = 0; i < files.length; i++ )
              {
                  final File file = new File( basedir, files[ i ] );
                  loadExtensions( file, extensions );
              }
          }
          return (Extension[])extensions.toArray( new Extension[ extensions.size() ] );
      }
  
      /**
       * Load list of available extensions from specified file.
       *
       * @param file the file
       * @param extensions the list to add available extensions to
       * @throws TaskException if there is an error
       */
      private static void loadExtensions( final File file,
                                          final ArrayList extensions )
          throws TaskException
      {
          try
          {
              final JarFile jarFile = new JarFile( file );
              final Extension[] extension =
                  Extension.getAvailable( jarFile.getManifest() );
              for( int i = 0; i < extension.length; i++ )
              {
                  extensions.add( extension[ i ] );
              }
          }
          catch( final Exception e )
          {
              throw new TaskException( e.getMessage(), e );
          }
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/extensions/ExtraAttribute.java
  
  Index: ExtraAttribute.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.extensions;
  
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.myrmidon.api.TaskException;
  
  /**
   * Simple holder for extra attributes in main section of manifest.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/14 10:55:07 $
   * @todo Refactor this and all the other parameter, sysproperty,
   *   property etc into a single class in framework
   */
  public class ExtraAttribute
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( ExtraAttribute.class );
  
      private String m_name;
      private String m_value;
  
      /**
       * Set the name of the parameter.
       *
       * @param name the name of parameter
       */
      public void setName( final String name )
      {
          m_name = name;
      }
  
      /**
       * Set the value of the parameter.
       *
       * @param value the parameter value
       */
      public void setValue( final String value )
      {
          m_value = value;
      }
  
      /**
       * Retrieve name of parameter.
       *
       * @return the name of parameter.
       */
      String getName()
      {
          return m_name;
      }
  
      /**
       * Retrieve the value of parameter.
       *
       * @return the value of parameter.
       */
      String getValue()
      {
          return m_value;
      }
  
      /**
       * Make sure that neither the name or the value
       * is null.
       */
      public void validate()
          throws TaskException
      {
          if( null == m_name )
          {
              final String message = REZ.getString( "param.noname.error" );
              throw new TaskException( message );
          }
          else if( null == m_value )
          {
              final String message =
                  REZ.getString( "param.novalue.error", m_name );
              throw new TaskException( message );
          }
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/extensions/JarLibDisplayTask.java
  
  Index: JarLibDisplayTask.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.extensions;
  
  import java.io.File;
  import java.util.Iterator;
  import java.util.Vector;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.myrmidon.api.AbstractTask;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.framework.FileSet;
  import org.apache.tools.todo.types.DirectoryScanner;
  import org.apache.tools.todo.types.ScannerUtil;
  
  /**
   * Display the "Optional Package" and "Package Specification" information
   * contained within the specified jars.
   *
   * <p>Prior to JDK1.3, an "Optional Package" was known as an Extension.
   * The specification for this mechanism is available in the JDK1.3
   * documentation in the directory
   * $JDK_HOME/docs/guide/extensions/versioning.html. Alternatively it is
   * available online at <a href="http://java.sun.com/j2se/1.3/docs/guide/extensions/versioning.html">
   * http://java.sun.com/j2se/1.3/docs/guide/extensions/versioning.html</a>.</p>
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @ant.task name="jarlib-display"
   */
  public class JarLibDisplayTask
      extends AbstractTask
  {
      private final static Resources REZ =
          ResourceManager.getPackageResources( JarLibDisplayTask.class );
  
      /**
       * The library to display information about.
       */
      private File m_file;
  
      /**
       * Filesets specifying all the librarys
       * to display information about.
       */
      private final Vector m_filesets = new Vector();
  
      /**
       * The jar library to display information for.
       *
       * @param file The jar library to display information for.
       */
      public void setFile( final File file )
      {
          m_file = file;
      }
  
      /**
       * Adds a set of files about which library data will be displayed.
       *
       * @param fileSet a set of files about which library data will be displayed.
       */
      public void addFileset( final FileSet fileSet )
      {
          m_filesets.addElement( fileSet );
      }
  
      public void execute()
          throws TaskException
      {
          validate();
  
          final LibraryDisplayer displayer = new LibraryDisplayer();
          // Check if list of files to check has been specified
          if( !m_filesets.isEmpty() )
          {
              final Iterator iterator = m_filesets.iterator();
              while( iterator.hasNext() )
              {
                  final FileSet fileSet = (FileSet)iterator.next();
                  final DirectoryScanner scanner = ScannerUtil.getDirectoryScanner( fileSet );
                  final File basedir = scanner.getBasedir();
                  final String[] files = scanner.getIncludedFiles();
                  for( int i = 0; i < files.length; i++ )
                  {
                      final File file = new File( basedir, files[ i ] );
                      displayer.displayLibrary( file );
                  }
              }
          }
          else
          {
              displayer.displayLibrary( m_file );
          }
      }
  
      /**
       * Validate the tasks parameters.
       *
       * @throws TaskException if invalid parameters found
       */
      private void validate()
          throws TaskException
      {
          if( null == m_file && m_filesets.isEmpty() )
          {
              final String message = REZ.getString( "extension.missing-file.error" );
              throw new TaskException( message );
          }
          if( null != m_file && !m_file.exists() )
          {
              final String message = REZ.getString( "extension.file-noexist.error", m_file );
              throw new TaskException( message );
          }
          if( null != m_file && !m_file.isFile() )
          {
              final String message = REZ.getString( "extension.bad-file.error", m_file );
              throw new TaskException( message );
          }
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/extensions/JarLibManifestTask.java
  
  Index: JarLibManifestTask.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.extensions;
  
  import java.io.File;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.jar.Attributes;
  import java.util.jar.Manifest;
  import org.apache.avalon.excalibur.extension.Extension;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.avalon.excalibur.io.IOUtil;
  import org.apache.myrmidon.Constants;
  import org.apache.myrmidon.api.AbstractTask;
  import org.apache.myrmidon.api.TaskException;
  
  /**
   * Task to generate a manifest that declares all the dependencies
   * in manifest. The dependencies are determined by looking in the
   * specified path and searching for Extension / "Optional Package"
   * specifications in the manifests of the jars.
   *
   * <p>Prior to JDK1.3, an "Optional Package" was known as an Extension.
   * The specification for this mechanism is available in the JDK1.3
   * documentation in the directory
   * $JDK_HOME/docs/guide/extensions/versioning.html. Alternatively it is
   * available online at <a href="http://java.sun.com/j2se/1.3/docs/guide/extensions/versioning.html">
   * http://java.sun.com/j2se/1.3/docs/guide/extensions/versioning.html</a>.</p>
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @ant.task name="jarlib-manifest"
   */
  public final class JarLibManifestTask
      extends AbstractTask
  {
      private final static Resources REZ =
          ResourceManager.getPackageResources( JarLibManifestTask.class );
  
      /**
       * Version of manifest spec that task generates.
       */
      private static final String MANIFEST_VERSION = "1.0";
  
      /**
       * "Created-By" string used when creating manifest.
       */
      private static final String CREATED_BY = "Created-By";
  
      /**
       * The library to display information about.
       */
      private File m_destfile;
  
      /**
       * The extension supported by this library (if any).
       */
      private Extension m_extension;
  
      /**
       * ExtensionAdapter objects representing
       * dependencies required by library.
       */
      private final ArrayList m_dependencies = new ArrayList();
  
      /**
       * ExtensionAdapter objects representing optional
       * dependencies required by library.
       */
      private final ArrayList m_optionals = new ArrayList();
  
      /**
       * Extra attributes the user specifies for main section
       * in manifest.
       */
      private final ArrayList m_extraAttributes = new ArrayList();
  
      /**
       * The location where generated manifest is placed.
       *
       * @param destfile The location where generated manifest is placed.
       */
      public void setDestfile( final File destfile )
      {
          m_destfile = destfile;
      }
  
      /**
       * Adds an extension that this library implements.
       *
       * @param extensionAdapter an extension that this library implements.
       */
      public void addExtension( final ExtensionAdapter extensionAdapter )
          throws TaskException
      {
          if( null != m_extension )
          {
              final String message = REZ.getString( "manifest.multi-extension.error" );
              throw new TaskException( message );
          }
          else
          {
              m_extension = extensionAdapter.toExtension();
          }
      }
  
      /**
       * Adds a set of extensions that this library requires.
       *
       * @param extensionSet a set of extensions that this library requires.
       */
      public void addDepends( final ExtensionSet extensionSet )
      {
          m_dependencies.add( extensionSet );
      }
  
      /**
       * Adds a set of extensions that this library optionally requires.
       *
       * @param extensionSet a set of extensions that this library optionally requires.
       */
      public void addOptions( final ExtensionSet extensionSet )
      {
          m_optionals.add( extensionSet );
      }
  
      /**
       * Adds an attribute that is to be put in main section of manifest.
       *
       * @param attribute an attribute that is to be put in main section of manifest.
       */
      public void addAttribute( final ExtraAttribute attribute )
      {
          m_extraAttributes.add( attribute );
      }
  
      public void execute()
          throws TaskException
      {
          validate();
  
          final Manifest manifest = new Manifest();
          final Attributes attributes = manifest.getMainAttributes();
  
          attributes.put( Attributes.Name.MANIFEST_VERSION, MANIFEST_VERSION );
          attributes.putValue( CREATED_BY, Constants.BUILD_DESCRIPTION );
  
          appendExtraAttributes( attributes );
  
          if( null != m_extension )
          {
              Extension.addExtension( m_extension, attributes );
          }
  
          //Add all the dependency data to manifest for dependencies
          final ArrayList depends = toExtensions( m_dependencies );
          appendExtensionList( attributes,
                               Extension.EXTENSION_LIST,
                               "lib",
                               depends.size() );
          appendLibraryList( attributes, "lib", depends );
  
          //Add all the dependency data to manifest for "optional"
          //dependencies
          final ArrayList option = toExtensions( m_optionals );
          appendExtensionList( attributes,
                               Extension.OPTIONAL_EXTENSION_LIST,
                               "opt",
                               option.size() );
          appendLibraryList( attributes, "opt", option );
  
          try
          {
              final String message =
                  REZ.getString( "manifest.file.notice",
                                 m_destfile.getAbsoluteFile() );
              getContext().info( message );
              writeManifest( manifest );
          }
          catch( final IOException ioe )
          {
              throw new TaskException( ioe.getMessage(), ioe );
          }
      }
  
      /**
       * Validate the tasks parameters.
       *
       * @throws TaskException if invalid parameters found
       */
      private void validate()
          throws TaskException
      {
          if( null == m_destfile )
          {
              final String message =
                  REZ.getString( "manifest.missing-file.error" );
              throw new TaskException( message );
          }
          if( m_destfile.exists() && !m_destfile.isFile() )
          {
              final String message =
                  REZ.getString( "manifest.bad-file.error", m_destfile );
              throw new TaskException( message );
          }
      }
  
      /**
       * Add any extra attributes to the manifest.
       *
       * @param attributes the manifest section to write
       *        attributes to
       */
      private void appendExtraAttributes( final Attributes attributes )
      {
          final Iterator iterator = m_extraAttributes.iterator();
          while( iterator.hasNext() )
          {
              final ExtraAttribute attribute =
                  (ExtraAttribute)iterator.next();
              attributes.putValue( attribute.getName(),
                                   attribute.getValue() );
          }
      }
  
      /**
       * Write out manifest to destfile.
       *
       * @param manifest the manifest
       * @throws IOException if error writing file
       */
      private void writeManifest( final Manifest manifest )
          throws IOException
      {
          FileOutputStream output = null;
          try
          {
              output = new FileOutputStream( m_destfile );
              manifest.write( output );
              output.flush();
          }
          finally
          {
              IOUtil.shutdownStream( output );
          }
      }
  
      /**
       * Append specified extensions to specified attributes.
       * Use the extensionKey to list the extensions, usually "Extension-List:"
       * for required dependencies and "Optional-Extension-List:" for optional
       * dependencies. NOTE: "Optional" dependencies are not part of the
       * specification.
       *
       * @param attributes the attributes to add extensions to
       * @param extensions the list of extensions
       * @throws TaskException if an error occurs
       */
      private void appendLibraryList( final Attributes attributes,
                                      final String listPrefix,
                                      final ArrayList extensions )
          throws TaskException
      {
          final int size = extensions.size();
          for( int i = 0; i < size; i++ )
          {
              final Extension extension = (Extension)extensions.get( i );
              final String prefix = listPrefix + i + "-";
              Extension.addExtension( extension, prefix, attributes );
          }
      }
  
      /**
       * Append an attribute such as "Extension-List: lib0 lib1 lib2"
       * using specified prefix and counting up to specified size.
       * Also use specified extensionKey so that can generate list of
       * optional dependencies aswell.
       *
       * @param size the number of librarys to list
       * @param listPrefix the prefix for all librarys
       * @param attributes the attributes to add key-value to
       * @param extensionKey the key to use
       */
      private void appendExtensionList( final Attributes attributes,
                                        final Attributes.Name extensionKey,
                                        final String listPrefix,
                                        final int size )
      {
          final StringBuffer sb = new StringBuffer();
          for( int i = 0; i < size; i++ )
          {
              sb.append( listPrefix + i );
              sb.append( ' ' );
          }
  
          //add in something like
          //"Extension-List: javahelp java3d"
          attributes.put( extensionKey, sb.toString() );
      }
  
      /**
       * Convert a list of ExtensionSet objects to extensions.
       *
       * @param extensionSets the list of ExtensionSets to add to list
       * @throws TaskException if an error occurs
       */
      private static ArrayList toExtensions( final ArrayList extensionSets )
          throws TaskException
      {
          final ArrayList results = new ArrayList();
  
          final int size = extensionSets.size();
          for( int i = 0; i < size; i++ )
          {
              final ExtensionSet set = (ExtensionSet)extensionSets.get( i );
              final Extension[] extensions = set.toExtensions();
              for( int j = 0; j < extensions.length; j++ )
              {
                  results.add( extensions[ j ] );
              }
          }
  
          return results;
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/extensions/LibFileSet.java
  
  Index: LibFileSet.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.extensions;
  
  import org.apache.myrmidon.framework.FileSet;
  
  /**
   * LibFileSet represents a fileset containing libraries.
   * Asociated with the libraries is data pertaining to
   * how they are to be handled when building manifests.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/14 10:55:07 $
   */
  public class LibFileSet
      extends FileSet
  {
      /**
       * Flag indicating whether should include the
       * "Implementation-URL" attribute in manifest.
       * Defaults to false.
       */
      private boolean m_includeURL;
  
      /**
       * Flag indicating whether should include the
       * "Implementation-*" attributes in manifest.
       * Defaults to false.
       */
      private boolean m_includeImpl;
  
      /**
       * String that is the base URL for the librarys
       * when constructing the "Implementation-URL"
       * attribute. For instance setting the base to
       * "http://jakarta.apache.org/avalon/libs/" and then
       * including the library "excalibur-cli-1.0.jar" in the
       * fileset will result in the "Implementation-URL" attribute
       * being set to "http://jakarta.apache.org/avalon/libs/excalibur-cli-1.0.jar"
       *
       * Note this is only used if the library does not define
       * "Implementation-URL" itself.
       *
       * Note that this also implies includeURL=true
       */
      private String m_urlBase;
  
      /**
       * Flag indicating whether should include the
       * "Implementation-URL" attribute in manifest.
       * Defaults to false.
       *
       * @param includeURL the flag
       * @see #m_includeURL
       */
      public void setIncludeURL( boolean includeURL )
      {
          m_includeURL = includeURL;
      }
  
      /**
       * Flag indicating whether should include the
       * "Implementation-*" attributes in manifest.
       * Defaults to false.
       *
       * @param includeImpl the flag
       * @see #m_includeImpl
       */
      public void setIncludeImpl( boolean includeImpl )
      {
          m_includeImpl = includeImpl;
      }
  
      /**
       * Set the url base for fileset.
       *
       * @param urlBase the base url
       * @see #m_urlBase
       */
      public void setUrlBase( String urlBase )
      {
          m_urlBase = urlBase;
      }
  
      /**
       * Get the includeURL flag.
       *
       * @return the includeURL flag.
       */
      boolean isIncludeURL()
      {
          return m_includeURL;
      }
  
      /**
       * Get the includeImpl flag.
       *
       * @return the includeImpl flag.
       */
      boolean isIncludeImpl()
      {
          return m_includeImpl;
      }
  
      /**
       * Get the urlbase.
       *
       * @return the urlbase.
       */
      String getUrlBase()
      {
          return m_urlBase;
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/extensions/LibraryDisplayer.java
  
  Index: LibraryDisplayer.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.extensions;
  
  import java.io.File;
  import java.io.IOException;
  import java.text.ParseException;
  import java.util.jar.JarFile;
  import java.util.jar.Manifest;
  import org.apache.avalon.excalibur.extension.Extension;
  import org.apache.avalon.excalibur.extension.Specification;
  import org.apache.myrmidon.api.TaskException;
  
  /**
   * Utility class to output the information in a jar relating
   * to "Optional Packages" (formely known as "Extensions")
   * and Package Specifications.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/14 10:55:07 $
   */
  class LibraryDisplayer
  {
      /**
       * Display the extensions and specifications contained
       * within specified file.
       *
       * @param file the file
       * @throws TaskException if fail to read file
       */
      void displayLibrary( final File file )
          throws TaskException
      {
          final Manifest manifest = getManifest( file );
          displayLibrary( file, manifest );
      }
  
      /**
       * Display the extensions and specifications contained
       * within specified file.
       *
       * @param file the file to use while reporting
       * @param manifest the manifest of file
       * @throws TaskException if fail to read file
       */
      void displayLibrary( final File file,
                           final Manifest manifest )
          throws TaskException
      {
          final Extension[] available = Extension.getAvailable( manifest );
          final Extension[] required = Extension.getRequired( manifest );
          final Extension[] options = Extension.getOptions( manifest );
          final Specification[] specifications = getSpecifications( manifest );
  
          if( 0 == available.length &&
              0 == required.length &&
              0 == options.length &&
              0 == specifications.length )
          {
              return;
          }
  
          final String message = "File: " + file;
          final int size = message.length();
          printLine( size );
          System.out.println( message );
          printLine( size );
          if( 0 != available.length )
          {
              System.out.println( "Extensions Supported By Library:" );
              for( int i = 0; i < available.length; i++ )
              {
                  final Extension extension = available[ i ];
                  System.out.println( extension.toString() );
              }
          }
  
          if( 0 != required.length )
          {
              System.out.println( "Extensions Required By Library:" );
              for( int i = 0; i < required.length; i++ )
              {
                  final Extension extension = required[ i ];
                  System.out.println( extension.toString() );
              }
          }
  
          if( 0 != options.length )
          {
              System.out.println( "Extensions that will be used by Library if present:" );
              for( int i = 0; i < options.length; i++ )
              {
                  final Extension extension = options[ i ];
                  System.out.println( extension.toString() );
              }
          }
  
          if( 0 != specifications.length )
          {
              System.out.println( "Specifications Supported By Library:" );
              for( int i = 0; i < specifications.length; i++ )
              {
                  final Specification specification = specifications[ i ];
                  displaySpecification( specification );
              }
          }
      }
  
      /**
       * Print out a line of '-'s equal to specified size.
       *
       * @param size the number of dashes to printout
       */
      private void printLine( final int size )
      {
          for( int i = 0; i < size; i++ )
          {
              System.out.print( "-" );
          }
          System.out.println();
      }
  
      /**
       * Get specifications from manifest.
       *
       * @param manifest the manifest
       * @return the specifications or null if none
       * @throws TaskException if malformed specification sections
       */
      private Specification[] getSpecifications( final Manifest manifest )
          throws TaskException
      {
          try
          {
              return Specification.getSpecifications( manifest );
          }
          catch( final ParseException pe )
          {
              throw new TaskException( pe.getMessage(), pe );
          }
      }
  
      /**
       * Print out specification details.
       *
       * @param specification the specification
       */
      private void displaySpecification( final Specification specification )
      {
          final String[] sections = specification.getSections();
          if( null != sections )
          {
              final StringBuffer sb = new StringBuffer( "Sections: " );
              for( int i = 0; i < sections.length; i++ )
              {
                  sb.append( " " );
                  sb.append( sections[ i ] );
              }
              System.out.println( sb );
          }
          System.out.println( specification.toString() );
      }
  
      /**
       * retrieve manifest for specified file.
       *
       * @param file the file
       * @return the manifest
       * @throws org.apache.myrmidon.api.TaskException if errror occurs (file not exist,
       *         file not a jar, manifest not exist in file)
       */
      private Manifest getManifest( final File file )
          throws TaskException
      {
          try
          {
              final JarFile jarFile = new JarFile( file );
              return jarFile.getManifest();
          }
          catch( final IOException ioe )
          {
              throw new TaskException( ioe.getMessage(), ioe );
          }
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/extensions/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  extension.missing-file.error=File attribute not specified.
  extension.file-noexist.error=File "{0}" does not exist.
  extension.bad-file.error="{0}" is not a file.
  
  manifest.missing-file.error=Destfile attribute not specified.
  manifest.bad-file.error="{0}" is not a file.
  manifest.file.notice=Generating manifest {0}.
  manifest.multi-extension.error=Can not have multiple extensions defined in one library.
  
  param.noname.error=Missing name from parameter.
  param.novalue.error=Missing value from parameter "{0}".
  
  extension.noname.error=Extension is missing name.
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/ConverterDef.java
  
  Index: ConverterDef.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.runtime;
  
  import org.apache.myrmidon.framework.AbstractTypeDef;
  import org.apache.myrmidon.interfaces.deployer.ConverterDefinition;
  import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
  
  /**
   * Task to define a converter.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @ant.task name="converter-def"
   */
  public class ConverterDef
      extends AbstractTypeDef
  {
      private String m_sourceType;
      private String m_destinationType;
  
      /**
       * Sets the converter's source type.
       */
      public void setSourceType( final String sourceType )
      {
          m_sourceType = sourceType;
      }
  
      /**
       * Sets the converter's destination type.
       */
      public void setDestinationType( final String destinationType )
      {
          m_destinationType = destinationType;
      }
  
      protected TypeDefinition createTypeDefinition()
      {
          return new ConverterDefinition( getClassname(), m_sourceType, m_destinationType );
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/Facility.java
  
  Index: Facility.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.runtime;
  
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.aspects.AspectHandler;
  import org.apache.myrmidon.framework.AbstractContainerTask;
  import org.apache.myrmidon.interfaces.aspect.AspectManager;
  
  /**
   * Task that definesMethod to register a single converter.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @ant.task name="facility"
   */
  public class Facility
      extends AbstractContainerTask
      implements Configurable
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( Facility.class );
  
      private String m_namespace;
      private AspectHandler m_aspectHandler;
  
      public void configure( final Configuration configuration )
          throws ConfigurationException
      {
          final String[] attributes = configuration.getAttributeNames();
          for( int i = 0; i < attributes.length; i++ )
          {
              final String name = attributes[ i ];
              final String value = configuration.getAttribute( name );
              configureAttribute( this, name, value );
          }
  
          final Configuration[] children = configuration.getChildren();
  
          if( 1 == children.length )
          {
              final String typeName = children[ 0 ].getName();
              try
              {
                  m_aspectHandler = (AspectHandler)newInstance( AspectHandler.ROLE, typeName );
              }
              catch( final Exception e )
              {
                  final String message =
                      REZ.getString( "facility.no-create.error", typeName );
                  throw new ConfigurationException( message, e );
              }
  
              configureElement( m_aspectHandler, children[ 0 ] );
          }
          else
          {
              final String message = REZ.getString( "facility.multi-element.error" );
              throw new ConfigurationException( message );
          }
      }
  
      public void setNamespace( final String namespace )
      {
          m_namespace = namespace;
      }
  
      public void execute()
          throws TaskException
      {
          if( null == m_namespace )
          {
              final String message = REZ.getString( "facility.no-namespace.error" );
              throw new TaskException( message );
          }
  
          final AspectManager aspectManager = (AspectManager)getService( AspectManager.class );
          aspectManager.addAspectHandler( m_namespace, m_aspectHandler );
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/Import.java
  
  Index: Import.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.runtime;
  
  import java.io.File;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.myrmidon.api.AbstractTask;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.interfaces.deployer.Deployer;
  import org.apache.myrmidon.interfaces.deployer.DeploymentException;
  import org.apache.myrmidon.interfaces.deployer.TypeDeployer;
  
  /**
   * Task to import a tasklib.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @ant.task name="import"
   */
  public class Import
      extends AbstractTask
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( Import.class );
  
      private File m_lib;
  
      public void setLib( final File lib )
      {
          m_lib = lib;
      }
  
      public void execute()
          throws TaskException
      {
          if( null == m_lib )
          {
              final String message = REZ.getString( "import.no-lib.error" );
              throw new TaskException( message );
          }
  
          try
          {
              final Deployer deployer = (Deployer)getService( Deployer.class );
              final TypeDeployer typeDeployer = deployer.createDeployer( m_lib );
              typeDeployer.deployAll();
          }
          catch( final DeploymentException de )
          {
              final String message = REZ.getString( "import.no-deploy.error" );
              throw new TaskException( message, de );
          }
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  facility.no-create.error=Failed to create aspect handler of type {0}.
  facility.multi-element.error=Expected one sub-element to configure facility.
  facility.no-namespace.error=Must specify namespace parameter.
  
  import.no-lib.error=Must specify lib parameter.
  import.no-deploy.error=Error importing tasklib.
  
  typeavailable.no-type-name.error=No type name was specified.
  typeavailable.unknown-role.error=Unknown role "{0}".
  typeavailable.evaluate.error=Could not determine if type "{0}" is available.
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/TypeAvailableCondition.java
  
  Index: TypeAvailableCondition.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.runtime;
  
  import org.apache.myrmidon.framework.conditions.Condition;
  import org.apache.myrmidon.framework.DataType;
  import org.apache.myrmidon.api.TaskContext;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.interfaces.role.RoleManager;
  import org.apache.myrmidon.interfaces.role.RoleInfo;
  import org.apache.myrmidon.interfaces.type.TypeManager;
  import org.apache.myrmidon.interfaces.type.TypeFactory;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  
  /**
   * A condition that evaluates to true if a particular type is available.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/14 10:55:08 $
   *
   * @ant.type type="condition" name="type-available"
   */
  public class TypeAvailableCondition
      implements Condition
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( TypeAvailableCondition.class );
  
      private String m_roleShorthand;
      private String m_name;
  
      /**
       * Sets the role to search for.
       */
      public void setType( final String type )
      {
          m_roleShorthand = type;
      }
  
      /**
       * Sets the type to search for.
       */
      public void setName( final String name )
      {
          m_name = name;
      }
  
      /**
       * Evaluates this condition.
       *
       * @param context
       *      The context to evaluate the condition in.
       */
      public boolean evaluate( final TaskContext context )
          throws TaskException
      {
          if( m_name == null )
          {
              final String message = REZ.getString( "typeavailable.no-type-name.error" );
              throw new TaskException( message );
          }
  
          try
          {
              // Map the shorthand name to a role
              final String roleName;
              if( m_roleShorthand != null )
              {
                  final RoleManager roleManager = (RoleManager)context.getService( RoleManager.class );
                  final RoleInfo roleInfo = roleManager.getRoleByShorthandName( m_roleShorthand );
                  if( roleInfo == null )
                  {
                      final String message = REZ.getString( "typeavailable.unknown-role.error", m_roleShorthand );
                      throw new TaskException( message );
                  }
                  roleName = roleInfo.getName();
              }
              else
              {
                  roleName = DataType.ROLE;
              }
  
              // Lookup the type
              final TypeManager typeManager = (TypeManager)context.getService( TypeManager.class );
              final TypeFactory typeFactory = typeManager.getFactory( roleName );
  
              // Check if the type is available
              return typeFactory.canCreate( m_name );
          }
          catch( final Exception e )
          {
              final String message = REZ.getString( "typeavailable.evaluate.error", m_name );
              throw new TaskException( message, e );
          }
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/TypeDef.java
  
  Index: TypeDef.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.runtime;
  
  import org.apache.myrmidon.framework.AbstractTypeDef;
  import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
  
  /**
   * Task to define a type.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @ant.task name="type-def"
   */
  public class TypeDef
      extends AbstractTypeDef
  {
      private String m_role;
  
      public void setName( final String name )
      {
          super.setName( name );
      }
  
      /**
       * Sets the type's role.
       */
      public void setRole( final String role )
      {
          m_role = role;
      }
  
      protected TypeDefinition createTypeDefinition()
      {
          return new TypeDefinition( getName(), m_role, getClassname() );
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/build/BuildNumber.java
  
  Index: BuildNumber.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.build;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.util.Properties;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.avalon.excalibur.io.IOUtil;
  import org.apache.myrmidon.api.AbstractTask;
  import org.apache.myrmidon.api.TaskException;
  
  /**
   * This is a basic task that can be used to track build numbers.
   *
   * It will first attempt to read a build number from a file, then
   * set the property "build.number" to the value that was read in
   * (or 0 if no such value). Then it will increment the build number
   * by one and write it back out into the file.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/14 10:55:08 $
   * @ant.task name="build-number"
   */
  public class BuildNumber
      extends AbstractTask
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( BuildNumber.class );
  
      /**
       * The name of the property in which the build number is stored.
       */
      private static final String DEFAULT_PROPERTY_NAME = "build.number";
  
      /**
       * The default filename to use if no file specified.
       */
      private static final String DEFAULT_FILENAME = DEFAULT_PROPERTY_NAME;
  
      /**
       * The File in which the build number is stored.
       */
      private File m_file;
  
      /**
       * Specify the file in which the build numberis stored.
       * Defaults to "build.number" if not specified.
       *
       * @param file the file in which build number is stored.
       */
      public void setFile( final File file )
      {
          m_file = file;
      }
  
      /**
       * Run task.
       *
       * @exception TaskException if an error occurs
       */
      public void execute()
          throws TaskException
      {
          validate();
  
          final Properties properties = loadProperties();
          final int buildNumber = getBuildNumber( properties );
  
          properties.put( DEFAULT_PROPERTY_NAME,
                          String.valueOf( buildNumber + 1 ) );
  
          // Write the properties file back out
          FileOutputStream output = null;
          try
          {
              final String header = REZ.getString( "buildnumber.header.info" );
  
              output = new FileOutputStream( m_file );
              properties.store( output, header );
          }
          catch( final IOException ioe )
          {
              final String message =
                  REZ.getString( "buildnumber.badwrite.error", m_file );
              throw new TaskException( message, ioe );
          }
          finally
          {
              IOUtil.shutdownStream( output );
          }
  
          //Finally set the property
          getContext().setProperty( DEFAULT_PROPERTY_NAME,
                                    String.valueOf( buildNumber ) );
      }
  
      /**
       * Utility method to retrieve build number from properties object.
       *
       * @param properties the properties to retrieve build number from
       * @return the build number or if no number in properties object
       * @throws TaskException if build.number property is not an integer
       */
      private int getBuildNumber( final Properties properties )
          throws TaskException
      {
          final String buildNumber =
              properties.getProperty( DEFAULT_PROPERTY_NAME, "0" ).trim();
  
          // Try parsing the line into an integer.
          try
          {
              return Integer.parseInt( buildNumber );
          }
          catch( final NumberFormatException nfe )
          {
              final String message =
                  REZ.getString( "buildnumber.noparse.error", m_file, buildNumber );
              throw new TaskException( message, nfe );
          }
      }
  
      /**
       * Utility method to load properties from file.
       *
       * @return the loaded properties
       * @throws TaskException
       */
      private Properties loadProperties()
          throws TaskException
      {
          FileInputStream input = null;
          try
          {
              final Properties properties = new Properties();
              input = new FileInputStream( m_file );
              properties.load( input );
              return properties;
          }
          catch( final IOException ioe )
          {
              throw new TaskException( ioe.getMessage(), ioe );
          }
          finally
          {
              IOUtil.shutdownStream( input );
          }
      }
  
      /**
       * Validate that the task parameters are valid.
       *
       * @throws TaskException if parameters are invalid
       */
      private void validate()
          throws TaskException
      {
          if( null == m_file )
          {
              m_file = getContext().resolveFile( DEFAULT_FILENAME );
          }
  
          if( !m_file.exists() )
          {
              try
              {
                  m_file.createNewFile();
              }
              catch( final IOException ioe )
              {
                  final String message =
                      REZ.getString( "buildnumber.nocreate.error", m_file );
                  throw new TaskException( message, ioe );
              }
          }
  
          if( !m_file.canRead() )
          {
              final String message =
                  REZ.getString( "buildnumber.noread.error", m_file );
              throw new TaskException( message );
          }
  
          if( !m_file.canWrite() )
          {
              final String message =
                  REZ.getString( "buildnumber.nowrite.error", m_file );
              throw new TaskException( message );
          }
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/build/Checksum.java
  
  Index: Checksum.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.build;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.security.DigestInputStream;
  import java.security.MessageDigest;
  import java.security.NoSuchAlgorithmException;
  import java.security.NoSuchProviderException;
  import java.util.ArrayList;
  import java.util.Enumeration;
  import java.util.Hashtable;
  import org.apache.avalon.excalibur.io.IOUtil;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.framework.AbstractMatchingTask;
  import org.apache.myrmidon.framework.FileSet;
  import org.apache.tools.todo.types.DirectoryScanner;
  import org.apache.tools.todo.types.ScannerUtil;
  
  /**
   * This task can be used to create checksums for files. It can also be used to
   * verify checksums.
   *
   * @ant.task name="checksum"
   * @author <a href="mailto:umagesh@rediffmail.com">Magesh Umasankar</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/14 10:55:08 $
   */
  public class Checksum
      extends AbstractMatchingTask
  {
      /**
       * File for which checksum is to be calculated.
       */
      private File m_file;
  
      /**
       * MessageDigest algorithm to be used.
       */
      private String m_algorithm = "MD5";
  
      /**
       * MessageDigest Algorithm provider
       */
      private String m_provider;
  
      /**
       * ArrayList to hold source file sets.
       */
      private ArrayList m_filesets = new ArrayList();
  
      /**
       * Stores SourceFile, DestFile pairs and SourceFile, Property String pairs.
       */
      private Hashtable m_includeFileMap = new Hashtable();
  
      /**
       * File Extension that is be to used to create or identify destination file
       */
      private String m_fileext;
  
      /**
       * Create new destination file? Defaults to false.
       */
      private boolean m_forceOverwrite;
  
      /**
       * Message Digest instance
       */
      private MessageDigest m_messageDigest;
  
      /**
       * Holds generated checksum and gets set as a Project Property.
       */
      private String m_property;
  
      /**
       * Contains the result of a checksum verification. ("true" or "false")
       */
      private String m_verifyProperty;
  
      /**
       * Sets the MessageDigest algorithm to be used to calculate the checksum.
       */
      public void setAlgorithm( final String algorithm )
      {
          m_algorithm = algorithm;
      }
  
      /**
       * Sets the file for which the checksum is to be calculated.
       */
      public void setFile( final File file )
      {
          m_file = file;
      }
  
      /**
       * Sets the File Extension that is be to used to create or identify
       * destination file
       */
      public void setFileext( final String fileext )
      {
          m_fileext = fileext;
      }
  
      /**
       * Overwrite existing file irrespective of whether it is newer than the
       * source file? Defaults to false.
       */
      public void setForceOverwrite( boolean forceOverwrite )
      {
          this.m_forceOverwrite = forceOverwrite;
      }
  
      /**
       * Sets the property to hold the generated checksum
       */
      public void setProperty( String property )
      {
          this.m_property = property;
      }
  
      /**
       * Sets the MessageDigest algorithm provider to be used to calculate the
       * checksum.
       *
       * @param provider The new Provider value
       */
      public void setProvider( final String provider )
      {
          m_provider = provider;
      }
  
      /**
       * Sets verify property. This project property holds the result of a
       * checksum verification - "true" or "false"
       */
      public void setVerifyproperty( final String verifyProperty )
      {
          m_verifyProperty = verifyProperty;
      }
  
      /**
       * Adds a set of files (nested fileset attribute).
       */
      public void addFileset( final FileSet set )
      {
          m_filesets.add( set );
      }
  
      /**
       * Calculate the checksum(s).
       */
      public void execute()
          throws TaskException
      {
          final boolean value = validateAndExecute();
          if( m_verifyProperty != null )
          {
              getContext().setProperty( m_verifyProperty, "" + value );
          }
      }
  
      /**
       * Add key-value pair to the hashtable upon which to later operate upon.
       *
       * @param file The feature to be added to the ToIncludeFileMap attribute
       * @exception TaskException Description of Exception
       */
      private void addToIncludeFileMap( final File file )
          throws TaskException
      {
          if( file != null )
          {
              if( file.exists() )
              {
                  if( m_property == null )
                  {
                      final File dest = new File( file.getParent(), file.getName() + m_fileext );
                      if( m_forceOverwrite ||
                          ( file.lastModified() > dest.lastModified() ) )
                      {
                          m_includeFileMap.put( file, dest );
                      }
                      else
                      {
                          final String message = file + " omitted as " + dest +
                              " is up to date.";
                          getContext().debug( message );
                      }
                  }
                  else
                  {
                      m_includeFileMap.put( file, m_property );
                  }
              }
              else
              {
                  final String message = "Could not find file " + file.getAbsolutePath() +
                      " to generate checksum for.";
                  throw new TaskException( message );
              }
          }
      }
  
      /**
       * Generate checksum(s) using the message digest created earlier.
       */
      private boolean generateChecksums()
          throws TaskException
      {
          boolean checksumMatches = true;
          final Enumeration includes = m_includeFileMap.keys();
          while( includes.hasMoreElements() )
          {
              final File src = (File)includes.nextElement();
              final String message = "Calculating " + m_algorithm + " checksum for " + src;
              getContext().verbose( message );
  
              checksumMatches = z( src, checksumMatches );
          }
  
          return checksumMatches;
      }
  
      private boolean z( final File src, final boolean checksumMatches )
          throws TaskException
      {
          boolean match = checksumMatches;
          FileInputStream fis = null;
          FileOutputStream fos = null;
          try
          {
              fis = new FileInputStream( src );
              final byte[] fileDigest = buildDigest( fis );
              IOUtil.shutdownStream( fis );
  
              final StringBuffer sb = new StringBuffer();
              for( int i = 0; i < fileDigest.length; i++ )
              {
                  final String hexStr = Integer.toHexString( 0x00ff & fileDigest[ i ] );
                  if( hexStr.length() < 2 )
                  {
                      sb.append( '0' );
                  }
                  sb.append( hexStr );
              }
  
              final String checksum = sb.toString();
  
              //can either be a property name string or a file
              final Object destination = m_includeFileMap.get( src );
              if( destination instanceof String )
              {
                  final String prop = (String)destination;
                  match = checksum.equals( m_property );
                  getContext().setProperty( prop, checksum );
              }
              else if( destination instanceof File )
              {
                  final File file = (File)destination;
                  fos = new FileOutputStream( file );
                  fos.write( checksum.getBytes() );
                  fos.close();
                  fos = null;
              }
          }
          catch( final Exception e )
          {
              throw new TaskException( e.getMessage(), e );
          }
          finally
          {
              IOUtil.shutdownStream( fis );
              IOUtil.shutdownStream( fos );
          }
          return match;
      }
  
      private byte[] buildDigest( final InputStream input )
          throws IOException
      {
          m_messageDigest.reset();
  
          final DigestInputStream digester =
              new DigestInputStream( input, m_messageDigest );
  
          while( digester.read() != -1 )
          {
          }
  
          digester.close();
          return m_messageDigest.digest();
      }
  
      /**
       * Validate attributes and get down to business.
       */
      private boolean validateAndExecute()
          throws TaskException
      {
          if( null == m_file && 0 == m_filesets.size() )
          {
              final String message = "Specify at least one source - a file or a fileset.";
              throw new TaskException( message );
          }
  
          if( null != m_file && m_file.exists() && m_file.isDirectory() )
          {
              final String message = "Checksum cannot be generated for directories";
              throw new TaskException( message );
          }
  
          if( null != m_property && null != m_fileext )
          {
              final String message = "Property and FileExt cannot co-exist.";
              throw new TaskException( message );
          }
  
          if( m_property != null )
          {
              if( m_forceOverwrite )
              {
                  final String message =
                      "ForceOverwrite cannot be used when Property is specified";
                  throw new TaskException( message );
              }
  
              if( m_file != null )
              {
                  if( m_filesets.size() > 0 )
                  {
                      final String message =
                          "Multiple files cannot be used when Property is specified";
                      throw new TaskException( message );
                  }
              }
              else
              {
                  if( m_filesets.size() > 1 )
                  {
                      final String message =
                          "Multiple files cannot be used when Property is specified";
                      throw new TaskException( message );
                  }
              }
          }
  
          if( m_verifyProperty != null && m_forceOverwrite )
          {
              final String message = "VerifyProperty and ForceOverwrite cannot co-exist.";
              throw new TaskException( message );
          }
  
          if( m_fileext == null )
          {
              m_fileext = "." + m_algorithm;
          }
          else if( m_fileext.trim().length() == 0 )
          {
              final String message = "File extension when specified must not be an empty string";
              throw new TaskException( message );
          }
  
          setupMessageDigest();
  
          if( m_messageDigest == null )
          {
              final String message = "Unable to create Message Digest";
              throw new TaskException( message );
          }
  
          addIncludes();
  
          return generateChecksums();
      }
  
      private void setupMessageDigest()
          throws TaskException
      {
          m_messageDigest = null;
          if( m_provider != null )
          {
              try
              {
                  m_messageDigest = MessageDigest.getInstance( m_algorithm, m_provider );
              }
              catch( final NoSuchAlgorithmException nsae )
              {
                  throw new TaskException( nsae.toString(), nsae );
              }
              catch( final NoSuchProviderException nspe )
              {
                  throw new TaskException( nspe.toString(), nspe );
              }
          }
          else
          {
              try
              {
                  m_messageDigest = MessageDigest.getInstance( m_algorithm );
              }
              catch( final NoSuchAlgorithmException nsae )
              {
                  throw new TaskException( nsae.toString(), nsae );
              }
          }
      }
  
      private void addIncludes()
          throws TaskException
      {
          addToIncludeFileMap( m_file );
  
          final int size = m_filesets.size();
          for( int i = 0; i < size; i++ )
          {
              final FileSet fileSet = (FileSet)m_filesets.get( i );
              final DirectoryScanner scanner = ScannerUtil.getDirectoryScanner( fileSet );
              final String[] srcFiles = scanner.getIncludedFiles();
              for( int j = 0; j < srcFiles.length; j++ )
              {
                  final File src = new File( fileSet.getDir(), srcFiles[ j ] );
                  addToIncludeFileMap( src );
              }
          }
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/build/Patch.java
  
  Index: Patch.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.build;
  
  import java.io.File;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.myrmidon.api.AbstractTask;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.framework.nativelib.Execute;
  
  /**
   * Task as a layer on top of patch. Patch applies a diff file to an original.
   *
   * @ant.task name="patchx"
   * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/14 10:55:08 $
   */
  public class Patch
      extends AbstractTask
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( Patch.class );
  
      private File m_originalFile;
      private File m_patchFile;
      private boolean m_backups;
      private boolean m_ignorewhitespace;
      private boolean m_reverse;
      private boolean m_quiet;
      private Integer m_strip;
  
      /**
       * Shall patch write backups.
       *
       * @param backups The new Backups value
       */
      public void setBackups( final boolean backups )
      {
          m_backups = backups;
      }
  
      /**
       * Ignore whitespace differences.
       */
      public void setIgnorewhitespace( final boolean ignorewhitespace )
      {
          m_ignorewhitespace = ignorewhitespace;
      }
  
      /**
       * The file to patch.
       */
      public void setOriginalfile( final File originalFile )
      {
          m_originalFile = originalFile;
      }
  
      /**
       * The file containing the diff output.
       */
      public void setPatchfile( final File patchFile )
      {
          m_patchFile = patchFile;
      }
  
      /**
       * Work silently unless an error occurs.
       */
      public void setQuiet( final boolean quiet )
      {
          m_quiet = quiet;
      }
  
      /**
       * Assume patch was created with old and new files swapped.
       */
      public void setReverse( final boolean reverse )
      {
          m_reverse = reverse;
      }
  
      /**
       * Strip the smallest prefix containing <i>num</i> leading slashes from
       * filenames. <p>
       *
       * patch's <i>-p</i> option.
       *
       * @param strip The new Strip value
       */
      public void setStrip( final Integer strip )
      {
          m_strip = strip;
      }
  
      public void execute()
          throws TaskException
      {
          validate();
  
          final Execute exe = buildCommand();
          exe.execute( getContext() );
      }
  
      private void validate()
          throws TaskException
      {
          if( null == m_patchFile )
          {
              final String message = REZ.getString( "patch.missing-file.error" );
              throw new TaskException( message );
          }
  
          if( !m_patchFile.exists() )
          {
              final String message = REZ.getString( "patch.file-noexist.error", m_patchFile );
              throw new TaskException( message );
          }
  
          if( null != m_strip && m_strip.intValue() < 0 )
          {
              final String message = REZ.getString( "patch.neg-strip.error" );
              throw new TaskException( message );
          }
      }
  
      private Execute buildCommand(  )
      {
          final Execute cmd = new Execute();
          cmd.setExecutable( "patch" );
          if( m_backups )
          {
              cmd.addArgument( "-b" );
          }
  
          if( null != m_strip )
          {
              cmd.addArgument( "-p" + m_strip.intValue() );
          }
  
          if( m_quiet )
          {
              cmd.addArgument( "-s" );
          }
  
          if( m_reverse )
          {
              cmd.addArgument( "-R" );
          }
  
          cmd.addArgument( "-i" );
          cmd.addArgument( m_patchFile );
  
          if( m_ignorewhitespace )
          {
              cmd.addArgument( "-l" );
          }
  
          if( null != m_originalFile )
          {
              cmd.addArgument( m_originalFile );
          }
          return cmd;
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/build/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  sleep.duration.notice=Sleeping for {0} milliseconds.
  sleep.neg-time.error=Negative sleep periods are not supported.
  
  patch.missing-file.error=Patchfile argument is required.
  patch.file-noexist.error=Patchfile "{0}" doesn\'t exist.
  patch.neg-strip.error=Strip has to be >= 0
  
  buildnumber.nocreate.error={0} doesn't exist and new file can't be created.
  buildnumber.noread.error=Unable to read from {0}.
  buildnumber.nowrite.error=Unable to write to {0}.
  buildnumber.noparse.error={0} contains a non integer build number: {1}
  buildnumber.badwrite.error=Error while writing {0}.
  buildnumber.header.info=Build Number for ANT. Do not edit!
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/build/SleepTask.java
  
  Index: SleepTask.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.build;
  
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.myrmidon.api.AbstractTask;
  import org.apache.myrmidon.api.TaskException;
  
  /**
   * A task to sleep for a period of time
   *
   * @ant.task name="sleep"
   * @author steve_l@iseran.com steve loughran
   * @version $Revision: 1.1 $ $Date: 2002/04/14 10:55:08 $
   */
  public class SleepTask
      extends AbstractTask
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( SleepTask.class );
  
      private int m_seconds;
      private int m_hours;
      private int m_minutes;
      private int m_milliseconds;
  
      /**
       * Sets the Hours attribute of the Sleep object
       */
      public void setHours( final int hours )
      {
          m_hours = hours;
      }
  
      /**
       * Sets the Milliseconds attribute of the Sleep object
       */
      public void setMilliseconds( final int milliseconds )
      {
          m_milliseconds = milliseconds;
      }
  
      /**
       * Sets the Minutes attribute of the Sleep object
       */
      public void setMinutes( final int minutes )
      {
          m_minutes = minutes;
      }
  
      /**
       * Sets the Seconds attribute of the Sleep object
       */
      public void setSeconds( final int seconds )
      {
          m_seconds = seconds;
      }
  
      /**
       * sleep for a period of time
       *
       * @param millis time to sleep
       */
      private void doSleep( final long millis )
      {
          try
          {
              Thread.sleep( millis );
          }
          catch( InterruptedException ie )
          {
          }
      }
  
      /**
       * Executes this build task. throws org.apache.tools.ant.TaskException if
       * there is an error during task execution.
       *
       * @exception TaskException Description of Exception
       */
      public void execute()
          throws TaskException
      {
          validate();
          final long sleepTime = getSleepTime();
  
          final String message = REZ.getString( "sleep.duration.notice", new Long( sleepTime ) );
          getContext().debug( message );
  
          doSleep( sleepTime );
      }
  
      /**
       * verify parameters
       *
       * @throws TaskException if something is invalid
       */
      private void validate()
          throws TaskException
      {
          if( getSleepTime() < 0 )
          {
              final String message = REZ.getString( "sleep.neg-time.error" );
              throw new TaskException( message );
          }
      }
  
      /**
       * return time to sleep
       *
       * @return sleep time. if below 0 then there is an error
       */
      private long getSleepTime()
      {
          return ( ( ( (long)m_hours * 60 ) + m_minutes ) * 60 + m_seconds ) * 1000 + m_milliseconds;
      }
  }
  
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/build/UpToDateCondition.java
  
  Index: UpToDateCondition.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.build;
  
  import java.io.File;
  import java.util.ArrayList;
  import java.util.Iterator;
  import org.apache.myrmidon.api.TaskContext;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.framework.FileNameMapper;
  import org.apache.myrmidon.framework.FileSet;
  import org.apache.myrmidon.framework.conditions.Condition;
  import org.apache.tools.todo.types.DirectoryScanner;
  import org.apache.tools.todo.types.ScannerUtil;
  import org.apache.tools.todo.types.SourceFileScanner;
  import org.apache.tools.todo.util.mappers.MergingMapper;
  
  /**
   * A condition which evaluates to true when the specified target has a
   * timestamp greater than all of the source files.
   *
   * @author William Ferguson <a href="mailto:williamf@mincom.com">
   *      williamf@mincom.com</a>
   * @author Hiroaki Nakamura <a href="mailto:hnakamur@mc.neweb.ne.jp">
   *      hnakamur@mc.neweb.ne.jp</a>
   * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
   *
   * @ant.type type="condition" name="uptodate"
   */
  public class UpToDateCondition
      implements Condition
  {
      private final ArrayList m_fileSets = new ArrayList();
      private FileNameMapper m_mapper;
      private File m_targetFile;
  
      /**
       * The file which must be more up to date than each of the source files if
       * the property is to be set.
       *
       * @param file the file which we are checking against.
       */
      public void setTargetFile( final File file )
      {
          m_targetFile = file;
      }
  
      /**
       * Nested &lt;srcfiles&gt; element.
       *
       * @param fs The feature to be added to the Srcfiles attribute
       */
      public void addSrcfiles( final FileSet fs )
      {
          m_fileSets.add( fs );
      }
  
      /**
       * Defines the FileNameMapper to use (nested mapper element).
       */
      public void add( final FileNameMapper mapper )
          throws TaskException
      {
          if( m_mapper != null )
          {
              throw new TaskException( "Cannot define more than one mapper" );
          }
          m_mapper = mapper;
      }
  
      /**
       * Evaluates this condition.
       *
       * @param context
       *      The context to evaluate the condition in.
       */
      public boolean evaluate( TaskContext context )
          throws TaskException
      {
          if( m_targetFile == null && m_mapper == null )
          {
              throw new TaskException( "The targetfile attribute or a nested mapper element must be set" );
          }
  
          // if not there then it can't be up to date
          if( m_targetFile != null && !m_targetFile.exists() )
          {
              return false;
          }
  
          final Iterator enum = m_fileSets.iterator();
          while( enum.hasNext() )
          {
              final FileSet fs = (FileSet)enum.next();
              final DirectoryScanner ds = ScannerUtil.getDirectoryScanner( fs );
              if ( !scanDir( fs.getDir(), ds.getIncludedFiles(), context ) )
              {
                  return false;
              }
          }
          return true;
      }
  
      private boolean scanDir( final File srcDir,
                               final String files[],
                               final TaskContext context )
          throws TaskException
      {
          final SourceFileScanner scanner = new SourceFileScanner();
          FileNameMapper mapper = null;
          File dir = srcDir;
          if( m_mapper == null )
          {
              final MergingMapper mm = new MergingMapper();
              mm.setTo( m_targetFile.getAbsolutePath() );
              mapper = mm;
              dir = null;
          }
          else
          {
              mapper = m_mapper;
          }
          return scanner.restrict( files, srcDir, dir, mapper, context ).length == 0;
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/AbstractAntTask.java
  
  Index: AbstractAntTask.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.core;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.Map;
  import org.apache.myrmidon.api.AbstractTask;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.interfaces.embeddor.Embeddor;
  import org.apache.myrmidon.interfaces.model.Project;
  import org.apache.myrmidon.interfaces.workspace.Workspace;
  
  /**
   * Abstract base class for Tasks which execute targets.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/14 10:55:08 $
   */
  public abstract class AbstractAntTask
      extends AbstractTask
  {
      /**
       * If true, inherit all properties from parent Project
       * If false, inherit only userProperties and those defined
       * inside the ant call itself
       */
      private boolean m_inheritAll;
  
      /**
       * The target to process in build file. If not specified
       * will use default in specified build file.
       */
      private String m_target;
  
      /**
       * The parameters/properties which will be passed to the workspace
       * for the target execution.
       */
      private final ArrayList m_parameters = new ArrayList();
  
      /**
       * Specify whether should inherit properties in sub-build.
       *
       * @param inheritAll true to inherit else false
       */
      public void setInheritAll( final boolean inheritAll )
      {
          m_inheritAll = inheritAll;
      }
  
      /**
       * set the target to process. If none is defined it will
       * execute the default target of the build file
       */
      public void setTarget( final String target )
      {
          m_target = target;
      }
  
      /**
       * Add a parameter to processing of build file.
       *
       * @param param the parameter
       */
      public void addParam( final AntParam param )
      {
          m_parameters.add( param );
      }
  
      /**
       * Execute the specified build, with specified parameters.
       *
       * @throws TaskException if an error occurs.
       */
      public void execute()
          throws TaskException
      {
          try
          {
              Project project = getProject();
  
              Embeddor embeddor = getEmbeddor();
  
              final Workspace workspace =
                  embeddor.createWorkspace( buildParameters() );
  
              // TODO - inherit listeners, and services (TypeManager specifically)
              workspace.addProjectListener( embeddor.createListener("default"));
  
              if( null == m_target )
              {
                  m_target = project.getDefaultTargetName();
              }
  
              workspace.executeProject( project, m_target );
          }
          catch( final Exception e )
          {
              throw new TaskException( e.toString(), e );
          }
      }
  
      /**
       * A convenience method for obtaining the Embeddor from the
       * TaskContext.
       * @return The Embeddor contained in the TaskContext
       * @throws TaskException if the Embeddor could not be obtained.
       */
      protected Embeddor getEmbeddor() throws TaskException
      {
          final Embeddor embeddor =
              (Embeddor)getContext().getService( Embeddor.class );
          return embeddor;
      }
  
      /**
       * Get/create/build the project containing the target to be executed.
       * Subclasses will override this method to provide different means
       * of obtaining a project to execute.
       * @return The project containing the target to execute.
       * @throws Exception If a problem occurred building the project.
       */
      protected abstract Project getProject() throws Exception;
  
      /**
       * Build the parameters to pass to sub-project.
       * These include the current tasks properties
       * (if inheritall=true) and any supplied by the user.
       *
       * @return the created parameters
       */
      private Map buildParameters()
          throws TaskException
      {
          final Map parameters = new HashMap();
  
          if( m_inheritAll )
          {
              parameters.putAll( getContext().getProperties() );
          }
  
          final int size = m_parameters.size();
          for( int i = 0; i < size; i++ )
          {
              final AntParam param = (AntParam)m_parameters.get( i );
              param.validate();
              final String name = param.getName();
              final Object value = param.getValue();
              parameters.put( name, value );
          }
  
          return parameters;
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/AbstractAvailableCondition.java
  
  Index: AbstractAvailableCondition.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.core;
  
  import org.apache.myrmidon.api.TaskContext;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.framework.conditions.Condition;
  import org.apache.myrmidon.framework.file.Path;
  import org.apache.myrmidon.framework.file.FileListUtil;
  
  /**
   * An abstract condition which checks for the availability of a particular
   * resource in a classpath.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/14 10:55:08 $
   */
  public abstract class AbstractAvailableCondition
      implements Condition
  {
      private Path m_classpath = new Path();
  
      /**
       * Adds a classpath element.
       */
      public void setClasspath( final Path classpath )
      {
          m_classpath.add( classpath );
      }
  
      /**
       * Adds a classpath element.
       */
      public void addClasspath( final Path classpath )
      {
          m_classpath.add( classpath );
      }
  
      /**
       * Builds the ClassLoader to use to check resources.
       */
      protected ClassLoader buildClassLoader( final TaskContext context ) throws TaskException
      {
          return FileListUtil.createClassLoader( m_classpath, context );
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/AntCallTask.java
  
  Index: AntCallTask.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.core;
  
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.interfaces.model.Project;
  
  /**
   * A task which executes a target in the current project,
   * or a referenced project.
   *
   * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/14 10:55:08 $
   * @ant.task name="ant-call"
   */
  public class AntCallTask
      extends AbstractAntTask
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( AntCallTask.class );
  
      private String m_project;
  
      /**
       * Specifies the project to execute. If not specified, the current
       * project is used.
       * @param project the name of the Project to execute.
       */
      public void setProject( String project )
      {
          m_project = project;
      }
  
      /**
       * Get/create/build the project which will be executed.
       * Subclasses will override this method to provide different means
       * of obtaining a project to execute.
       * @return The project containing the target to execute.
       * @throws Exception If a problem occurred building the project.
       */
      protected Project getProject() throws Exception
      {
          Project currentProject =
              (Project)getContext().getService( Project.class );
  
          // By default, use the current project.
          Project referencedProject = currentProject;
  
          if( m_project != null )
          {
              referencedProject = currentProject.getProject( m_project );
              if( referencedProject == null )
              {
                  final String message =
                      REZ.getString( "antcall.invalid-project.error" );
                  throw new TaskException( message );
              }
          }
  
          return referencedProject;
      }
  }
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/AntParam.java
  
  Index: AntParam.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.core;
  
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.myrmidon.api.TaskException;
  
  /**
   * Simple holder for parameters.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/14 10:55:08 $
   * @todo Refactor this and all the other parameter, sysproperty,
   *   property etc into a single class in framework
   */
  public class AntParam
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( AntParam.class );
  
      private String m_name;
      private Object m_value;
  
      /**
       * Set the name of the parameter.
       *
       * @param name the name of parameter
       */
      public void setName( final String name )
      {
          m_name = name;
      }
  
      /**
       * Set the value of the parameter.
       *
       * @param value the parameter value
       */
      public void setValue( final Object value )
      {
          m_value = value;
      }
  
      /**
       * Retrieve name of parameter.
       *
       * @return the name of parameter.
       */
      public String getName()
      {
          return m_name;
      }
  
      /**
       * Retrieve the value of parameter.
       *
       * @return the value of parameter.
       */
      public Object getValue()
      {
          return m_value;
      }
  
      /**
       * Make sure that neither the name or the value
       * is null.
       */
      public void validate()
          throws TaskException
      {
          if( null == m_name )
          {
              final String message = REZ.getString( "param.noname.error" );
              throw new TaskException( message );
          }
          else if( null == m_value )
          {
              final String message =
                  REZ.getString( "param.novalue.error", m_name );
              throw new TaskException( message );
          }
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/AntTask.java
  
  Index: AntTask.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.core;
  
  import java.io.File;
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.myrmidon.interfaces.model.Project;
  
  /**
   * Executes a target in a named build file.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @ant.task name="ant"
   */
  public class AntTask
  
      extends AbstractAntTask
  {
      /**
       * Default build file.
       */
      private static final String DEFAULT_BUILD_FILE = "build.ant";
  
      /**
       * The build file which to execute. If not set defaults to
       * using "build.ant" in the basedir of current project.
       */
      private File m_file;
  
      /**
       * The "type" of the build file. By default this is null which
       * means the type will be determined by the build file extension.
       */
      private String m_type;
  
      /**
       * set the build file to process.
       *
       * @param file the build file
       */
      public void setFile( final File file )
      {
          m_file = file;
      }
  
      /**
       * set the type of build file.
       *
       * @param type the type of build file
       */
      public void setType( final String type )
      {
          m_type = type;
      }
  
      /**
       * @return The project containing the target to execute.
       * @throws Exception If a problem occurred building the project.
       */
      protected Project getProject() throws Exception
      {
          if( null == m_file )
          {
              m_file = getContext().resolveFile( DEFAULT_BUILD_FILE );
          }
  
          final Project project =
              getEmbeddor().createProject( m_file.toString(),
                                           m_type,
                                           new Parameters() );
          return project;
      }
  
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/ClassAvailableCondition.java
  
  Index: ClassAvailableCondition.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.core;
  
  import org.apache.myrmidon.api.TaskContext;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.framework.conditions.Condition;
  
  /**
   * A condition that evaluates to true if the requested class is available
   * at runtime.
   *
   * @author Stefano Mazzocchi <a href="mailto:stefano@apache.org">
   *      stefano@apache.org</a>
   * @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a>
   *
   * @ant.type type="condition" name="class-available"
   */
  public class ClassAvailableCondition
      extends AbstractAvailableCondition
      implements Condition
  {
      private String m_classname;
  
      /**
       * Sets the name of the class to search for.
       */
      public void setClassname( final String classname )
      {
          m_classname = classname;
      }
  
      /**
       * Evaluates the condition.
       */
      public boolean evaluate( final TaskContext context )
          throws TaskException
      {
          if( m_classname == null )
          {
              throw new TaskException( "Classname not specified." );
          }
  
          // Build the classloader to use to check resources
          final ClassLoader classLoader = buildClassLoader( context );
  
          // Do the check
          try
          {
              classLoader.loadClass( m_classname );
              return true;
          }
          catch( final Exception e )
          {
              return false;
          }
      }
  
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/ConditionTask.java
  
  Index: ConditionTask.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.core;
  
  import org.apache.myrmidon.api.AbstractTask;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.framework.conditions.AndCondition;
  import org.apache.myrmidon.framework.conditions.Condition;
  
  /**
   * &lt;condition&gt; task as a generalization of &lt;available&gt; and
   * &lt;uptodate&gt; <p>
   *
   * This task supports boolean logic as well as pluggable conditions to decide,
   * whether a property should be set.</p> <p>
   *
   * This task does not extend Task to take advantage of ConditionBase.</p>
   *
   * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
   * @version $Revision: 1.1 $
   *
   * @ant.task name="condition"
   */
  public class ConditionTask
      extends AbstractTask
  {
      private AndCondition m_condition = new AndCondition();
      private String m_property;
      private String m_value = "true";
  
      /**
       * Adds a condition.
       */
      public void add( final Condition condition )
      {
          m_condition.add( condition );
      }
  
      /**
       * The name of the property to set. Required.
       *
       * @param p The new Property value
       */
      public void setProperty( final String p )
      {
          m_property = p;
      }
  
      /**
       * The value for the property to set. Defaults to "true".
       *
       * @param v The new Value value
       */
      public void setValue( final String v )
      {
          m_value = v;
      }
  
      /**
       * See whether our nested condition holds and set the property.
       */
      public void execute()
          throws TaskException
      {
          if( m_property == null )
          {
              throw new TaskException( "No property was specified" );
          }
  
          if( m_condition.evaluate( getContext() ) )
          {
              getContext().setProperty( m_property, m_value );
          }
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/Equals.java
  
  Index: Equals.java
  ===================================================================
  package org.apache.antlib.core;
  
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.api.TaskContext;
  import org.apache.myrmidon.framework.conditions.Condition;
  
  /**
   * Simple String comparison condition.
   *
   * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
   * @version $Revision: 1.1 $
   *
   * @ant.type type="condition" name="equals"
   */
  public class Equals implements Condition
  {
  
      private String arg1, arg2;
  
      public void setArg1( String a1 )
      {
          arg1 = a1;
      }
  
      public void setArg2( String a2 )
      {
          arg2 = a2;
      }
  
      /**
       * Evaluates this condition.
       *
       * @param context
       *      The context to evaluate the condition in.
       */
      public boolean evaluate( final TaskContext context )
          throws TaskException
      {
          if( arg1 == null || arg2 == null )
          {
              throw new TaskException( "both arg1 and arg2 are required in equals" );
          }
          return arg1.equals( arg2 );
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/ExtFileNameMapper.java
  
  Index: ExtFileNameMapper.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.core;
  
  import org.apache.avalon.excalibur.io.FileUtil;
  import org.apache.myrmidon.api.TaskContext;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.framework.FileNameMapper;
  
  /**
   * Maps file extensions.
   *
   * @ant.type type="mapper" name="map-extension"
   */
  public class ExtFileNameMapper
      implements FileNameMapper
  {
      private String m_extension;
  
      public void setExtension( final String extension )
      {
          m_extension = extension;
      }
  
      public String[] mapFileName( final String filename, TaskContext context )
          throws TaskException
      {
          final String name = FileUtil.removeExtension( filename );
          if( m_extension != null )
          {
              return new String[]{ name + '.' + m_extension };
          }
          else
          {
              return new String[]{ name };
          }
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/Fail.java
  
  Index: Fail.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.core;
  
  import org.apache.myrmidon.api.AbstractTask;
  import org.apache.myrmidon.api.TaskException;
  
  /**
   * This is a task used to throw a TaskException.
   * Useful for forcing a build to fail on a certain condition.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @ant.task name="fail"
   */
  public class Fail
      extends AbstractTask
  {
      private String m_message;
  
      public void setMessage( final String message )
      {
          checkNullMessage();
          m_message = message;
      }
  
      public void addContent( final String message )
      {
          checkNullMessage();
          m_message = message;
      }
  
      public void execute()
          throws TaskException
      {
          if( null != m_message )
          {
              throw new TaskException( m_message );
          }
          else
          {
              throw new TaskException();
          }
      }
  
      private void checkNullMessage()
      {
          if( null != m_message )
          {
              final String message = "Message can only be set once by " +
                  "either nested content or the message attribute";
              throw new IllegalStateException( message );
          }
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/FileTokenSet.java
  
  Index: FileTokenSet.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.core;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.util.HashMap;
  import java.util.Map;
  import java.util.Properties;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.avalon.excalibur.io.IOUtil;
  import org.apache.myrmidon.api.TaskContext;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.framework.filters.TokenSet;
  
  /**
   * A set of tokens that are read from a file.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/14 10:55:08 $
   *
   * @ant.type type="token-set" name="tokens-file"
   */
  public class FileTokenSet
      implements TokenSet
  {
      private static final Resources REZ
          = ResourceManager.getPackageResources( FileTokenSet.class );
  
      private Map m_tokens = new HashMap();
  
      /**
       * set the file containing the tokens for this tokenset.
       */
      public void setFile( final File file )
          throws TaskException
      {
          // TODO - defer loading the tokens
          if( !file.isFile() )
          {
              final String message = REZ.getString( "filetokenset.not-a-file.error", file );
              throw new TaskException( message );
          }
  
          try
          {
              FileInputStream instr = new FileInputStream( file );
  
              try
              {
                  Properties props = new Properties();
                  props.load( instr );
                  m_tokens.putAll( props );
              }
              finally
              {
                  IOUtil.shutdownStream( instr );
              }
          }
          catch( final Exception e )
          {
              final String message = REZ.getString( "filetokenset.read-tokens.error", file );
              throw new TaskException( message, e );
          }
      }
  
      /**
       * Evaluates the value for a token.
       */
      public String getValue( String token, TaskContext context )
          throws TaskException
      {
          return (String)m_tokens.get( token );
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/FlatFileNameMapper.java
  
  Index: FlatFileNameMapper.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.core;
  
  import org.apache.avalon.excalibur.io.FileUtil;
  import org.apache.myrmidon.api.TaskContext;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.framework.FileNameMapper;
  
  /**
   * Implementation of FileNameMapper that always returns the source file name
   * without any leading directory information. <p>
   *
   * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
   *
   * @ant.type type="mapper" name="flatten"
   */
  public class FlatFileNameMapper
      extends PrefixFileNameMapper
      implements FileNameMapper
  {
  
      /**
       * Returns an one-element array containing the source file name without any
       * leading directory information.
       *
       * @param sourceFileName Description of Parameter
       * @return Description of the Returned Value
       */
      public String[] mapFileName( final String sourceFileName, TaskContext context )
          throws TaskException
      {
          final String baseName = FileUtil.removePath( sourceFileName, '/' );
          return super.mapFileName( baseName, context );
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/IfTask.java
  
  Index: IfTask.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.core;
  
  import java.util.ArrayList;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.framework.AbstractContainerTask;
  import org.apache.myrmidon.framework.conditions.AndCondition;
  import org.apache.myrmidon.framework.conditions.Condition;
  import org.apache.myrmidon.framework.conditions.IsTrueCondition;
  import org.apache.myrmidon.framework.conditions.NotCondition;
  
  /**
   * A simple task to test a supplied condition. If the condition is true
   * then it will execute the inner tasks, else it won't.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/14 10:55:08 $
   * @ant.task name="if"
   */
  public class IfTask
      extends AbstractContainerTask
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( IfTask.class );
  
      private Condition m_condition;
      private ArrayList m_tasks = new ArrayList();
  
      /**
       * Set if clause on pattern.
       *
       * @param condition the condition
       * @exception TaskException if an error occurs
       */
      public void setTest( final String condition )
          throws TaskException
      {
          verifyConditionNull();
          m_condition = new IsTrueCondition( condition );
      }
  
      /**
       * Set unless clause of pattern.
       *
       * @param condition the unless clause
       * @exception TaskException if an error occurs
       */
      public void setNotTest( final String condition )
          throws TaskException
      {
          verifyConditionNull();
          m_condition = new NotCondition( new IsTrueCondition( condition ) );
      }
  
      /**
       * Add a nested "condition" element, which provides an AndCondition
       * container for any type of condition.
       * @param andCondition The configured Condition
       * @throws TaskException If a condition has already been set.
       */
      public void addCondition( final AndCondition andCondition )
          throws TaskException
      {
          verifyConditionNull();
          m_condition = andCondition;
      }
  
      public void add( final Configuration task )
      {
          m_tasks.add( task );
      }
  
      public void execute()
          throws TaskException
      {
          if( null == m_condition )
          {
              final String message = REZ.getString( "if.no-condition.error" );
              throw new TaskException( message );
          }
  
          // Evaluate the condition
          if( !m_condition.evaluate( getContext() ) )
          {
              return;
          }
  
          final Configuration[] tasks =
              (Configuration[])m_tasks.toArray( new Configuration[ m_tasks.size() ] );
  
          executeTasks( tasks );
      }
  
      public String toString()
      {
          return "If['" + m_condition + "]";
      }
  
      /**
       * Utility method to make sure condition unset.
       * Made so that it is not possible for both if and unless to be set.
       *
       * @exception TaskException if an error occurs
       */
      private void verifyConditionNull()
          throws TaskException
      {
          if( null != m_condition )
          {
              final String message = REZ.getString( "if.ifelse-duplicate.error" );
              throw new TaskException( message );
          }
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/LoadProperties.java
  
  Index: LoadProperties.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.core;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.IOException;
  import java.util.Properties;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.avalon.excalibur.io.IOUtil;
  import org.apache.myrmidon.api.AbstractTask;
  import org.apache.myrmidon.api.TaskException;
  
  /**
   * This task loads properties from a property file and places them in the context.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @ant.task name="load-properties"
   */
  public class LoadProperties
      extends AbstractTask
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( LoadProperties.class );
  
      private String m_prefix;
      private File m_file;
  
      /**
       * Specify the prefix to be placed before all properties (if any).
       */
      public void setPrefix( final String prefix )
      {
          m_prefix = prefix;
      }
  
      public void setFile( final File file )
      {
          m_file = file;
      }
  
      public void execute()
          throws TaskException
      {
          if( null == m_file )
          {
              final String message = REZ.getString( "loadprop.no-file.error" );
              throw new TaskException( message );
          }
  
          //Make sure prefix ends with a '.' if specified
          if( null == m_prefix )
          {
              m_prefix = "";
          }
          else if( !m_prefix.endsWith( "." ) )
          {
              m_prefix += ".";
          }
  
          loadFile( m_file );
      }
  
      /**
       * Utility method to load properties file.
       */
      private void loadFile( final File file )
          throws TaskException
      {
          if( getContext().isDebugEnabled() )
          {
              final String message =
                  REZ.getString( "loadprop.file.notice", file.getAbsolutePath() );
              getContext().debug( message );
          }
  
          if( !file.exists() )
          {
              final String message =
                  REZ.getString( "loadprop.missing-file.notice", file.getAbsolutePath() );
              getContext().debug( message );
          }
          else
          {
              FileInputStream input = null;
  
              try
              {
                  input = new FileInputStream( file );
                  final Properties properties = new PropertyLoader( this );
                  properties.load( input );
              }
              catch( final IOException ioe )
              {
                  throw new TaskException( ioe.getMessage(), ioe );
              }
  
              IOUtil.shutdownStream( input );
          }
      }
  
      /**
       * Utility method that will resolve and add specified proeprty.
       * Used by external PropertyLoader class as a call back method.
       */
      protected final void addUnresolvedValue( final String name, final String value )
      {
          try
          {
              final Object objectValue = getContext().resolveValue( value.toString() );
              final String name1 = m_prefix + name;
              getContext().setProperty( name1, objectValue );
          }
          catch( final TaskException te )
          {
              final String message = REZ.getString( "loadprop.bad-resolve.error", name, value );
              getContext().info( message, te );
          }
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/Log.java
  
  Index: Log.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.core;
  
  import org.apache.myrmidon.api.AbstractTask;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.framework.LogLevel;
  
  /**
   * This is a task used to log messages in the build file.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @ant.task name="log"
   */
  public class Log
      extends AbstractTask
  {
      /**
       * The message to printout when logging
       */
      private String m_message;
  
      /**
       * The level at which to print out messages.
       */
      private LogLevel m_level = LogLevel.INFO;
  
      /**
       * Set the level at which the message will be logged.
       *
       * @param level the level at which message will be logged
       */
      public void setLevel( final LogLevel level )
      {
          m_level = level;
      }
  
      /**
       * Set the message to print out when logging message
       */
      public void setMessage( final String message )
      {
          checkNullMessage();
          m_message = message;
      }
  
      /**
       * Set the message to print out when logging message
       */
      public void addContent( final String message )
      {
          checkNullMessage();
          m_message = message;
      }
  
      /**
       * Log message at specified level.
       */
      public void execute()
          throws TaskException
      {
          LogLevel.log( getContext(), m_level, m_message );
      }
  
      /**
       * Utility message to verify that the message has not already been set.
       */
      private void checkNullMessage()
      {
          if( null != m_message )
          {
              final String message = "Message can only be set once by " +
                  "either nested content or the message attribute";
              throw new IllegalStateException( message );
          }
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/PrefixFileNameMapper.java
  
  Index: PrefixFileNameMapper.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.core;
  
  import org.apache.myrmidon.api.TaskContext;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.framework.FileNameMapper;
  
  /**
   * A filename mapper that applies a prefix to each file.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/14 10:55:08 $
   *
   * @ant.type type="mapper" name="prefix"
   */
  public class PrefixFileNameMapper
      implements FileNameMapper
  {
      private String m_prefix;
  
      /**
       * Sets the prefix.
       */
      public void setPrefix( final String prefix )
      {
          m_prefix = prefix;
          if( ! m_prefix.endsWith( "/" ) )
          {
              m_prefix = m_prefix + '/';
          }
      }
  
      /**
       * Returns an array containing the target filename(s) for the given source
       * file.
       */
      public String[] mapFileName( final String sourceFileName,
                                   final TaskContext context )
          throws TaskException
      {
          if( m_prefix == null )
          {
              return new String[]{ sourceFileName };
          }
          else
          {
              return new String[] { m_prefix + sourceFileName };
          }
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/Property.java
  
  Index: Property.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.core;
  
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.myrmidon.api.AbstractTask;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.framework.DataType;
  
  /**
   * This is the property "task" to declare a binding of a datatype to a name.
   *
   * TODO: Determine final format of property task.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/14 10:55:08 $
   * @ant.task name="property"
   */
  public class Property
      extends AbstractTask
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( Property.class );
  
      private String m_name;
      private Object m_value;
  
      public void setName( final String name )
      {
          m_name = name;
      }
  
      /**
       * Sets the property value from a nested element.
       */
      public void add( final DataType value )
          throws TaskException
      {
          setValue( value );
      }
  
      /**
       * Sets the property value from text content.
       */
      public void addContent( final String value )
          throws TaskException
      {
          setValue( value );
      }
  
      /**
       * Sets the property value from an attribute.
       */
      public void setValue( final Object value )
          throws TaskException
      {
          if( null != m_value )
          {
              final String message = REZ.getString( "property.multi-set.error" );
              throw new TaskException( message );
          }
  
          m_value = value;
      }
  
      public void execute()
          throws TaskException
      {
          if( null == m_name )
          {
              final String message = REZ.getString( "property.no-name.error" );
              throw new TaskException( message );
          }
  
          if( null == m_value )
          {
              final String message = REZ.getString( "property.no-value.error" );
              throw new TaskException( message );
          }
  
          getContext().setProperty( m_name, m_value );
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/PropertyDump.java
  
  Index: PropertyDump.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.core;
  
  import java.util.Iterator;
  import java.util.Map;
  import org.apache.myrmidon.api.AbstractTask;
  import org.apache.myrmidon.api.TaskException;
  
  /**
   * This is a simple task used to dump out all the proeprtys in the
   * runtime. Useful for debugging behaviour in ant build directives.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @author <a href="mailto:jimcook@visualxs.com">Jim Cook</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/14 10:55:08 $
   * @ant.task name="property-dump"
   * @todo Consider moving to new antlib
   */
  public class PropertyDump
      extends AbstractTask
  {
      /**
       * The prefix which the keys must start with if they are
       * to be dumped.
       */
      private String m_prefix;
  
      /**
       * Set the prefix which the keys must start with if they are
       * to be dumped. If not specified then all keys are dumped.
       *
       * @param prefix the prefix
       */
      public void setPrefix( final String prefix )
      {
          m_prefix = prefix;
      }
  
      /**
       * Printout all the properties in ant runtime.
       */
      public void execute()
          throws TaskException
      {
          final Map properties = getContext().getProperties();
          final Iterator iterator = properties.keySet().iterator();
          while( iterator.hasNext() )
          {
              final String key = (String)iterator.next();
              final Object value = properties.get( key );
  
              //Check to see if property starts with specified prefix
              //and if it doesn't then skip property
              if( null != m_prefix && !key.startsWith( m_prefix ) )
              {
                  continue;
              }
  
              getContext().info( key + "=" + value );
          }
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/PropertyLoader.java
  
  Index: PropertyLoader.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.core;
  
  import java.util.Properties;
  
  /**
   * This class is an UGLY HACK utility class to enable us to reuse
   * the property parsing and loading code from Properties object.
   */
  class PropertyLoader
      extends Properties
  {
      private LoadProperties m_loadProperties;
  
      public PropertyLoader( LoadProperties loadProperties )
      {
          m_loadProperties = loadProperties;
      }
  
      /**
       * Overidden put to add unresolved values.
       */
      public synchronized Object put( Object key, Object value )
      {
          m_loadProperties.addUnresolvedValue( key.toString(), value.toString() );
          return null;
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/PropertyTokenSet.java
  
  Index: PropertyTokenSet.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.core;
  
  import org.apache.myrmidon.api.TaskContext;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.framework.filters.TokenSet;
  
  /**
   * A token set that uses the project's properties as tokens.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/14 10:55:08 $
   *
   * @ant.type type="token-set" name="properties"
   */
  public class PropertyTokenSet
      implements TokenSet
  {
      /**
       * Evaluates the value for a token.
       */
      public String getValue( String token, TaskContext context )
          throws TaskException
      {
          final Object propValue = context.getProperty( token );
          if( propValue == null )
          {
              return null;
          }
          return propValue.toString();
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/ResourceAvailableCondition.java
  
  Index: ResourceAvailableCondition.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.core;
  
  import java.io.InputStream;
  import org.apache.avalon.excalibur.io.IOUtil;
  import org.apache.myrmidon.api.TaskContext;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.framework.conditions.Condition;
  
  /**
   * A condition that evaluates to true if the requested resource is available
   * at runtime.
   *
   * @author Stefano Mazzocchi <a href="mailto:stefano@apache.org">
   *      stefano@apache.org</a>
   * @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a>
   *
   * @ant.type type="condition" name="resource-available"
   */
  public class ResourceAvailableCondition
      extends AbstractAvailableCondition
      implements Condition
  {
      private String m_resource;
  
      /**
       * Sets the name of the resource to look for.
       */
      public void setResource( final String resource )
      {
          m_resource = resource;
      }
  
      /**
       * Evaluates the condition.
       */
      public boolean evaluate( final TaskContext context )
          throws TaskException
      {
          if( m_resource == null )
          {
              throw new TaskException( "Resource was not specified." );
          }
  
          // Check whether the resource is available
          final ClassLoader classLoader = buildClassLoader( context );
          final InputStream instr = classLoader.getResourceAsStream( m_resource );
          if( instr != null )
          {
              IOUtil.shutdownStream( instr );
              return true;
          }
          return false;
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  property.no-set.error=Unable to set datatype.
  property.multi-set.error=Value can not be set multiple times.
  property.no-name.error=Name must be specified.
  property.no-value.error=Value must be specified.
  
  loadprop.no-file.error=No file specified to load properties from.
  loadprop.file.notice=Loading proeprties from {0}.
  loadprop.missing-file.notice=Unable to find property file: {0}.
  loadprop.bad-resolve.error=Unable to resolve and set property named "{0}" to value "{1}".
  
  convert.bad-boolean.error=Error converting object ({0}) to Boolean.
  convert.bad-byte.error=Error converting object ({0}) to Byte.
  convert.bad-class.error=Error converting object ({0}) to Class.
  convert.bad-double.error=Error converting object ({0}) to Double.
  convert.bad-file.error=Error converting object ({0}) to File.
  
  getByName.error=Failed to retrieve enum by calling getByName on "{0}". (Reason: {1}).
  enum.missing.getByName.error=Enum class "{0}" is missing a public static method named "getByName" that accepts a single string parameter.
  enum.missing.getNames.error=Enum class "{0}" is missing a public static method named "getNames" that returns a String array of all enum names.
  invalid.enum.error=Invalid value "{0}" for enum, expected one of {1}.
  
  if.ifelse-duplicate.error=Can only set one condition for If task type. Conditions may be 'test' or 'not-test' attributes, or nested 'condition' elements.
  if.no-condition.error=No condition was specified for If task.
  
  trycatch.multiple-trys.error=Multiple <try/> elements can not be placed inside <try-catch/> task.
  trycatch.missing-try-before-catch.error=There needs to be a <try/> element before <catch/> element.
  trycatch.multiple-catches.error=Multiple <catch/> elements can not be placed inside <try-catch/> task.
  trycatch.missing-try-before-finally.error=There needs to be a <try/> element before <finally/> element.
  trycatch.multiple-finallys.error=Multiple <finally/> elements can not be placed inside <try-catch/> task.
  trycatch.no-try.error=Missing <try/> element from <try-catch/> task.
  trycatch.missing-second.error=Missing <catch/> or <finally/> elements from <try-catch/> task.
  
  filetokenset.not-a-file.error=File {0} does not exist, or is not a file.
  filetokenset.read-tokens.error=Could not read tokens from {0}.
  
  param.noname.error=Missing name from parameter.
  param.novalue.error=Missing value from parameter "{0}".
  
  antcall.invalid-project.error=Project-reference "{0}" not found.
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/SingletonTokenSet.java
  
  Index: SingletonTokenSet.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.core;
  
  import org.apache.myrmidon.api.TaskContext;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.framework.filters.TokenSet;
  
  /**
   * A single token and its value.
   *
   * @author Michael McCallum
   * @created 14 March 2001
   *
   * @ant.type type="token-set" name="token"
   */
  public class SingletonTokenSet
      implements TokenSet
  {
      /**
       * Token which will be replaced in the filter operation
       */
      private String m_token;
  
      /**
       * The value which will replace the token in the filtering operation
       */
      private String m_value;
  
      /**
       * Constructor for the Filter object
       *
       * @param token The token which will be replaced when filtering
       * @param value The value which will replace the token when filtering
       */
      public SingletonTokenSet( final String token, final String value )
      {
          m_token = token;
          m_value = value;
      }
  
      /**
       * No argument conmstructor
       */
      public SingletonTokenSet()
      {
      }
  
      /**
       * Sets the Token attribute of the Filter object
       */
      public void setToken( final String token )
      {
          m_token = token;
      }
  
      /**
       * Sets the Value attribute of the Filter object
       */
      public void setValue( final String value )
      {
          m_value = value;
      }
  
      /**
       * Evaluates the value for a token.
       */
      public String getValue( final String token, final TaskContext context )
          throws TaskException
      {
          if( token.equals( m_token ) )
          {
              return m_value;
          }
          return null;
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/StringToEnumConverter.java
  
  Index: StringToEnumConverter.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.core;
  
  import java.lang.reflect.InvocationTargetException;
  import java.lang.reflect.Method;
  import java.util.Arrays;
  import org.apache.aut.converter.Converter;
  import org.apache.aut.converter.ConverterException;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  
  /**
   * String to Enum converter
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @ant.converter source="java.lang.String" destination="org.apache.avalon.framework.Enum"
   */
  public class StringToEnumConverter
      implements Converter
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( StringToEnumConverter.class );
  
      public Object convert( final Class destination,
                             final Object original,
                             final Object context )
          throws ConverterException
      {
          final Object object = getEnum( destination, original );
          if( null == object )
          {
              final String[] names = getValidNames( destination );
              final String message =
                  REZ.getString( "invalid.enum.error", original, Arrays.asList( names ) );
              throw new ConverterException( message );
          }
          else
          {
              return object;
          }
      }
  
      private Object getEnum( final Class destination, final Object original )
          throws ConverterException
      {
          try
          {
              final Class[] types = new Class[]{String.class};
              final Object[] args = new Object[]{original.toString()};
  
              final Method method = destination.getMethod( "getByName", types );
              return method.invoke( null, args );
          }
          catch( final InvocationTargetException ite )
          {
              final Throwable target = ite.getTargetException();
              if( target instanceof IllegalArgumentException )
              {
                  return null;
              }
              else
              {
                  final String message =
                      REZ.getString( "getByName.error", destination.getName(), target );
                  throw new ConverterException( message, target );
              }
          }
          catch( final Exception e )
          {
              final String message =
                  REZ.getString( "enum.missing.getByName.error", destination.getName() );
              throw new ConverterException( message, e );
          }
      }
  
      private String[] getValidNames( final Class clazz )
          throws ConverterException
      {
          try
          {
              final Class[] types = new Class[ 0 ];
              final Object[] args = new Object[ 0 ];
  
              final Method method = clazz.getMethod( "getNames", types );
              return (String[])method.invoke( null, args );
          }
          catch( final Exception e )
          {
              final String message =
                  REZ.getString( "enum.missing.getNames.error", clazz.getName() );
              throw new ConverterException( message, e );
          }
      }
  }
  
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/StringToFileConverter.java
  
  Index: StringToFileConverter.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.core;
  
  import java.io.File;
  import org.apache.aut.converter.AbstractConverter;
  import org.apache.aut.converter.ConverterException;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.myrmidon.api.TaskContext;
  import org.apache.myrmidon.api.TaskException;
  
  /**
   * String to file converter
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @ant.converter source="java.lang.String" destination="java.io.File"
   */
  public class StringToFileConverter
      extends AbstractConverter
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( StringToFileConverter.class );
  
      public StringToFileConverter()
      {
          super( String.class, File.class );
      }
  
      public Object convert( final Object object, final Object context )
          throws ConverterException
      {
          try
          {
              final TaskContext taskContext = (TaskContext)context;
              return taskContext.resolveFile( (String)object );
          }
          catch( final TaskException te )
          {
              final String message = REZ.getString( "convert.bad-file.error", object );
              throw new ConverterException( message, te );
          }
      }
  }
  
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/TryCatchTask.java
  
  Index: TryCatchTask.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.core;
  
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.framework.AbstractContainerTask;
  import org.apache.myrmidon.framework.TaskList;
  
  /**
   * A task that emulates the try-catch-finally construct in a number
   * of languages.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/14 10:55:08 $
   * @ant.task name="try-catch"
   */
  public final class TryCatchTask
      extends AbstractContainerTask
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( TryCatchTask.class );
  
      private TaskList m_try;
      private TaskList m_catch;
      private TaskList m_finally;
  
      public void addTry( final TaskList taskList )
          throws TaskException
      {
          if( null != m_try )
          {
              final String message = REZ.getString( "trycatch.multiple-trys.error" );
              throw new TaskException( message );
          }
          m_try = taskList;
      }
  
      public void addCatch( final TaskList taskList )
          throws TaskException
      {
          if( null == m_try )
          {
              final String message = REZ.getString( "trycatch.missing-try-before-catch.error" );
              throw new TaskException( message );
          }
          else if( null != m_catch )
          {
              final String message = REZ.getString( "trycatch.multiple-catches.error" );
              throw new TaskException( message );
          }
          m_catch = taskList;
      }
  
      public void addFinally( final TaskList taskList )
          throws TaskException
      {
          if( null == m_try )
          {
              final String message = REZ.getString( "trycatch.missing-try-before-finally.error" );
              throw new TaskException( message );
          }
          else if( null != m_finally )
          {
              final String message = REZ.getString( "trycatch.multiple-finallys.error" );
              throw new TaskException( message );
          }
          m_finally = taskList;
      }
  
      public void execute()
          throws TaskException
      {
          validate();
  
          try
          {
              final Configuration[] tasks = m_try.getTasks();
              executeTasks( tasks );
          }
          catch( final TaskException te )
          {
              if( null != m_catch )
              {
                  final Configuration[] tasks = m_catch.getTasks();
                  executeTasks( tasks );
              }
              else
              {
                  throw te;
              }
          }
          finally
          {
              if( null != m_finally )
              {
                  final Configuration[] tasks = m_finally.getTasks();
                  executeTasks( tasks );
              }
          }
      }
  
      private void validate()
          throws TaskException
      {
          if( null == m_try )
          {
              final String message = REZ.getString( "trycatch.no-try.error" );
              throw new TaskException( message );
          }
          else if( null == m_catch && null == m_finally )
          {
              final String message = REZ.getString( "trycatch.missing-second.error" );
              throw new TaskException( message );
          }
      }
  
      public String toString()
      {
          return "Try-Catch-Finally";
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message