ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject cvs commit: ant/src/etc/testcases/taskdefs/import import_same_target.xml same_target.xml
Date Mon, 25 Apr 2005 10:16:01 GMT
peterreilly    2005/04/25 03:16:01

  Modified:    .        Tag: ANT_16_BRANCH WHATSNEW
               src/main/org/apache/tools/ant/helper Tag: ANT_16_BRANCH
                        ProjectHelper2.java AntXMLContext.java
               src/testcases/org/apache/tools/ant/taskdefs Tag:
                        ANT_16_BRANCH ImportTest.java
  Added:       src/etc/testcases/taskdefs/import Tag: ANT_16_BRANCH
                        import_same_target.xml same_target.xml
  Log:
  sync
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.503.2.219 +2 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.503.2.218
  retrieving revision 1.503.2.219
  diff -u -r1.503.2.218 -r1.503.2.219
  --- WHATSNEW	19 Apr 2005 21:21:03 -0000	1.503.2.218
  +++ WHATSNEW	25 Apr 2005 10:16:01 -0000	1.503.2.219
  @@ -50,6 +50,8 @@
     This means, the jikes compiler adapter now requires Jikes 1.15 or later.
     Bugzilla Reports 25868, 26404 and 32609.
   
  +* Targets with identical name work in imported project. Bugzilla Report 34566.
  +
   Other changes:
   --------------
   
  
  
  
  No                   revision
  No                   revision
  1.33.2.19 +8 -2      ant/src/main/org/apache/tools/ant/helper/ProjectHelper2.java
  
  Index: ProjectHelper2.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/helper/ProjectHelper2.java,v
  retrieving revision 1.33.2.18
  retrieving revision 1.33.2.19
  diff -u -r1.33.2.18 -r1.33.2.19
  --- ProjectHelper2.java	18 Nov 2004 09:49:25 -0000	1.33.2.18
  +++ ProjectHelper2.java	25 Apr 2005 10:16:01 -0000	1.33.2.19
  @@ -24,7 +24,9 @@
   import java.io.IOException;
   import java.io.UnsupportedEncodingException;
   import java.net.URL;
  +import java.util.HashMap;
   import java.util.Hashtable;
  +import java.util.Map;
   import java.util.Stack;
   
   import org.xml.sax.Locator;
  @@ -117,20 +119,24 @@
               context.setIgnoreProjectTag(true);
               Target currentTarget = context.getCurrentTarget();
               Target currentImplicit = context.getImplicitTarget();
  +            Map    currentTargets = context.getCurrentTargets();
               try {
                   Target newCurrent = new Target();
                   newCurrent.setProject(project);
                   newCurrent.setName("");
                   context.setCurrentTarget(newCurrent);
  +                context.setCurrentTargets(new HashMap());
                   context.setImplicitTarget(newCurrent);
                   parse(project, source, new RootHandler(context, mainHandler));
                   newCurrent.execute();
               } finally {
                   context.setCurrentTarget(currentTarget);
                   context.setImplicitTarget(currentImplicit);
  +                context.setCurrentTargets(currentTargets);
               }
           } else {
               // top level file
  +            context.setCurrentTargets(new HashMap());
               parse(project, source, new RootHandler(context, mainHandler));
               // Execute the top-level target
               context.getImplicitTarget().execute();
  @@ -819,8 +825,7 @@
   
               // If the name has already been defined ( import for example )
               if (currentTargets.containsKey(name)) {
  -                if (!context.isIgnoringProjectTag()) {
  -                    // not in an import'ed file
  +                if (context.getCurrentTargets().get(name) != null) {
                       throw new BuildException(
                           "Duplicate target '" + name + "'", target.getLocation());
                   }
  @@ -841,6 +846,7 @@
   
               if (name != null) {
                   target.setName(name);
  +                context.getCurrentTargets().put(name, target);
                   project.addOrReplaceTarget(name, target);
               }
   
  
  
  
  1.4.2.7   +21 -1     ant/src/main/org/apache/tools/ant/helper/AntXMLContext.java
  
  Index: AntXMLContext.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/helper/AntXMLContext.java,v
  retrieving revision 1.4.2.6
  retrieving revision 1.4.2.7
  diff -u -r1.4.2.6 -r1.4.2.7
  --- AntXMLContext.java	19 Jul 2004 18:22:36 -0000	1.4.2.6
  +++ AntXMLContext.java	25 Apr 2005 10:16:01 -0000	1.4.2.7
  @@ -1,5 +1,5 @@
   /*
  - * Copyright  2003-2004 The Apache Software Foundation
  + * Copyright  2003-2005 The Apache Software Foundation
    *
    *  Licensed under the Apache License, Version 2.0 (the "License");
    *  you may not use this file except in compliance with the License.
  @@ -92,6 +92,9 @@
       private Map prefixMapping = new HashMap();
   
   
  +    /** Keeps track of targets in files */
  +    private Map currentTargets = null;
  +
       /**
        * constructor
        * @param project the project to which this antxml context belongs to
  @@ -341,6 +344,23 @@
           }
           return (String) list.get(list.size() - 1);
       }
  +
  +    /**
  +     * Get the targets in the current source file.
  +     * @return the current targets.
  +     */
  +    public Map getCurrentTargets() {
  +        return currentTargets;
  +    }
  +
  +    /**
  +     * Set the map of the targets in the current source file.
  +     * @param currentTargets a map of targets.
  +     */
  +    void setCurrentTargets(Map currentTargets) {
  +        this.currentTargets = currentTargets;
  +    }
  +
   }
   
   
  
  
  
  No                   revision
  No                   revision
  1.6.2.7   +17 -1     ant/src/testcases/org/apache/tools/ant/taskdefs/ImportTest.java
  
  Index: ImportTest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/ImportTest.java,v
  retrieving revision 1.6.2.6
  retrieving revision 1.6.2.7
  diff -u -r1.6.2.6 -r1.6.2.7
  --- ImportTest.java	4 Jun 2004 12:09:38 -0000	1.6.2.6
  +++ ImportTest.java	25 Apr 2005 10:16:01 -0000	1.6.2.7
  @@ -1,5 +1,5 @@
   /*
  - * Copyright  2003-2004 The Apache Software Foundation
  + * Copyright  2003-2005 The Apache Software Foundation
    *
    *  Licensed under the Apache License, Version 2.0 (the "License");
    *  you may not use this file except in compliance with the License.
  @@ -91,6 +91,22 @@
           assertNotNull(getProject().getReference("baz"));
       }
   
  +    public void testImportSameTargets() {
  +        try {
  +            configureProject(
  +                "src/etc/testcases/taskdefs/import/same_target.xml");
  +        } catch (BuildException ex) {
  +            String message = ex.getMessage();
  +            if (message.indexOf("Duplicate target") == -1) {
  +                assertTrue("Did not see 'Duplicate target' in '" + message +"'", false);
  +            }
  +            return;
  +        }
  +        assertTrue(
  +            "Did not see build exception",
  +            false);
  +    }
  +
       public void testImportError() {
           try {
               configureProject(
  
  
  
  No                   revision
  No                   revision
  1.1.2.1   +0 -0      ant/src/etc/testcases/taskdefs/import/import_same_target.xml
  
  
  
  
  1.1.2.1   +0 -0      ant/src/etc/testcases/taskdefs/import/same_target.xml
  
  
  
  

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


Mime
View raw message