From dev-return-50073-apmail-ant-dev-archive=ant.apache.org@ant.apache.org Thu Aug 28 15:07:23 2003 Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 48472 invoked from network); 28 Aug 2003 15:07:23 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 28 Aug 2003 15:07:23 -0000 Received: (qmail 45475 invoked by uid 500); 28 Aug 2003 15:02:52 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 45314 invoked by uid 500); 28 Aug 2003 15:02:50 -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 45215 invoked from network); 28 Aug 2003 15:02:49 -0000 Received: from unknown (HELO relay.t-online-com.de) (62.156.147.74) by daedalus.apache.org with SMTP; 28 Aug 2003 15:02:49 -0000 Received: from DJ0X820J (p5080ec42.dip0.t-ipconnect.de [80.128.236.66]) by relay.t-online-com.de (SMTPSVC(1.0.0.2)) with ESMTP id 8C5D714CAB7 for ; Thu, 28 Aug 2003 16:32:42 +0200 (CEST) Message-ID: <00eb01c36d71$e2ad5c10$020200c0@DJ0X820J> From: "Antoine Levy-Lambert" To: "Ant Developers List" References: <012701c36898$3124aa30$020200c0@DJ0X820J> Subject: Re: [VOTE] Ant/Antcall Returning properties and references [WAS] Re: ant 1.5.4 : Import Date: Thu, 28 Aug 2003 16:37:18 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N So far, I have got two +1 (myself and Jan Materne) for this proposal. The vote will be closed tomorrow at 12:28 pm CET (20 hours from now). Three +1s are required for a code change, so, by the likes of it, the vote will have a negative result. The , , tasks of Antelope provide functionality in terms of returning properties. This is also returning references, so it can bring something new, plus the ease for users who want to deploy ant, but no extra jars providing core functionality to ant. Since there are already tons of changes in ant 1.6 alpha, there can be some wisdom in refusing or postponing this change. And there is also enough work fixing small or large bugs in existing functionality. Cheers, Antoine ----- Original Message ----- From: "Antoine Levy-Lambert" To: "Ant Developers List" Sent: Friday, August 22, 2003 12:28 PM Subject: [VOTE] Ant/Antcall Returning properties and references [WAS] Re: ant 1.5.4 : Import > I think that the code of Dominique would add a lot of value to ant. > Instead of committing the code as is, I would like simply to add the new > features to the task. > This means that it should be a no brainer to have these features then also > in > Can we vote about introducing it ? > I start with my +1 > Cheers, > Antoine > ----- Original Message ----- > From: "Dominique Devienne" > To: "'Ant Developers List'" > Sent: Thursday, July 24, 2003 5:36 PM > Subject: RE: ant 1.5.4 : Import > > > > Then have a look at what I did in the past two days to do something > similar > > ;-) I created an task that piggybacks on , and allows > > returning properties and/or references from the called build file back > into > > the caller's context (Project). > > > > That would take care of that use case ;-) --DD > > > > > -----Original Message----- > > > From: Conor MacNeill [mailto:conor@cortexebusiness.com.au] > > > Sent: Thursday, July 24, 2003 10:39 AM > > > To: Ant Developers List > > > Subject: Re: ant 1.5.4 : Import > > > > > > On Fri, 25 Jul 2003 01:23 am, Dominique Devienne wrote: > > > > > > > > I (strongly again ;) believe that imported build files should be > > > designed > > > > to be imported, and never used without being imported. > > > > > > I disagree (strongly :-). I think augmenting/overriding an existing > build > > > file > > > is a valid use for import. I recently changed the checkstyle build I > have > > > been using (check.xml) to import Ant's build.xml to pick up property > defs > > > for > > > various locations. Have a look. > > > > > > Conor > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > // vim:ts=2:sw=2 > > package com.lgc.buildmagic.test; > > > > import org.apache.tools.ant.ProjectComponent; > > import org.apache.tools.ant.types.Path; > > import org.apache.tools.ant.types.FileSet; > > > > import com.lgc.buildmagic.util.BuildFileTestCase; > > > > /** > > * Tests <antreturn>. > > * > > * @author Dominique Devienne > > * @version Jul 2003 - Copyright (c) 2003, Landmark Graphics Corp. > > */ > > public class AntReturnTest > > extends BuildFileTestCase { > > > > public void testReturnProperty() { > > executeTarget("test-returnProperty"); > > > > assertProperty("propA", "a"); > > assertProperty("propB", null); > > assertProperty("propC", "ccc"); > > assertProperty("propD", null); > > } > > > > private void assertProperty(String name, String expectedValue) { > > String value = getProject().getProperty(name); > > assertEquals(name + " property", value, expectedValue); > > } > > > > public void testReturnReference() { > > executeTarget("test-returnReference"); > > > > assertReference("pathRef", Path.class); > > assertReference("filesetRef", FileSet.class); > > assertReference("patternsetRef", null); > > } > > > > private void assertReference(String refid, Class expectedClass) { > > Object value = getProject().getReference(refid); > > if (expectedClass != null) { > > assertNotNull(refid + " reference", value); > > assertEquals(refid + " reference type", expectedClass, > > value.getClass()); > > assertSame(refid + " reference project", getProject(), > > ((ProjectComponent)value).getProject()); > > } > > else { > > assertEquals(refid + " reference found", false, value != null); > > } > > } > > > > } // END class AntReturnTest > > > > // vim:ts=2:sw=2 > > package com.lgc.buildmagic; > > > > import java.util.List; > > import java.util.Iterator; > > import java.util.ArrayList; > > import java.util.Collections; > > > > import org.apache.tools.ant.Project; > > import org.apache.tools.ant.ProjectComponent; > > import org.apache.tools.ant.BuildException; > > > > import org.apache.tools.ant.types.Reference; > > > > import org.apache.tools.ant.taskdefs.Ant; > > import org.apache.tools.ant.taskdefs.Property; > > > > /** > > * ... > > * > > * @author Dominique Devienne > > * @version Jul 2003 - Copyright (c) 2003, Landmark Graphics Corp. > > * > > * @ant.task category="control" > > */ > > public class AntReturn > > extends Ant { > > > > private Project _newProject; > > private ReturnedElements _returns; > > > > public void init() { > > super.init(); > > setInheritAll(false); > > setInheritRefs(false); > > } > > > > public void execute() > > throws BuildException { > > int returnCount = 0; > > if (_returns != null) { > > returnCount = _returns._references.size() > > + _returns._properties.size(); > > } > > > > if (returnCount > 0 && _newProject == null) { > > // Create dummy property to get at nested project > > Property p = createProperty(); > > p.setName("sdliugyhspuygh.asdjhriawu120983472$376asdbfandbfa7347"); > > p.setValue(""); > > > > if (_newProject == null) { > > throw new BuildException("Cannot access nested Project > BEFORE!!!"); > > } > > } > > > > super.execute(); > > > > if (returnCount < 1) { > > return; // Nothing to return > > } > > > > // Set the returned properties in the outer project > > for (Iterator i = _returns._properties.iterator(); i.hasNext();) { > > ReturnProperty retProperty = (ReturnProperty)i.next(); > > String name = retProperty.getName(); > > String value = _newProject.getProperty(name); > > if (value == null) { > > throw new BuildException("Cannot find property '" + name + "'"); > > } > > getProject().setNewProperty(retProperty.getToName(), value); > > } > > > > // Set the returned properties in the outer project > > for (Iterator i = _returns._references.iterator(); i.hasNext();) { > > ReturnReference retReference = (ReturnReference)i.next(); > > String refid = retReference.getRefid(); > > Object value = _newProject.getReference(refid); > > if (value == null) { > > throw new BuildException("Cannot find reference '" + refid + "'"); > > } > > if (value instanceof ProjectComponent) { > > ((ProjectComponent)value).setProject(getProject()); > > } > > getProject().addReference(retReference.getToRefid(), value); > > } > > } > > > > /** Intercept property creation to catch the new project. Wicked! */ > > public Property createProperty() { > > Property p = super.createProperty(); > > _newProject = p.getProject(); > > return p; > > } > > > > /** Adds the set of properties/references to return. */ > > public void addReturn(ReturnedElements returns) { > > if (_returns != null) { > > throw new BuildException("Can have only one nested "); > > } > > _returns = returns; > > } > > > > /** Programatic convenience to select a property to return. */ > > public void selectProperty(String name, String toName) { > > if (_returns == null) { > > addReturn(new ReturnedElements()); > > } > > ReturnProperty p = new ReturnProperty(); > > p.setName(name); > > if (toName != null) { > > p.setToName(toName); > > } > > _returns.addProperty(p); > > } > > > > /** Programatic convenience to select a reference to return. */ > > public void selectReference(String refid, String toRefid) { > > if (_returns == null) { > > addReturn(new ReturnedElements()); > > } > > ReturnReference r = new ReturnReference(); > > r.setRefid(refid); > > if (toRefid != null) { > > r.setToRefid(toRefid); > > } > > _returns.addReference(r); > > } > > > > /** A property name to return from the called project. */ > > public static class ReturnProperty { > > private String _name; > > private String _toName; > > > > public void setName(String name) { > > _name = TaskUtils.assertNotEmpty(name, "name", true); > > } > > public void setToName(String toName) { > > _toName = TaskUtils.assertNotEmpty(toName, "toName", true); > > } > > public String getName() { > > TaskUtils.assertAttributeSet(_name, "name"); > > return _name; > > } > > public String getToName() { > > return (_toName == null)? getName(): _toName; > > } > > } // END class AntReturn.ReturnProperty > > > > /** A reference name to return from the called project. */ > > public static class ReturnReference { > > private String _refid; > > private String _toRefid; > > > > public void setRefid(String refid) { > > _refid = TaskUtils.assertNotEmpty(refid, "refid", true); > > } > > public void setToRefid(String toRefid) { > > _toRefid = TaskUtils.assertNotEmpty(toRefid, "toRefid", true); > > } > > public String getRefid() { > > TaskUtils.assertAttributeSet(_refid, "refid"); > > return _refid; > > } > > public String getToRefid() { > > return (_toRefid == null)? getRefid(): _toRefid; > > } > > } // END class AntReturn.ReturnReference > > > > /** List of properties and references to return from the called project. > > */ > > public static class ReturnedElements { > > private List _properties = Collections.EMPTY_LIST; > > private List _references = Collections.EMPTY_LIST; > > > > public void addProperty(ReturnProperty retProperty) { > > if (_properties == Collections.EMPTY_LIST) { > > _properties = new ArrayList(4); > > } > > _properties.add(retProperty); > > } > > > > public void addReference(ReturnReference retReference) { > > if (_references == Collections.EMPTY_LIST) { > > _references = new ArrayList(4); > > } > > _references.add(retReference); > > } > > } // END class AntReturn.ReturnedElements > > > > } // END class AntReturn > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org