Peter, 
do we know the filename where a particular target came from?
I do not know this code well enough. But if we do, we probably
just need to check the files are different.

Jose Alberto

> -----Original Message-----
> From: Peter Reilly [mailto:[EMAIL PROTECTED] 
> Sent: 01 March 2004 09:00
> To: Ant Developers List
> Subject: Re: cvs commit: ant WHATSNEW build.xml
> 
> 
> Jose,
> You are right, the check is just for the main build file.
> 
> Peter
> Jose Alberto Fernandez wrote:
> 
> >Peter,
> >
> >Maybe I do not understand the fix completely,
> >but shouldn't the check be that a target cannot appear
> >ON THE SAME FILE (imported or main) more than once?
> >I.e., I should not be able to duplicate a target on a file
> >and get away with it by importing it instead of executing it 
> directly.
> >
> >Does your fix covers this case?
> >
> >Jose Alberto
> >
> >  
> >
> >>-----Original Message-----
> >>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> >>Sent: 27 February 2004 12:14
> >>To: [EMAIL PROTECTED]
> >>Subject: RE: cvs commit: ant WHATSNEW build.xml
> >>
> >>
> >>Fast resolved, Peter :)
> >>
> >>Jan
> >>
> >>    
> >>
> >>>-----Original Message-----
> >>>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> >>>Sent: Friday, February 27, 2004 12:45 PM
> >>>To: [EMAIL PROTECTED]
> >>>Subject: cvs commit: ant WHATSNEW build.xml
> >>>
> >>>
> >>>peterreilly    2004/02/27 03:45:15
> >>>
> >>>  Modified:    src/main/org/apache/tools/ant/helper 
> >>>ProjectHelper2.java
> >>>               src/testcases/org/apache/tools/ant ProjectTest.java
> >>>               .        WHATSNEW build.xml
> >>>  Log:
> >>>  Fix for duplicate targets in the build file.
> >>>  In ant 1.5 these were not allowed.
> >>>  In ant 1.6, with import file's targets being allowed to
> >>>  be overridden, duplicate targets where incorrectly allowed
> >>>  in normal build files.
> >>>  The fix just checks if the duplicate target is defined
> >>>  in an imported file or in a "main" file.
> >>>  Reported by: Dominique Devienne
> >>>  See: http://marc.theaimsgroup.com/?t=107705039100004&r=1&w=2
> >>>  
> >>>  Revision  Changes    Path
> >>>  1.42      +8 -0      
> >>>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/ProjectHelp
> >>>er2.java,v
> >>>  retrieving revision 1.41
> >>>  retrieving revision 1.42
> >>>  diff -u -r1.41 -r1.42
> >>>  --- ProjectHelper2.java  9 Feb 2004 21:05:18 -0000       1.41
> >>>  +++ ProjectHelper2.java  27 Feb 2004 11:45:14 -0000      1.42
> >>>  @@ -804,6 +804,14 @@
> >>>   
> >>>               // If the name has already been defined ( 
> import for 
> >>>example )
> >>>               if (currentTargets.containsKey(name)) {
> >>>  +                if (!context.isIgnoringProjectTag()) {
> >>>  +                    // not in an import'ed file
> >>>  +                    throw new BuildException(
> >>>  +                        "Duplicate target '" + name + "'",
> >>>  +                        new 
> >>>Location(context.getLocator().getSystemId(),
> >>>  +                                     
> >>>context.getLocator().getLineNumber(),
> >>>  +                                     
> >>>context.getLocator().getColumnNumber()));
> >>>  +                }
> >>>                   // Alter the name.
> >>>                   if (context.getCurrentProjectName() != null) {
> >>>                       String newName =
> >>>context.getCurrentProjectName()
> >>>  
> >>>  
> >>>  
> >>>  1.24      +10 -3     
> >>>ant/src/testcases/org/apache/tools/ant/ProjectTest.java
> >>>  
> >>>  Index: ProjectTest.java
> >>>  
> >>>      
> >>>
> >>===================================================================
> >>    
> >>
> >>>  RCS file: 
> >>>/home/cvs/ant/src/testcases/org/apache/tools/ant/ProjectTest.java,v
> >>>  retrieving revision 1.23
> >>>  retrieving revision 1.24
> >>>  diff -u -r1.23 -r1.24
> >>>  --- ProjectTest.java     20 Feb 2004 12:24:04 -0000      1.23
> >>>  +++ ProjectTest.java     27 Feb 2004 11:45:14 -0000      1.24
> >>>  @@ -206,8 +206,15 @@
> >>>   
> >>>       public void testDuplicateTargets() {
> >>>           // fail, because buildfile contains two targets 
> with the 
> >>>same name
> >>>  -        BFT bft = new BFT("", "core/duplicate-target.xml");
> >>>  -        bft.expectBuildException("twice", "Duplicate target");
> >>>  +        try {
> >>>  +            BFT bft = new BFT("", "core/duplicate-target.xml");
> >>>  +        } catch (BuildException ex) {
> >>>  +            assertEquals("specific message",
> >>>  +                         "Duplicate target 'twice'",
> >>>  +                         ex.getMessage());
> >>>  +            return;
> >>>  +        }
> >>>  +        fail("Should throw BuildException about 
> >>>      
> >>>
> >>duplicate target");
> >>    
> >>
> >>>       }
> >>>   
> >>>       public void testDuplicateTargetsImport() {
> >>>  @@ -265,4 +272,4 @@
> >>>   class DummyTaskPackage extends Task {
> >>>       public DummyTaskPackage() {}
> >>>       public void execute() {}
> >>>  -}
> >>>  \ No newline at end of file
> >>>  +}
> >>>  
> >>>  
> >>>  
> >>>  1.556     +5 -1      ant/WHATSNEW
> >>>  
> >>>  Index: WHATSNEW
> >>>  
> >>>      
> >>>
> >>===================================================================
> >>    
> >>
> >>>  RCS file: /home/cvs/ant/WHATSNEW,v
> >>>  retrieving revision 1.555
> >>>  retrieving revision 1.556
> >>>  diff -u -r1.555 -r1.556
> >>>  --- WHATSNEW     25 Feb 2004 13:02:52 -0000      1.555
> >>>  +++ WHATSNEW     27 Feb 2004 11:45:15 -0000      1.556
> >>>  @@ -53,7 +53,11 @@
> >>>   
> >>>   * MacroDef did not allow attributes named 
> 'description'. Bugzilla 
> >>>Report 27175.
> >>>   
> >>>  -* Throw build exception if name attribute missing from 
> patternset. 
> >>>Bugzilla Report 25982.
> >>>  +* Throw build exception if name attribute missing from
> >>>patternset#NameEntry.
> >>>  +  Bugzilla Report 25982.
> >>>  +
> >>>  +* Throw build exception if target repeated in build file, 
> >>>but allow targets
> >>>  +  to be repeated in imported files. 
> >>>   
> >>>   Other changes:
> >>>   --------------
> >>>  
> >>>  
> >>>  
> >>>  1.412     +1 -8      ant/build.xml
> >>>  
> >>>  Index: build.xml
> >>>  
> >>>      
> >>>
> >>===================================================================
> >>    
> >>
> >>>  RCS file: /home/cvs/ant/build.xml,v
> >>>  retrieving revision 1.411
> >>>  retrieving revision 1.412
> >>>  diff -u -r1.411 -r1.412
> >>>  --- build.xml    26 Feb 2004 16:35:26 -0000      1.411
> >>>  +++ build.xml    27 Feb 2004 11:45:15 -0000      1.412
> >>>  @@ -329,13 +329,6 @@
> >>>     <patternset id="teststhatfail">
> >>>       <exclude
> >>>      
> >>>
> >>name="${optional.package}/BeanShellScriptTest.java"/>
> >>    
> >>
> >>>       <exclude
> >>>      
> >>>
> >>name="${optional.package}/jdepend/JDependTest.java"/>
> >>    
> >>
> >>>  -    <!-- The 
> >>>org.apache.tools.ant.ProjectTest.testDuplicateTargets fails.
> >>>  -    This is a known problem. It was noticed that duplicate 
> >>>targets were
> >>>  -    not detected in ant 1.6.*, so a test was put in. But 
> >>>no code was put in
> >>>  -    to fix the problem!
> >>>  -    see 
> >>>      
> >>>
> >>http://marc.theaimsgroup.com/?l=ant-dev&m=107756336622453&w=2
> >>  -    -->
> >>  -    <exclude name="${ant.package}/ProjectTest.java"/>
> >>     </patternset>
> >>   
> >>     <!--
> >>  @@ -1611,4 +1604,4 @@
> >>             description="--> creates a minimum distribution
> >>in ./dist"
> >>             depends="dist-lite"/>
> >>   
> >>  -</project>
> >>  \ No newline at end of file
> >>  +</project>
> >>  
> >>  
> >>  
> >>
> >>------------------------------------------------------------
> ---------
> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>    
> >>
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> >  
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to