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/myrmidon/src/samples sample.ant
Date Fri, 28 Jun 2002 09:02:08 GMT
donaldp     2002/06/28 02:02:08

  Modified:    antlib/src/java/org/apache/antlib/template TemplateDef.java
                        TemplateTask.java
               antlib   project.xml
               myrmidon/src/samples sample.ant
  Added:       antlib/src/java/org/apache/antlib/template
                        AttributeAdapter.java AttributeDef.java
                        ElementAdapter.java ElementDef.java
                        Resource.properties TemplateDefTask.java
                        TemplateTaskFactory.java
  Removed:     antlib/src/java/org/apache/antlib/template FeatureDef.java
  Log:
  Started to move across templating from SP into myrmidon. Still fairly primitive and uses
massive amounts of memory.
  
  The nesting of elements is also primitive.
  
  Checking it in so that adam can see it ;)
  
  Revision  Changes    Path
  1.2       +8 -8      jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/template/TemplateDef.java
  
  Index: TemplateDef.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/template/TemplateDef.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TemplateDef.java	20 Jun 2002 07:13:23 -0000	1.1
  +++ TemplateDef.java	28 Jun 2002 09:02:07 -0000	1.2
  @@ -21,20 +21,20 @@
       /**
        * The attributes that the template instance can define.
        */
  -    private final FeatureDef[] m_attributes;
  +    private final AttributeDef[] m_attributes;
   
       /**
        * The elements that the template instance can define.
        */
  -    private final FeatureDef[] m_elements;
  +    private final ElementDef[] m_elements;
   
       /**
        * The un-expanded template model.
        */
       private final ModelElement m_template;
   
  -    public TemplateDef( final FeatureDef[] attributes,
  -                        final FeatureDef[] elements,
  +    public TemplateDef( final AttributeDef[] attributes,
  +                        final ElementDef[] elements,
                           final ModelElement template )
       {
           m_attributes = attributes;
  @@ -42,17 +42,17 @@
           m_template = template;
       }
   
  -    public FeatureDef[] getAttributes()
  +    public AttributeDef[] getAttributes()
       {
           return m_attributes;
       }
   
  -    public FeatureDef[] getElements()
  +    public ElementDef[] getElements()
       {
           return m_elements;
       }
   
  -    public ModelElement getTemplate()
  +    public ModelElement getModel()
       {
           return m_template;
       }
  
  
  
  1.2       +221 -16   jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/template/TemplateTask.java
  
  Index: TemplateTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/template/TemplateTask.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TemplateTask.java	20 Jun 2002 07:54:44 -0000	1.1
  +++ TemplateTask.java	28 Jun 2002 09:02:07 -0000	1.2
  @@ -19,7 +19,7 @@
   
   /**
    * Task used to execute a template that has been defined
  - * via { @link TemplateDefTask}.
  + * via {@link TemplateDefTask}.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    */
  @@ -55,8 +55,72 @@
           throws TaskException
       {
           final Map attributes = getAttributeMap();
  -        //elements are ignored for the time being ...
  -        attributes.size();
  +        final Map elements = getElementMap();
  +
  +        final ModelElement model =
  +            processTemplate( m_template.getModel(), attributes, elements );
  +
  +        executeTasks( model.getChildren() );
  +    }
  +
  +    private ModelElement processTemplate( final ModelElement model,
  +                                          final Map attributes,
  +                                          final Map elements )
  +        throws TaskException
  +    {
  +        final ModelElement newModel =
  +            new ModelElement( model.getName(), model.getLocation() );
  +
  +        final String[] names = model.getAttributeNames();
  +
  +        if( model.getName().equals( "_template-inc_" ) )
  +        {
  +            final String name = model.getAttribute( "name" );
  +            final ModelElement element = (ModelElement)elements.get( name );
  +            if( null == element )
  +            {
  +                final String message =
  +                    REZ.getString( "template.missing-include.error", name );
  +                throw new TaskException( message );
  +            }
  +
  +            if( 1 != names.length || 0 != element.getChildCount() )
  +            {
  +                System.out.println( "names.length = " + names.length );
  +                System.out.println( "element.getChildCount() = " + element.getChildCount()
);
  +
  +                final String message =
  +                    REZ.getString( "template.malformed-include.error", name );
  +                throw new TaskException( message );
  +            }
  +
  +            return element;
  +        }
  +
  +        for( int i = 0; i < names.length; i++ )
  +        {
  +            final String key = names[ i ];
  +            final String value = processValue( model.getAttribute( key ), attributes );
  +            newModel.setAttribute( key, value );
  +        }
  +
  +        final ModelElement[] children = model.getChildren();
  +        for( int i = 0; i < children.length; i++ )
  +        {
  +            final ModelElement child =
  +                processTemplate( children[ i ], attributes, elements );
  +            newModel.addChild( child );
  +        }
  +
  +        newModel.makeReadOnly();
  +        return newModel;
  +    }
  +
  +    private String processValue( final String attribute,
  +                                 final Map attributes )
  +        throws TaskException
  +    {
  +        return resolveProperty( attribute, attributes );
       }
   
       /**
  @@ -72,26 +136,20 @@
           throws TaskException
       {
           final Map attributes = new HashMap();
  -        final FeatureDef[] attributeDefs = m_template.getAttributes();
  +        final AttributeDef[] attributeDefs = m_template.getAttributes();
           for( int i = 0; i < attributeDefs.length; i++ )
           {
  -            final FeatureDef attributeDef = attributeDefs[ i ];
  +            final AttributeDef attributeDef = attributeDefs[ i ];
               final String name = attributeDef.getName();
               final String defaultValue = attributeDef.getDefaultValue();
   
               final String strValue = m_model.getAttribute( name, defaultValue );
               if( null == strValue )
               {
  -                if( !attributeDef.isOptional() )
  -                {
  -                    final String message =
  -                        REZ.getString( "template.missing-attribute.error", name );
  -                    throw new TaskException( message );
  -                }
  -                else
  -                {
  -                    continue;
  -                }
  +                final String message =
  +                    REZ.getString( "template.missing-attribute.error",
  +                                   name );
  +                throw new TaskException( message );
               }
   
               final Object value = createValue( attributeDef.getType(), strValue );
  @@ -105,7 +163,9 @@
               if( !attributes.containsKey( name ) )
               {
                   final String message =
  -                    REZ.getString( "template.extra-attribute.error", name );
  +                    REZ.getString( "template.extra-attribute.error",
  +                                   name,
  +                                   getContext().getName() );
                   throw new TaskException( message );
               }
           }
  @@ -113,6 +173,60 @@
       }
   
       /**
  +     * Retrieve a map containing the elements resolved to
  +     * their correct types.
  +     *
  +     * @return the element map
  +     * @throws TaskException if required element are missing,
  +     *         extra element are present or unable to convert
  +     *         to correct element type
  +     */
  +    private Map getElementMap()
  +        throws TaskException
  +    {
  +        final Map elements = new HashMap();
  +        final ElementDef[] elementDefs = m_template.getElements();
  +        for( int i = 0; i < elementDefs.length; i++ )
  +        {
  +            final ElementDef attributeDef = elementDefs[ i ];
  +            final String name = attributeDef.getName();
  +            final ModelElement defaultValue = attributeDef.getDefault();
  +
  +            ModelElement element = m_model.getChild( name );
  +            if( null == element )
  +            {
  +                if( null != defaultValue )
  +                {
  +                    element = defaultValue;
  +                }
  +                else
  +                {
  +                    final String message =
  +                        REZ.getString( "template.missing-element.error", name );
  +                    throw new TaskException( message );
  +                }
  +            }
  +
  +            elements.put( name, element );
  +        }
  +
  +        final ModelElement[] children = m_model.getChildren();
  +        for( int i = 0; i < children.length; i++ )
  +        {
  +            final String name = children[ i ].getName();
  +            if( !elements.containsKey( name ) )
  +            {
  +                final String message =
  +                    REZ.getString( "template.extra-element.error",
  +                                   name,
  +                                   getContext().getName() );
  +                throw new TaskException( message );
  +            }
  +        }
  +        return elements;
  +    }
  +
  +    /**
        * Get the type coresponding tyo specified type. Note that
        * this mechanism is a complete hack and something more
        * useful needs to be done in future to allow classes
  @@ -131,5 +245,96 @@
           {
               throw new TaskException( e.getMessage(), e );
           }
  +    }
  +
  +    public String resolveProperty( final String property,
  +                                   final Map context )
  +        throws TaskException
  +    {
  +        int start = findBeginning( property, 0 );
  +        if( -1 == start )
  +        {
  +            return property;
  +        }
  +
  +        int end = findEnding( property, start );
  +
  +        final int length = property.length();
  +
  +        if( 0 == start && end == ( length - 1 ) )
  +        {
  +            return resolveValue( property.substring( start + 2, end ),
  +                                 context );
  +        }
  +
  +        final StringBuffer sb = new StringBuffer( length * 2 );
  +        int lastPlace = 0;
  +
  +        while( true )
  +        {
  +            final Object value =
  +                resolveValue( property.substring( start + 2, end ),
  +                              context );
  +
  +            sb.append( property.substring( lastPlace, start ) );
  +            sb.append( value );
  +
  +            lastPlace = end + 1;
  +
  +            start = findBeginning( property, lastPlace );
  +            if( -1 == start )
  +            {
  +                break;
  +            }
  +
  +            end = findEnding( property, start );
  +        }
  +
  +        sb.append( property.substring( lastPlace, length ) );
  +
  +        return sb.toString();
  +    }
  +
  +    private int findBeginning( final String property, final int currentPosition )
  +    {
  +        return property.indexOf( "@{", currentPosition );
  +    }
  +
  +    private int findEnding( final String property, final int currentPosition )
  +        throws TaskException
  +    {
  +        final int index = property.indexOf( '}', currentPosition );
  +        if( -1 == index )
  +        {
  +            final String message = "Malformed property with mismatched }'s";
  +            throw new TaskException( message );
  +        }
  +
  +        return index;
  +    }
  +
  +    /**
  +     * Retrieve a value from the specified context using the specified key.
  +     * If there is no such value then a TaskException is generated.
  +     *
  +     * @param key the key of value in context
  +     * @param context the Context
  +     * @return the object retrieved from context
  +     * @exception TaskException if an error occurs
  +     */
  +    private String resolveValue( final String key,
  +                                 final Map context )
  +        throws TaskException
  +    {
  +        Object value = context.get( key );
  +        if( null == value )
  +        {
  +            final String message =
  +                "Unable to find " + key + " to expand during " +
  +                "property resolution.";
  +            throw new TaskException( message );
  +        }
  +
  +        return value.toString();
       }
   }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/template/AttributeAdapter.java
  
  Index: AttributeAdapter.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.template;
  
  import org.apache.myrmidon.api.TaskException;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  
  /**
   * Simple ant-style task to hold template data.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/06/28 09:02:07 $
   */
  public class AttributeAdapter
  {
      private final static Resources REZ =
          ResourceManager.getPackageResources( AttributeAdapter.class );
  
      private String m_name;
      private String m_type;
      private String m_default;
  
      public void setName( final String name )
      {
          m_name = name;
      }
  
      public void setType( final String type )
      {
          m_type = type;
      }
  
      public void setDefault( final String defaultValue )
      {
          m_default = defaultValue;
      }
  
      AttributeDef toFeatureDef()
          throws TaskException
      {
          if( null == m_name )
          {
              final String message =
                  REZ.getString( "attribute.missing-name.error" );
              throw new TaskException( message );
          }
          if( null == m_name )
          {
              final String message =
                  REZ.getString( "attribute.missing-name.error", m_name );
              throw new TaskException( message );
          }
  
          return new AttributeDef( m_name, m_type, m_default );
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/template/AttributeDef.java
  
  Index: AttributeDef.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.template;
  
  /**
   * This defines a feature (either an attribute or an element)
   * that can be accepted by the template task.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/06/28 09:02:07 $
   */
  public class AttributeDef
  {
      private final String m_name;
      private final String m_type;
      private final String m_defaultValue;
  
      public AttributeDef( final String name,
                         final String type,
                         final String defaultValue )
      {
          m_name = name;
          m_type = type;
          m_defaultValue = defaultValue;
      }
  
      public String getName()
      {
          return m_name;
      }
  
      public String getType()
      {
          return m_type;
      }
  
      public String getDefaultValue()
      {
          return m_defaultValue;
      }
  
      public boolean isOptional()
      {
          return ( null == getDefaultValue() );
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/template/ElementAdapter.java
  
  Index: ElementAdapter.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.template;
  
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.api.metadata.ModelElement;
  
  /**
   * An adpator representing element for template.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/06/28 09:02:07 $
   */
  public class ElementAdapter
  {
      private final static Resources REZ =
          ResourceManager.getPackageResources( ElementAdapter.class );
  
      private String m_name;
      private ModelElement m_default;
  
      public void setName( final String name )
      {
          m_name = name;
      }
  
      public void add( final ModelElement defaultValue )
          throws TaskException
      {
          if( null != m_default )
          {
              final String message =
                  REZ.getString( "element.multiple-elements.error", m_name );
              throw new TaskException( message );
          }
          m_default = defaultValue;
      }
  
      ElementDef toElementDef()
          throws TaskException
      {
          if( null == m_name )
          {
              final String message =
                  REZ.getString( "element.missing-name.error" );
              throw new TaskException( message );
          }
  
          return new ElementDef( m_name, m_default );
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/template/ElementDef.java
  
  Index: ElementDef.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.template;
  
  import org.apache.myrmidon.api.metadata.ModelElement;
  
  /**
   * This defines a Element that can be accepted by the template task.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/06/28 09:02:07 $
   */
  public class ElementDef
  {
      private final String m_name;
      private final ModelElement m_default;
  
      public ElementDef( final String name,
                         final ModelElement defaultValue )
      {
          m_name = name;
          m_default = defaultValue;
      }
  
      public String getName()
      {
          return m_name;
      }
  
      public ModelElement getDefault()
      {
          return m_default;
      }
  
      public boolean isOptional()
      {
          return ( null == getDefault() );
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/template/Resource.properties
  
  Index: Resource.properties
  ===================================================================
  template.missing-attribute.error=Attribute named "{0}" is missing.
  template.extra-attribute.error=Attribute named "{0}" is unknown to template task "{1}".
  template.missing-element.error=Element named "{0}" is missing.
  template.extra-element.error=Element named "{0}" is unknown to template task "{1}".
  template.missing-include.error=The include named "{0}", appeared in template that had no
corresponding element specified.
  template.malformed-include.error=The include named "{0}" has unknown attributes or sub-elements.
  
  template-def.many-logic.error=Templates can only define a single block o logic.
  template-def.missing-logic.error=TemplateDef task named "{0}" does not define a logic element.
  template-def.missing-name.error=The TemplateDef task has not specified a name.
  
  element.missing-name.error=Element does not specify a name.
  element.missing-name.error=Element named "{0}" does not specify a type.
  
  attribute.missing-name.error=Attribute does not specify a name.
  attribute.missing-name.error=Attribute named "{0}" does not specify a type.
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/template/TemplateDefTask.java
  
  Index: TemplateDefTask.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.template;
  
  import java.util.ArrayList;
  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.Task;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.api.metadata.ModelElement;
  import org.apache.myrmidon.interfaces.type.TypeException;
  import org.apache.myrmidon.interfaces.type.TypeRegistry;
  
  /**
   * Task used to execute a template that has been defined
   * via { @link TemplateDefTask}.
   *
   * @ant.task name="template-def"
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   */
  public class TemplateDefTask
      extends AbstractTask
  {
      private final static Resources REZ =
          ResourceManager.getPackageResources( TemplateDefTask.class );
  
      /**
       * The name to use to define template.
       */
      private String m_name;
  
      /**
       * The list of attributes for template.
       */
      private final ArrayList m_attributes = new ArrayList();
  
      /**
       * The list of elements for template.
       */
      private final ArrayList m_elements = new ArrayList();
  
      /**
       * The logic element for template.
       */
      private ModelElement m_logic;
  
      public void setName( final String name )
      {
          m_name = name;
      }
  
      public void addAttribute( final AttributeAdapter attribute )
      {
          m_attributes.add( attribute );
      }
  
      public void addElement( final ElementAdapter element )
      {
          m_elements.add( element );
      }
  
  
      public void addLogic( final ModelElement logic )
          throws TaskException
      {
          if( null != m_logic )
          {
              final String message =
                  REZ.getString( "template-def.many-logic.error" );
              throw new TaskException( message );
          }
          m_logic = logic;
      }
  
      public void execute()
          throws TaskException
      {
          if( null == m_name )
          {
              final String message =
                  REZ.getString( "template-def.missing-name.error" );
              throw new TaskException( message );
          }
          if( null == m_logic )
          {
              final String message =
                  REZ.getString( "template-def.missing-logic.error", m_name );
              throw new TaskException( message );
          }
          final AttributeDef[] attributes = getAttributeDefs();
          final ElementDef[] elements = getElementDefs();
          final TemplateDef templateDef = new TemplateDef( attributes, elements, m_logic );
          final TemplateTaskFactory factory =
              new TemplateTaskFactory( m_name, templateDef );
  
          final TypeRegistry typeRegistry = (TypeRegistry)getService( TypeRegistry.class );
          try
          {
              typeRegistry.registerType( Task.ROLE, "", m_name, factory );
          }
          catch( final TypeException te )
          {
              throw new TaskException( te.getMessage(), te );
          }
      }
  
      private AttributeDef[] getAttributeDefs()
          throws TaskException
      {
          final ArrayList attributes = new ArrayList();
          final int size = m_attributes.size();
          for( int i = 0; i < size; i++ )
          {
              final AttributeAdapter attribute =
                  (AttributeAdapter)m_attributes.get( i );
              final AttributeDef featureDef = attribute.toFeatureDef();
              attributes.add( featureDef );
          }
          return (AttributeDef[])attributes.toArray( new AttributeDef[ attributes.size() ]
);
      }
  
      private ElementDef[] getElementDefs()
          throws TaskException
      {
          final ArrayList elements = new ArrayList();
          final int size = m_elements.size();
          for( int i = 0; i < size; i++ )
          {
              final ElementAdapter element =
                  (ElementAdapter)m_elements.get( i );
              final ElementDef elementDef = element.toElementDef();
              elements.add( elementDef );
          }
          return (ElementDef[])elements.toArray( new ElementDef[ elements.size() ] );
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/template/TemplateTaskFactory.java
  
  Index: TemplateTaskFactory.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.template;
  
  import org.apache.myrmidon.interfaces.type.TypeFactory;
  import org.apache.myrmidon.interfaces.type.TypeException;
  
  /**
   * 
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/06/28 09:02:07 $
   */
  public class TemplateTaskFactory
      implements TypeFactory
  {
      private final String m_name;
      private final TemplateDef m_templateDef;
  
      TemplateTaskFactory( final String name,
                                  final TemplateDef templateDef )
      {
          if( null == name )
          {
              throw new NullPointerException( "name" );
          }
          if( null == templateDef )
          {
              throw new NullPointerException( "templateDef" );
          }
          m_name = name;
          m_templateDef = templateDef;
      }
  
      public boolean canCreate( final String name )
      {
          return m_name.equals( name );
      }
  
      public Object create( final String name )
          throws TypeException
      {
          if( canCreate( name ) )
          {
              return new TemplateTask( m_templateDef );
          }
          else
          {
              return null;
          }
      }
  }
  
  
  
  1.12      +4 -0      jakarta-ant-myrmidon/antlib/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/project.xml,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- project.xml	15 Jun 2002 03:27:02 -0000	1.11
  +++ project.xml	28 Jun 2002 09:02:07 -0000	1.12
  @@ -75,6 +75,10 @@
               <patternset includes="org/apache/antlib/security/**"/>
           </jar>
           <jar>
  +            <id>template</id>
  +            <patternset includes="org/apache/antlib/template/**"/>
  +        </jar>
  +        <jar>
               <id>vfile</id>
               <patternset includes="org/apache/antlib/vfile/**"/>
           </jar>
  
  
  
  1.11      +45 -4     jakarta-ant-myrmidon/myrmidon/src/samples/sample.ant
  
  Index: sample.ant
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/myrmidon/src/samples/sample.ant,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- sample.ant	27 May 2002 23:37:19 -0000	1.10
  +++ sample.ant	28 Jun 2002 09:02:07 -0000	1.11
  @@ -29,9 +29,9 @@
       <target name="xp-deployer-test" depends="typedef-test, prim->undefined-task"
/>
   
       <target name="all"
  -            depends="property-test, typedef2-test, typedef-test,
  -                     converterdef-test, ant-call-test, datatype-test,
  -                     namespace-test, prim->main, exec-test" />
  +        depends="property-test, typedef2-test, typedef-test,
  +                 converterdef-test, ant-call-test, datatype-test,
  +                 namespace-test, prim->main, exec-test" />
   
       <target name="if-test">
           <property name="blah" value="true" />
  @@ -230,7 +230,7 @@
   
       <target name="move-test">
           <move file="../../dist/bin/sample.ant-copied.txt"
  -              dest-file="../../dist/bin/sample.ant-moved.txt"/>
  +            dest-file="../../dist/bin/sample.ant-moved.txt"/>
       </target>
   
       <target name="filtered-copy-test">
  @@ -356,6 +356,47 @@
               <depends-ref id="my-dependencies"/>
               <options-ref id="my-options"/>
           </jarlib-manifest>
  +    </target>
  +
  +    <target name="template-def-test">
  +        <template-def name="foo">
  +            <logic>
  +                <log message="Hello!"/>
  +            </logic>
  +        </template-def>
  +        <foo/>
  +
  +        <template-def name="foo2">
  +            <attribute name="name" type="java.lang.String" default="Nobody"/>
  +            <attribute name="title" type="java.lang.String" default="Mr"/>
  +            <logic>
  +                <log message="Hello @{title} @{name}!"/>
  +            </logic>
  +        </template-def>
  +        <foo2 name="Donald"/>
  +        <foo2 name="Pete" title="Grand High Fubar"/>
  +
  +        <template-def name="foo3">
  +            <element name="extension">
  +                <extension
  +                    extension-name="org.realityforge.dve"
  +                    specification-version="1.0"
  +                    specification-vendor="Peter Donald"/>
  +            </element>
  +            <logic>
  +                <log message="Template generating manifest!!"/>
  +                <jarlib-manifest destfile="../../generated-manifest.txt">
  +                    <_template-inc_ name="extension"/>
  +                </jarlib-manifest>
  +            </logic>
  +        </template-def>
  +        <foo3/>
  +        <foo3>
  +            <extension
  +                extension-name="org.realityforge.dve"
  +                specification-version="1.0"
  +                specification-vendor="Peter Donald"/>
  +        </foo3>
       </target>
   
   </project>
  
  
  

--
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