Clover coverage report - Ant Coverage
Coverage timestamp: Tue Apr 8 2003 20:43:55 EST
file stats: LOC: 655   Methods: 23
NCLOC: 360   Classes: 2
 
 Source file Conditionals Statements Methods TOTAL
Ant.java 63.5% 75.6% 78.3% 72.1%
 1   
 /*
 2   
  * The Apache Software License, Version 1.1
 3   
  *
 4   
  * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
 5   
  * reserved.
 6   
  *
 7   
  * Redistribution and use in source and binary forms, with or without
 8   
  * modification, are permitted provided that the following conditions
 9   
  * are met:
 10   
  *
 11   
  * 1. Redistributions of source code must retain the above copyright
 12   
  *    notice, this list of conditions and the following disclaimer.
 13   
  *
 14   
  * 2. Redistributions in binary form must reproduce the above copyright
 15   
  *    notice, this list of conditions and the following disclaimer in
 16   
  *    the documentation and/or other materials provided with the
 17   
  *    distribution.
 18   
  *
 19   
  * 3. The end-user documentation included with the redistribution, if
 20   
  *    any, must include the following acknowlegement:
 21   
  *       "This product includes software developed by the
 22   
  *        Apache Software Foundation (http://www.apache.org/)."
 23   
  *    Alternately, this acknowlegement may appear in the software itself,
 24   
  *    if and wherever such third-party acknowlegements normally appear.
 25   
  *
 26   
  * 4. The names "Ant" and "Apache Software
 27   
  *    Foundation" must not be used to endorse or promote products derived
 28   
  *    from this software without prior written permission. For written
 29   
  *    permission, please contact apache@apache.org.
 30   
  *
 31   
  * 5. Products derived from this software may not be called "Apache"
 32   
  *    nor may "Apache" appear in their names without prior written
 33   
  *    permission of the Apache Group.
 34   
  *
 35   
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 36   
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 37   
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 38   
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 39   
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 40   
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 41   
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 42   
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 43   
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 44   
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 45   
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 46   
  * SUCH DAMAGE.
 47   
  * ====================================================================
 48   
  *
 49   
  * This software consists of voluntary contributions made by many
 50   
  * individuals on behalf of the Apache Software Foundation.  For more
 51   
  * information on the Apache Software Foundation, please see
 52   
  * <http://www.apache.org/>.
 53   
  */
 54   
 
 55   
 package org.apache.tools.ant.taskdefs;
 56   
 
 57   
 import java.io.File;
 58   
 import java.io.FileOutputStream;
 59   
 import java.io.IOException;
 60   
 import java.io.PrintStream;
 61   
 import java.lang.reflect.Method;
 62   
 import java.util.Enumeration;
 63   
 import java.util.Hashtable;
 64   
 import java.util.Vector;
 65   
 import org.apache.tools.ant.BuildException;
 66   
 import org.apache.tools.ant.BuildListener;
 67   
 import org.apache.tools.ant.DefaultLogger;
 68   
 import org.apache.tools.ant.Project;
 69   
 import org.apache.tools.ant.ProjectComponent;
 70   
 import org.apache.tools.ant.ProjectHelper;
 71   
 import org.apache.tools.ant.Task;
 72   
 import org.apache.tools.ant.util.FileUtils;
 73   
 
 74   
 /**
 75   
  * Build a sub-project.
 76   
  *
 77   
  *  <pre>
 78   
  *  &lt;target name=&quot;foo&quot; depends=&quot;init&quot;&gt;
 79   
  *    &lt;ant antfile=&quot;build.xml&quot; target=&quot;bar&quot; &gt;
 80   
  *      &lt;property name=&quot;property1&quot; value=&quot;aaaaa&quot; /&gt;
 81   
  *      &lt;property name=&quot;foo&quot; value=&quot;baz&quot; /&gt;
 82   
  *    &lt;/ant&gt;</SPAN>
 83   
  *  &lt;/target&gt;</SPAN>
 84   
  *
 85   
  *  &lt;target name=&quot;bar&quot; depends=&quot;init&quot;&gt;
 86   
  *    &lt;echo message=&quot;prop is ${property1} ${foo}&quot; /&gt;
 87   
  *  &lt;/target&gt;
 88   
  * </pre>
 89   
  *
 90   
  *
 91   
  * @author Costin Manolache
 92   
  *
 93   
  * @since Ant 1.1
 94   
  *
 95   
  * @ant.task category="control"
 96   
  */
 97   
 public class Ant extends Task {
 98   
 
 99   
     /** the basedir where is executed the build file */
 100   
     private File dir = null;
 101   
 
 102   
     /**
 103   
      * the build.xml file (can be absolute) in this case dir will be
 104   
      * ignored
 105   
      */
 106   
     private String antFile = null;
 107   
 
 108   
     /** the target to call if any */
 109   
     private String target = null;
 110   
 
 111   
     /** the output */
 112   
     private String output  = null;
 113   
 
 114   
     /** should we inherit properties from the parent ? */
 115   
     private boolean inheritAll = true;
 116   
 
 117   
     /** should we inherit references from the parent ? */
 118   
     private boolean inheritRefs = false;
 119   
 
 120   
     /** the properties to pass to the new project */
 121   
     private Vector properties = new Vector();
 122   
 
 123   
     /** the references to pass to the new project */
 124   
     private Vector references = new Vector();
 125   
 
 126   
     /** the temporary project created to run the build file */
 127   
     private Project newProject;
 128   
 
 129   
     /** The stream to which output is to be written. */
 130   
     private PrintStream out = null;
 131   
 
 132   
     /**
 133   
      * If true, pass all properties to the new Ant project.
 134   
      * Defaults to true.
 135   
      */
 136  20
     public void setInheritAll(boolean value) {
 137  20
         inheritAll = value;
 138   
     }
 139   
 
 140   
     /**
 141   
      * If true, pass all references to the new Ant project.
 142   
      * Defaults to false.
 143   
      */
 144  7
     public void setInheritRefs(boolean value) {
 145  7
         inheritRefs = value;
 146   
     }
 147   
 
 148   
     /**
 149   
      * Creates a Project instance for the project to call.
 150   
      */
 151  52
     public void init() {
 152  52
         newProject = new Project();
 153  52
         newProject.setDefaultInputStream(getProject().getDefaultInputStream());
 154  52
         newProject.setJavaVersionProperty();
 155  52
         newProject.addTaskDefinition("property",
 156   
                                      (Class) getProject().getTaskDefinitions()
 157   
                                              .get("property"));
 158   
     }
 159   
 
 160   
     /**
 161   
      * Called in execute or createProperty if newProject is null.
 162   
      *
 163   
      * <p>This can happen if the same instance of this task is run
 164   
      * twice as newProject is set to null at the end of execute (to
 165   
      * save memory and help the GC).</p>
 166   
      *
 167   
      * <p>Sets all properties that have been defined as nested
 168   
      * property elements.</p>
 169   
      */
 170  7
     private void reinit() {
 171  7
         init();
 172  7
         final int count = properties.size();
 173  7
         for (int i = 0; i < count; i++) {
 174  0
             Property p = (Property) properties.elementAt(i);
 175  0
             Property newP = (Property) newProject.createTask("property");
 176  0
             newP.setName(p.getName());
 177  0
             if (p.getValue() != null) {
 178  0
                 newP.setValue(p.getValue());
 179   
             }
 180  0
             if (p.getFile() != null) {
 181  0
                 newP.setFile(p.getFile());
 182   
             }
 183  0
             if (p.getResource() != null) {
 184  0
                 newP.setResource(p.getResource());
 185   
             }
 186  0
             if (p.getPrefix() != null) {
 187  0
                 newP.setPrefix(p.getPrefix());
 188   
             }
 189  0
             if (p.getRefid() != null) {
 190  0
                 newP.setRefid(p.getRefid());
 191   
             }
 192  0
             if (p.getEnvironment() != null) {
 193  0
                 newP.setEnvironment(p.getEnvironment());
 194   
             }
 195  0
             if (p.getClasspath() != null) {
 196  0
                 newP.setClasspath(p.getClasspath());
 197   
             }
 198  0
             properties.setElementAt(newP, i);
 199   
         }
 200   
     }
 201   
 
 202   
     /**
 203   
      * Attaches the build listeners of the current project to the new
 204   
      * project, configures a possible logfile, transfers task and
 205   
      * data-type definitions, transfers properties (either all or just
 206   
      * the ones specified as user properties to the current project,
 207   
      * depending on inheritall), transfers the input handler.
 208   
      */
 209  50
     private void initializeProject() {
 210  50
         newProject.setInputHandler(getProject().getInputHandler());
 211   
 
 212  50
         Vector listeners = getProject().getBuildListeners();
 213  50
         final int count = listeners.size();
 214  50
         for (int i = 0; i < count; i++) {
 215  69
             newProject.addBuildListener((BuildListener) listeners.elementAt(i));
 216   
         }
 217   
 
 218  50
         if (output != null) {
 219  4
             File outfile = null;
 220  4
             if (dir != null) {
 221  3
                 outfile = FileUtils.newFileUtils().resolveFile(dir, output);
 222   
             } else {
 223  1
                 outfile = getProject().resolveFile(output);
 224   
             }
 225  4
             try {
 226  4
                 out = new PrintStream(new FileOutputStream(outfile));
 227  4
                 DefaultLogger logger = new DefaultLogger();
 228  4
                 logger.setMessageOutputLevel(Project.MSG_INFO);
 229  4
                 logger.setOutputPrintStream(out);
 230  4
                 logger.setErrorPrintStream(out);
 231  4
                 newProject.addBuildListener(logger);
 232   
             } catch (IOException ex) {
 233  0
                 log("Ant: Can't set output to " + output);
 234   
             }
 235   
         }
 236   
 
 237  50
         Hashtable taskdefs = getProject().getTaskDefinitions();
 238  50
         Enumeration et = taskdefs.keys();
 239  50
         while (et.hasMoreElements()) {
 240  9050
             String taskName = (String) et.nextElement();
 241  9050
             if (taskName.equals("property")) {
 242   
                 // we have already added this taskdef in #init
 243  50
                 continue;
 244   
             }
 245  9000
             Class taskClass = (Class) taskdefs.get(taskName);
 246  9000
             newProject.addTaskDefinition(taskName, taskClass);
 247   
         }
 248   
 
 249  50
         Hashtable typedefs = getProject().getDataTypeDefinitions();
 250  50
         Enumeration e = typedefs.keys();
 251  50
         while (e.hasMoreElements()) {
 252  900
             String typeName = (String) e.nextElement();
 253  900
             Class typeClass = (Class) typedefs.get(typeName);
 254  900
             newProject.addDataTypeDefinition(typeName, typeClass);
 255   
         }
 256   
 
 257   
         // set user-defined properties
 258  50
         getProject().copyUserProperties(newProject);
 259   
 
 260  50
         if (!inheritAll) {
 261   
            // set Java built-in properties separately,
 262   
            // b/c we won't inherit them.
 263  12
            newProject.setSystemProperties();
 264   
 
 265   
         } else {
 266   
             // set all properties from calling project
 267   
 
 268  38
             Hashtable props = getProject().getProperties();
 269  38
             e = props.keys();
 270  38
             while (e.hasMoreElements()) {
 271  2124
                 String arg = e.nextElement().toString();
 272  2124
                 if ("basedir".equals(arg) || "ant.file".equals(arg)) {
 273   
                     // basedir and ant.file get special treatment in execute()
 274  76
                     continue;
 275   
                 }
 276   
 
 277  2048
                 String value = props.get(arg).toString();
 278   
                 // don't re-set user properties, avoid the warning message
 279  2048
                 if (newProject.getProperty(arg) == null){
 280   
                     // no user property
 281  1941
                     newProject.setNewProperty(arg, value);
 282   
                 }
 283   
             }
 284   
         }
 285   
     }
 286   
 
 287   
     /**
 288   
      * Pass output sent to System.out to the new project.
 289   
      *
 290   
      * @since Ant 1.5
 291   
      */
 292  0
     public void handleOutput(String line) {
 293  0
         if (newProject != null) {
 294  0
             newProject.demuxOutput(line, false);
 295   
         } else {
 296  0
             super.handleOutput(line);
 297   
         }
 298   
     }
 299   
 
 300   
     /**
 301   
      * @see Task#handleInput(byte[], int, int)
 302   
      * 
 303   
      * @since Ant 1.6
 304   
      */
 305  0
     public int handleInput(byte[] buffer, int offset, int length) 
 306   
         throws IOException {
 307  0
         if (newProject != null) {
 308  0
             return newProject.demuxInput(buffer, offset, length);
 309   
         } else {
 310  0
             return super.handleInput(buffer, offset, length);
 311   
         }
 312   
     }
 313   
     
 314   
     /**
 315   
      * Pass output sent to System.out to the new project.
 316   
      *
 317   
      * @since Ant 1.5.2
 318   
      */
 319  0
     public void handleFlush(String line) {
 320  0
         if (newProject != null) {
 321  0
             newProject.demuxFlush(line, false);
 322   
         } else {
 323  0
             super.handleFlush(line);
 324   
         }
 325   
     }
 326   
 
 327   
     /**
 328   
      * Pass output sent to System.err to the new project.
 329   
      *
 330   
      * @since Ant 1.5
 331   
      */
 332  0
     public void handleErrorOutput(String line) {
 333  0
         if (newProject != null) {
 334  0
             newProject.demuxOutput(line, true);
 335   
         } else {
 336  0
             super.handleErrorOutput(line);
 337   
         }
 338   
     }
 339   
 
 340   
     /**
 341   
      * Pass output sent to System.err to the new project.
 342   
      *
 343   
      * @since Ant 1.5.2
 344   
      */
 345  0
     public void handleErrorFlush(String line) {
 346  0
         if (newProject != null) {
 347  0
             newProject.demuxFlush(line, true);
 348   
         } else {
 349  0
             super.handleErrorFlush(line);
 350   
         }
 351   
     }
 352   
 
 353   
     /**
 354   
      * Do the execution.
 355   
      */
 356  50
     public void execute() throws BuildException {
 357  50
         File savedDir = dir;
 358  50
         String savedAntFile = antFile;
 359  50
         String savedTarget = target;
 360  50
         try {
 361  50
             if (newProject == null) {
 362  7
                 reinit();
 363   
             }
 364   
 
 365  50
             if ((dir == null) && (inheritAll)) {
 366  32
                 dir = getProject().getBaseDir();
 367   
             }
 368   
 
 369  50
             initializeProject();
 370   
 
 371  50
             if (dir != null) {
 372  40
                 newProject.setBaseDir(dir);
 373  40
                 if (savedDir != null) { // has been set explicitly
 374  8
                     newProject.setInheritedProperty("basedir" ,
 375   
                                                     dir.getAbsolutePath());
 376   
                 }
 377   
             } else {
 378  10
                 dir = getProject().getBaseDir();
 379   
             }
 380   
 
 381  50
             overrideProperties();
 382   
 
 383  50
             if (antFile == null) {
 384  0
                 antFile = "build.xml";
 385   
             }
 386   
 
 387  50
             File file = FileUtils.newFileUtils().resolveFile(dir, antFile);
 388  50
             antFile = file.getAbsolutePath();
 389   
 
 390  50
             log("calling target " + (target != null ? target : "[default]")
 391   
                     + " in build file " +  antFile.toString(),
 392   
                     Project.MSG_VERBOSE);
 393  50
             newProject.setUserProperty("ant.file" , antFile);
 394  50
             ProjectHelper.configureProject(newProject, new File(antFile));
 395   
 
 396  50
             if (target == null) {
 397  3
                 target = newProject.getDefaultTarget();
 398   
             }
 399   
 
 400   
             // Are we trying to call the target in which we are defined (or 
 401   
             // the build file if this is a top level task)?
 402  50
             if (newProject.getBaseDir().equals(getProject().getBaseDir()) &&
 403   
                 newProject.getProperty("ant.file").equals(getProject().getProperty("ant.file"))
 404   
                 && getOwningTarget() != null
 405   
                 && (getOwningTarget().getName().equals("") ||
 406   
                     getOwningTarget().getName().equals(target))) {
 407  2
                 throw new BuildException("ant task calling its own parent "
 408   
                                          + "target");
 409   
             }
 410   
 
 411  48
             addReferences();
 412   
 
 413  48
             if (target != null) {
 414  48
                 newProject.executeTarget(target);
 415   
             } else {
 416  0
                 newProject.executeTarget("");
 417   
             }
 418   
         } finally {
 419   
             // help the gc
 420  50
             newProject = null;
 421  50
             Enumeration enum = properties.elements();
 422  50
             while (enum.hasMoreElements()) {
 423  9
                 Property p = (Property) enum.nextElement();
 424  9
                 p.setProject(null);
 425   
             }
 426   
 
 427  50
             if (output != null && out != null) {
 428  4
                 try {
 429  4
                     out.close();
 430   
                 } catch (final Exception e) {
 431   
                     //ignore
 432   
                 }
 433   
             }
 434  50
             dir = savedDir;
 435  50
             antFile = savedAntFile;
 436  50
             target = savedTarget;
 437   
         }
 438   
     }
 439   
 
 440   
     /**
 441   
      * Override the properties in the new project with the one
 442   
      * explicitly defined as nested elements here.
 443   
      */
 444  50
     private void overrideProperties() throws BuildException {
 445  50
         Enumeration e = properties.elements();
 446  50
         while (e.hasMoreElements()) {
 447  9
             Property p = (Property) e.nextElement();
 448  9
             p.setProject(newProject);
 449  9
             p.execute();
 450   
         }
 451  50
         getProject().copyInheritedProperties(newProject);
 452   
     }
 453   
 
 454   
     /**
 455   
      * Add the references explicitly defined as nested elements to the
 456   
      * new project.  Also copy over all references that don't override
 457   
      * existing references in the new project if inheritrefs has been
 458   
      * requested.
 459   
      */
 460  48
     private void addReferences() throws BuildException {
 461  48
         Hashtable thisReferences 
 462   
             = (Hashtable) getProject().getReferences().clone();
 463  48
         Hashtable newReferences = newProject.getReferences();
 464  48
         Enumeration e;
 465  48
         if (references.size() > 0) {
 466  3
             for (e = references.elements(); e.hasMoreElements();) {
 467  3
                 Reference ref = (Reference) e.nextElement();
 468  3
                 String refid = ref.getRefId();
 469  3
                 if (refid == null) {
 470  0
                     throw new BuildException("the refid attribute is required"
 471   
                                              + " for reference elements");
 472   
                 }
 473  3
                 if (!thisReferences.containsKey(refid)) {
 474  0
                     log("Parent project doesn't contain any reference '"
 475   
                         + refid + "'",
 476   
                         Project.MSG_WARN);
 477  0
                     continue;
 478   
                 }
 479   
 
 480  3
                 thisReferences.remove(refid);
 481  3
                 String toRefid = ref.getToRefid();
 482  3
                 if (toRefid == null) {
 483  0
                     toRefid = refid;
 484   
                 }
 485  3
                 copyReference(refid, toRefid);
 486   
             }
 487   
         }
 488   
 
 489   
         // Now add all references that are not defined in the
 490   
         // subproject, if inheritRefs is true
 491  48
         if (inheritRefs) {
 492  5
             for (e = thisReferences.keys(); e.hasMoreElements();) {
 493  40
                 String key = (String) e.nextElement();
 494  40
                 if (newReferences.containsKey(key)) {
 495  25
                     continue;
 496   
                 }
 497  15
                 copyReference(key, key);
 498   
             }
 499   
         }
 500   
     }
 501   
 
 502   
     /**
 503   
      * Try to clone and reconfigure the object referenced by oldkey in
 504   
      * the parent project and add it to the new project with the key
 505   
      * newkey.
 506   
      *
 507   
      * <p>If we cannot clone it, copy the referenced object itself and
 508   
      * keep our fingers crossed.</p>
 509   
      */
 510  18
     private void copyReference(String oldKey, String newKey) {
 511  18
         Object orig = getProject().getReference(oldKey);
 512  18
         if (orig == null) {
 513  0
             log("No object referenced by " + oldKey + ". Can't copy to " 
 514   
                 + newKey, 
 515   
                 Project.MSG_WARN);
 516  0
             return;
 517   
         }
 518   
 
 519  18
         Class c = orig.getClass();
 520  18
         Object copy = orig;
 521  18
         try {
 522  18
             Method cloneM = c.getMethod("clone", new Class[0]);
 523  13
             if (cloneM != null) {
 524  13
                 copy = cloneM.invoke(orig, new Object[0]);
 525  13
                 log("Adding clone of reference " + oldKey, Project.MSG_DEBUG);
 526   
             }
 527   
         } catch (Exception e) {
 528   
             // not Clonable
 529   
         }
 530   
 
 531   
 
 532  18
         if (copy instanceof ProjectComponent) {
 533  13
             ((ProjectComponent) copy).setProject(newProject);
 534   
         } else {
 535  5
             try {
 536  5
                 Method setProjectM =
 537   
                     c.getMethod("setProject", new Class[] {Project.class});
 538  0
                 if (setProjectM != null) {
 539  0
                     setProjectM.invoke(copy, new Object[] {newProject});
 540   
                 }
 541   
             } catch (NoSuchMethodException e) {
 542   
                 // ignore this if the class being referenced does not have
 543   
                 // a set project method.
 544   
             } catch (Exception e2) {
 545  0
                 String msg = "Error setting new project instance for "
 546   
                     + "reference with id " + oldKey;
 547  0
                 throw new BuildException(msg, e2, getLocation());
 548   
             }
 549   
         }
 550  18
         newProject.addReference(newKey, copy);
 551   
     }
 552   
 
 553   
     /**
 554   
      * The directory to use as a base directory for the new Ant project.
 555   
      * Defaults to the current project's basedir, unless inheritall
 556   
      * has been set to false, in which case it doesn't have a default
 557   
      * value. This will override the basedir setting of the called project.
 558   
      */
 559  8
     public void setDir(File d) {
 560  8
         this.dir = d;
 561   
     }
 562   
 
 563   
     /**
 564   
      * The build file to use.
 565   
      * Defaults to "build.xml". This file is expected to be a filename relative
 566   
      * to the dir attribute given.
 567   
      */
 568  44
     public void setAntfile(String s) {
 569   
         // @note: it is a string and not a file to handle relative/absolute
 570   
         // otherwise a relative file will be resolved based on the current
 571   
         // basedir.
 572  44
         this.antFile = s;
 573   
     }
 574   
 
 575   
     /**
 576   
      * The target of the new Ant project to execute.
 577   
      * Defaults to the new project's default target.
 578   
      */
 579  42
     public void setTarget(String s) {
 580  42
         if (s.equals("")) {
 581  1
             throw new BuildException("target attribute must not be empty");
 582   
         }
 583   
         
 584  41
         this.target = s;
 585   
     }
 586   
 
 587   
     /**
 588   
      * Filename to write the output to.
 589   
      * This is relative to the value of the dir attribute
 590   
      * if it has been set or to the base directory of the
 591   
      * current project otherwise.
 592   
      */
 593  4
     public void setOutput(String s) {
 594  4
         this.output = s;
 595   
     }
 596   
 
 597   
     /**
 598   
      * Property to pass to the new project.
 599   
      * The property is passed as a 'user property'
 600   
      */
 601  9
     public Property createProperty() {
 602  9
         if (newProject == null) {
 603  0
             reinit();
 604   
         }
 605  9
         Property p = new Property(true, getProject());
 606  9
         p.setProject(newProject);
 607  9
         p.setTaskName("property");
 608  9
         properties.addElement(p);
 609  9
         return p;
 610   
     }
 611   
 
 612   
     /**
 613   
      * Reference element identifying a data type to carry
 614   
      * over to the new project.
 615   
      */
 616  1
     public void addReference(Reference r) {
 617  1
         references.addElement(r);
 618   
     }
 619   
 
 620   
     /**
 621   
      * Helper class that implements the nested &lt;reference&gt;
 622   
      * element of &lt;ant&gt; and &lt;antcall&gt;.
 623   
      */
 624   
     public static class Reference
 625   
         extends org.apache.tools.ant.types.Reference {
 626   
 
 627   
         /** Creates a reference to be configured by Ant */
 628  1
         public Reference() {
 629  1
             super();
 630   
         }
 631   
 
 632   
         private String targetid = null;
 633   
 
 634   
         /**
 635   
          * Set the id that this reference to be stored under in the
 636   
          * new project.
 637   
          *
 638   
          * @param targetid the id under which this reference will be passed to
 639   
          *        the new project */
 640  1
         public void setToRefid(String targetid) {
 641  1
             this.targetid = targetid;
 642   
         }
 643   
 
 644   
         /**
 645   
          * Get the id under which this reference will be stored in the new
 646   
          * project
 647   
          *
 648   
          * @return the id of the reference in the new project.
 649   
          */
 650  3
         public String getToRefid() {
 651  3
             return targetid;
 652   
         }
 653   
     }
 654   
 }
 655