Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 3973 invoked from network); 15 Apr 2005 20:52:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 15 Apr 2005 20:52:57 -0000 Received: (qmail 13136 invoked by uid 500); 15 Apr 2005 20:52:55 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 13077 invoked by uid 500); 15 Apr 2005 20:52:55 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 13064 invoked by uid 500); 15 Apr 2005 20:52:54 -0000 Received: (qmail 13061 invoked by uid 99); 15 Apr 2005 20:52:54 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Fri, 15 Apr 2005 13:52:54 -0700 Received: (qmail 3955 invoked by uid 1818); 15 Apr 2005 20:52:53 -0000 Date: 15 Apr 2005 20:52:53 -0000 Message-ID: <20050415205253.3954.qmail@minotaur.apache.org> From: mbenson@apache.org To: ant-cvs@apache.org Subject: cvs commit: ant/src/main/org/apache/tools/ant/types RedirectorElement.java X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N mbenson 2005/04/15 13:52:53 Modified: . Tag: ANT_16_BRANCH WHATSNEW src/etc/testcases/types Tag: ANT_16_BRANCH redirector.xml src/testcases/org/apache/tools/ant/types Tag: ANT_16_BRANCH RedirectorElementTest.java src/main/org/apache/tools/ant/types Tag: ANT_16_BRANCH RedirectorElement.java Log: Merge fix. Revision Changes Path No revision No revision 1.503.2.215 +2 -0 ant/WHATSNEW Index: WHATSNEW =================================================================== RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.503.2.214 retrieving revision 1.503.2.215 diff -u -r1.503.2.214 -r1.503.2.215 --- WHATSNEW 11 Apr 2005 09:31:15 -0000 1.503.2.214 +++ WHATSNEW 15 Apr 2005 20:52:52 -0000 1.503.2.215 @@ -310,6 +310,8 @@ * forkmode="perBatch" or "once" would ignore extension attributes that had been specified for s. Bugzilla Report 32973. +* The refid attribute of the I/O redirector was not functional. + Changes from Ant 1.6.1 to Ant 1.6.2 =================================== No revision No revision 1.1.2.2 +50 -20 ant/src/etc/testcases/types/redirector.xml Index: redirector.xml =================================================================== RCS file: /home/cvs/ant/src/etc/testcases/types/redirector.xml,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- redirector.xml 23 Jun 2004 19:30:14 -0000 1.1.2.1 +++ redirector.xml 15 Apr 2005 20:52:53 -0000 1.1.2.2 @@ -1,24 +1,54 @@ - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No revision No revision 1.1.2.2 +7 -2 ant/src/testcases/org/apache/tools/ant/types/RedirectorElementTest.java Index: RedirectorElementTest.java =================================================================== RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/types/RedirectorElementTest.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- RedirectorElementTest.java 23 Jun 2004 19:30:14 -0000 1.1.2.1 +++ RedirectorElementTest.java 15 Apr 2005 20:52:53 -0000 1.1.2.2 @@ -1,5 +1,5 @@ /* - * Copyright 2004 The Apache Software Foundation. + * Copyright 2004-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. @@ -16,6 +16,7 @@ */ package org.apache.tools.ant.types; +import org.apache.tools.ant.Project; import org.apache.tools.ant.BuildFileTest; public class RedirectorElementTest extends BuildFileTest { @@ -25,7 +26,7 @@ } public void setUp() { - configureProject("src/etc/testcases/types/redirector.xml"); + configureProject("src/etc/testcases/types/redirector.xml", Project.MSG_VERBOSE); } public void test1() { @@ -48,4 +49,8 @@ executeTarget("test4"); } + public void testRefid() { + executeTarget("testRefid"); + } + } No revision No revision 1.2.2.3 +79 -11 ant/src/main/org/apache/tools/ant/types/RedirectorElement.java Index: RedirectorElement.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/RedirectorElement.java,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.3 diff -u -r1.2.2.2 -r1.2.2.3 --- RedirectorElement.java 24 Sep 2004 22:29:09 -0000 1.2.2.2 +++ RedirectorElement.java 15 Apr 2005 20:52:53 -0000 1.2.2.3 @@ -1,5 +1,5 @@ /* - * Copyright 2004 The Apache Software Foundation. + * Copyright 2004-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. @@ -17,14 +17,14 @@ package org.apache.tools.ant.types; import java.io.File; +import java.util.Stack; import java.util.Vector; +import java.util.Iterator; import java.util.ArrayList; -import org.apache.tools.ant.Task; import org.apache.tools.ant.Project; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.taskdefs.Redirector; -import org.apache.tools.ant.types.DataType; /** * Element representation of a Redirector. @@ -108,7 +108,7 @@ } if (this.inputMapper != null) { if (usingInput) { - throw new BuildException("attribute \"input\"" + throw new BuildException("attribute \"input\"" + " cannot coexist with a nested "); } else { throw new BuildException("Cannot have > 1 "); @@ -146,7 +146,7 @@ } if (this.errorMapper != null) { if (usingError) { - throw new BuildException("attribute \"error\"" + throw new BuildException("attribute \"error\"" + " cannot coexist with a nested "); } else { throw new BuildException("Cannot have > 1 "); @@ -160,6 +160,8 @@ * *

You must not set another attribute or nest elements inside * this element if you make it a reference.

+ * @param r the reference to use + * @throws BuildException on error */ public void setRefid(Reference r) throws BuildException { if (usingInput @@ -210,7 +212,6 @@ this.inputString = inputString; } - /** * File the output of the process is redirected to. If error is not * redirected, it too will appear in the output @@ -273,7 +274,6 @@ if (isReference()) { throw tooManyAttributes(); } - //pre JDK 1.4 compatible this.logError = ((logError) ? Boolean.TRUE : Boolean.FALSE); } @@ -315,7 +315,6 @@ if (isReference()) { throw tooManyAttributes(); } - //pre JDK 1.4 compatible this.append = ((append) ? Boolean.TRUE : Boolean.FALSE); } @@ -330,7 +329,6 @@ if (isReference()) { throw tooManyAttributes(); } - //pre JDK 1.4 compatible this.alwaysLog = ((alwaysLog) ? Boolean.TRUE : Boolean.FALSE); } @@ -343,7 +341,6 @@ if (isReference()) { throw tooManyAttributes(); } - //pre JDK 1.4 compatible this.createEmptyFiles = ((createEmptyFiles) ? Boolean.TRUE : Boolean.FALSE); } @@ -418,6 +415,10 @@ * @param sourcefile String. */ public void configure(Redirector redirector, String sourcefile) { + if (isReference()) { + getRef().configure(redirector, sourcefile); + return; + } if (alwaysLog != null) { redirector.setAlwaysLog(alwaysLog.booleanValue()); } @@ -530,7 +531,74 @@ list.add(getProject().resolveFile(name[i])); } } - return (File[])(list.toArray(new File[list.size()])); + return (File[]) (list.toArray(new File[list.size()])); + } + + /** + * Convenience method. + * @throws BuildException on error. + */ + protected void dieOnCircularReference() throws BuildException { + if (isChecked()) { + return; + } + Stack s = new Stack(); + s.push(this); + dieOnCircularReference(s, getProject()); + } + + /** + * Overrides the version of DataType to recurse on all DataType + * child elements that may have been added. + * @param stk the stack of data types to use (recursively). + * @param p the project to use to dereference the references. + * @throws BuildException on error. + */ + protected void dieOnCircularReference(Stack stk, Project p) + throws BuildException { + if (isChecked()) { + return; + } + if (isReference()) { + super.dieOnCircularReference(stk, p); + } else { + Mapper[] m = new Mapper[] {inputMapper, outputMapper, errorMapper}; + for (int i = 0; i < m.length; i++) { + if (m[i] != null) { + stk.push(m[i]); + m[i].dieOnCircularReference(stk, p); + stk.pop(); + } + } + Vector[] v = new Vector[] + {inputFilterChains, outputFilterChains, errorFilterChains}; + for (int i = 0; i < v.length; i++) { + if (v[i] != null) { + for (Iterator fci = v[i].iterator(); fci.hasNext();) { + FilterChain fc = (FilterChain) fci.next(); + stk.push(fc); + fc.dieOnCircularReference(stk, p); + stk.pop(); + } + } + } + setChecked(true); + } + } + + /** + * Perform the check for circular references, returning the + * referenced RedirectorElement + * @return the referenced RedirectorElement. + */ + private RedirectorElement getRef() { + dieOnCircularReference(); + Object o = getRefid().getReferencedObject(getProject()); + if (!(o instanceof RedirectorElement)) { + throw new BuildException(getRefid().getRefId() + + " doesn\'t denote a RedirectorElement"); + } + return (RedirectorElement) o; } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org