You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by eh...@apache.org on 2002/03/02 23:21:19 UTC

cvs commit: jakarta-ant/proposal/sandbox/antlib/src/main/org/apache/tools/ant antlib.xml

ehatcher    02/03/02 14:21:19

  Modified:    proposal/sandbox/antlib/src/main/org/apache/tools/ant/taskdefs
                        Ant.java Antlib.java
  Added:       proposal/sandbox/antlib/src/main/org/apache/tools/ant
                        antlib.xml
  Log:
  for Jose Alberto
  
  Revision  Changes    Path
  1.3       +23 -1     jakarta-ant/proposal/sandbox/antlib/src/main/org/apache/tools/ant/taskdefs/Ant.java
  
  Index: Ant.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/antlib/src/main/org/apache/tools/ant/taskdefs/Ant.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Ant.java	18 Feb 2002 08:55:16 -0000	1.2
  +++ Ant.java	2 Mar 2002 22:21:19 -0000	1.3
  @@ -138,8 +138,10 @@
       }
   
       public void init() {
  -        newProject = project.createSubProject();
  +        newProject = new Project(project);
           newProject.setJavaVersionProperty();
  +//          newProject.addTaskDefinition("property", 
  +//                               (Class)project.getTaskDefinitions().get("property"));
       }
   
       private void reinit() {
  @@ -182,6 +184,26 @@
                   log( "Ant: Can't set output to " + output );
               }
           }
  +
  +//          Hashtable taskdefs = project.getTaskDefinitions();
  +//          Enumeration et = taskdefs.keys();
  +//          while (et.hasMoreElements()) {
  +//              String taskName = (String) et.nextElement();
  +//              if (taskName.equals("property")) {
  +//                  // we have already added this taskdef in #init
  +//                  continue;
  +//              }
  +//              Class taskClass = (Class) taskdefs.get(taskName);
  +//              newProject.addTaskDefinition(taskName, taskClass);
  +//          }
  +
  +//          Hashtable typedefs = project.getDataTypeDefinitions();
  +//          Enumeration e = typedefs.keys();
  +//          while (e.hasMoreElements()) {
  +//              String typeName = (String) e.nextElement();
  +//              Class typeClass = (Class) typedefs.get(typeName);
  +//              newProject.addDataTypeDefinition(typeName, typeClass);
  +//          }
   
           // set user-defined or all properties from calling project
           Hashtable prop1;
  
  
  
  1.4       +30 -7     jakarta-ant/proposal/sandbox/antlib/src/main/org/apache/tools/ant/taskdefs/Antlib.java
  
  Index: Antlib.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/antlib/src/main/org/apache/tools/ant/taskdefs/Antlib.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Antlib.java	18 Feb 2002 08:55:16 -0000	1.3
  +++ Antlib.java	2 Mar 2002 22:21:19 -0000	1.4
  @@ -418,7 +418,7 @@
           if (classpath != null) {
               clspath.append(classpath);
           }
  -	return project.addToLoader(loaderId, clspath);
  +	return project.getSymbols().addToLoader(loaderId, clspath);
       }
   
   
  @@ -505,6 +505,8 @@
   
   	private int level = 0;
   
  +	private SymbolTable symbols = null;
  +
   	private String name = null;
   	private String className = null;
   	private String adapter = null;
  @@ -518,6 +520,7 @@
           AntLibraryHandler(ClassLoader classloader, Properties als) {
               this.classloader = classloader;
               this.aliasMap = als;
  +	    this.symbols = project.getSymbols();
           }
   
           /**
  @@ -588,15 +591,15 @@
   
   	    try {
   		if ("role".equals(tag)) {
  -		    if (project.isRoleDefined(name)) {
  +		    if (isRoleInUse(name)) {
   			String msg = "Cannot override role: " + name;
   			log(msg, Project.MSG_WARN);
   			return;			
   		    }
   		    // Defining a new role
  -		    project.addRoleDefinition(name, loadClass(className),
  -					      (adapter == null? 
  -					       null : loadClass(adapter))); 
  +		    symbols.addRole(name, loadClass(className),
  +				    (adapter == null? 
  +				     null : loadClass(adapter))); 
   		    return;
   		}
   
  @@ -607,12 +610,12 @@
   		    name = alias;
   		}
   		//catch an attempted override of an existing name
  -		if (!override && project.isDefinedOnRole(tag, name)) {
  +		if (!override && isInUse(tag, name)) {
   		    String msg = "Cannot override " + tag + ": " + name;
   		    log(msg, Project.MSG_WARN);
   		    return;
   		}
  -		project.addDefinitionOnRole(tag, name, loadClass(className));
  +		symbols.add(tag, name, loadClass(className));
   	    }
   	    catch(BuildException be) {
   		throw new SAXParseException(be.getMessage(), locator, be);
  @@ -647,6 +650,26 @@
   		throw new SAXParseException(msg, locator);
   	    }
   	}
  +
  +        /**
  +         * test for a name being in use already on this role
  +         *
  +         * @param name the name to test
  +         * @return true if it is a task or a datatype
  +         */
  +        private boolean isInUse(String role, String name) {
  +            return (symbols.get(role, name) != null);
  +        }
  +
  +        /**
  +         * test for a role name being in use already
  +         *
  +         * @param name the name to test
  +         * @return true if it is a task or a datatype
  +         */
  +        private boolean isRoleInUse(String name) {
  +            return (symbols.getRole(name) != null);
  +        }
   
       //end inner class AntLibraryHandler
       }
  
  
  
  1.1                  jakarta-ant/proposal/sandbox/antlib/src/main/org/apache/tools/ant/antlib.xml
  
  Index: antlib.xml
  ===================================================================
  <?xml version='1.0' ?>
  <!--
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Ant", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
  -->
  <antlib version="1.5" >
    <task name="mkdir" class="org.apache.tools.ant.taskdefs.Mkdir"/>
    <task name="javac" class="org.apache.tools.ant.taskdefs.Javac"/>
    <task name="chmod" class="org.apache.tools.ant.taskdefs.Chmod"/>
    <task name="delete" class="org.apache.tools.ant.taskdefs.Delete"/>
    <task name="copy" class="org.apache.tools.ant.taskdefs.Copy"/>
    <task name="move" class="org.apache.tools.ant.taskdefs.Move"/>
    <task name="jar" class="org.apache.tools.ant.taskdefs.Jar"/>
    <task name="rmic" class="org.apache.tools.ant.taskdefs.Rmic"/>
    <task name="cvs" class="org.apache.tools.ant.taskdefs.Cvs"/>
    <task name="unzip" class="org.apache.tools.ant.taskdefs.Expand"/>
    <task name="unjar" class="org.apache.tools.ant.taskdefs.Expand"/>
    <task name="unwar" class="org.apache.tools.ant.taskdefs.Expand"/>
    <task name="echo" class="org.apache.tools.ant.taskdefs.Echo"/>
    <task name="javadoc" class="org.apache.tools.ant.taskdefs.Javadoc"/>
    <task name="zip" class="org.apache.tools.ant.taskdefs.Zip"/>
    <task name="gzip" class="org.apache.tools.ant.taskdefs.GZip"/>
    <task name="gunzip" class="org.apache.tools.ant.taskdefs.GUnzip"/>
    <task name="replace" class="org.apache.tools.ant.taskdefs.Replace"/>
    <task name="java" class="org.apache.tools.ant.taskdefs.Java"/>
    <task name="tstamp" class="org.apache.tools.ant.taskdefs.Tstamp"/>
    <task name="property" class="org.apache.tools.ant.taskdefs.Property"/>
    <task name="taskdef" class="org.apache.tools.ant.taskdefs.Taskdef"/>
    <task name="ant" class="org.apache.tools.ant.taskdefs.Ant"/>
    <task name="exec" class="org.apache.tools.ant.taskdefs.ExecTask"/>
    <task name="tar" class="org.apache.tools.ant.taskdefs.Tar"/>
    <task name="untar" class="org.apache.tools.ant.taskdefs.Untar"/>
    <task name="available" class="org.apache.tools.ant.taskdefs.Available"/>
    <task name="filter" class="org.apache.tools.ant.taskdefs.Filter"/>
    <task name="fixcrlf" class="org.apache.tools.ant.taskdefs.FixCRLF"/>
    <task name="patch" class="org.apache.tools.ant.taskdefs.Patch"/>
    <task name="style" class="org.apache.tools.ant.taskdefs.XSLTProcess"/>
    <task name="touch" class="org.apache.tools.ant.taskdefs.Touch"/>
    <task name="signjar" class="org.apache.tools.ant.taskdefs.SignJar"/>
    <task name="genkey" class="org.apache.tools.ant.taskdefs.GenerateKey"/>
    <task name="antstructure" class="org.apache.tools.ant.taskdefs.AntStructure"/>
    <task name="execon" class="org.apache.tools.ant.taskdefs.ExecuteOn"/>
    <task name="antcall" class="org.apache.tools.ant.taskdefs.CallTarget"/>
    <task name="sql" class="org.apache.tools.ant.taskdefs.SQLExec"/>
    <task name="mail" class="org.apache.tools.ant.taskdefs.email.EmailTask"/>
    <task name="fail" class="org.apache.tools.ant.taskdefs.Exit"/>
    <task name="war" class="org.apache.tools.ant.taskdefs.War"/>
    <task name="uptodate" class="org.apache.tools.ant.taskdefs.UpToDate"/>
    <task name="apply" class="org.apache.tools.ant.taskdefs.Transform"/>
    <task name="record" class="org.apache.tools.ant.taskdefs.Recorder"/>
    <task name="cvspass" class="org.apache.tools.ant.taskdefs.CVSPass"/>
    <task name="typedef" class="org.apache.tools.ant.taskdefs.Typedef"/>
    <task name="sleep" class="org.apache.tools.ant.taskdefs.Sleep"/>
    <task name="pathconvert" class="org.apache.tools.ant.taskdefs.PathConvert"/>
    <task name="ear" class="org.apache.tools.ant.taskdefs.Ear"/>
    <task name="parallel" class="org.apache.tools.ant.taskdefs.Parallel"/>
    <task name="sequential" class="org.apache.tools.ant.taskdefs.Sequential"/>
    <task name="condition" class="org.apache.tools.ant.taskdefs.ConditionTask"/>
    <task name="dependset" class="org.apache.tools.ant.taskdefs.DependSet"/>
    <task name="bzip2" class="org.apache.tools.ant.taskdefs.BZip2"/>
    <task name="bunzip2" class="org.apache.tools.ant.taskdefs.BUnzip2"/>
    <task name="checksum" class="org.apache.tools.ant.taskdefs.Checksum"/>
    <task name="waitfor" class="org.apache.tools.ant.taskdefs.WaitFor"/>
    <task name="input" class="org.apache.tools.ant.taskdefs.Input"/>
    <task name="loadfile" class="org.apache.tools.ant.taskdefs.LoadFile"/>
    <task name="manifest" class="org.apache.tools.ant.taskdefs.Manifest"/>
    <task name="antjar" class="org.apache.tools.ant.taskdefs.Antjar"/>
    <task name="antlib" class="org.apache.tools.ant.taskdefs.Antlib"/>
  
    <data-type name="path" class="org.apache.tools.ant.types.Path"/>
    <data-type name="fileset" class="org.apache.tools.ant.types.FileSet"/>
    <data-type name="filelist" class="org.apache.tools.ant.types.FileList"/>
    <data-type name="patternset" class="org.apache.tools.ant.types.PatternSet"/>
    <data-type name="mapper" class="org.apache.tools.ant.types.Mapper"/>
    <data-type name="filterset" class="org.apache.tools.ant.types.FilterSet"/>
    <data-type name="description" class="org.apache.tools.ant.types.Description"/>
    <data-type name="substitution" class="org.apache.tools.ant.types.Substitution"/>
    <data-type name="regexp" class="org.apache.tools.ant.types.RegularExpression"/>
  
    <!-- deprecated ant tasks (kept for back compatibility) -->
  
    <task name="javadoc2" class="org.apache.tools.ant.taskdefs.Javadoc"/>
    <task name="copydir" class="org.apache.tools.ant.taskdefs.Copydir"/>
    <task name="copyfile" class="org.apache.tools.ant.taskdefs.Copyfile"/>
    <task name="deltree" class="org.apache.tools.ant.taskdefs.Deltree"/>
    <task name="rename" class="org.apache.tools.ant.taskdefs.Rename"/>
  
  </antlib>
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>