ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Feller" <Emmanuel.Fel...@free.fr>
Subject Re: [VOTE] Ant/Antcall Returning properties and references [WAS] Re: ant 1.5.4 : Import
Date Thu, 28 Aug 2003 19:48:35 GMT
Hello,
As I am not a commiter i don't may vote, but i would like to
explain my point of view on this proposal.

I don't think that it is a good way. because ant build file
are not script file and include some returning sub project
will be use as a function : this is the first foot to
scripting language.

I like ant because it describe the build, it does not script
it. I did a lot of build with script because i had no way to
do something else, and i rather not see this in ant.

I like the import of antlib (snippet from build file) and
the macro and preset task. In my humble opinion it is just
the necessary stuff.

I know that some key user in special part of special way may
need this, but in 99% of case it is unlikeable.
In my opinion it is better to keep the task as is, and let
the returning task live in a special place but not in the
ant core.
Emmanuel.
ps: sorry for this quiet bad english. :)
----- Message d'origine -----
De : "Antoine Levy-Lambert" <antoine@antbuild.com>
À : "Ant Developers List" <dev@ant.apache.org>
Envoyé : jeudi 28 août 2003 16:37
Objet : Re: [VOTE] Ant/Antcall Returning properties and
references [WAS] Re: ant 1.5.4 : Import


> 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 <antfetch/>, <antcallback/>, <call/> tasks of Antelope
provide
> functionality in terms of returning properties. This
<antreturn/> 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" <antoine@antbuild.com>
> To: "Ant Developers List" <dev@ant.apache.org>
> 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 <ant/> task.
> > This means that it should be a no brainer to have these
features then also
> > in <antcall/>
> > Can we vote about introducing it ?
> > I start with my +1
> > Cheers,
> > Antoine
> > ----- Original Message -----
> > From: "Dominique Devienne" <DDevienne@lgc.com>
> > To: "'Ant Developers List'" <dev@ant.apache.org>
> > 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 <antreturn> task that piggybacks on
<ant>, 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
> > >
> > >
> > > <?xml version="1.0"?>
> > >
> > > <project name="AntReturnTest"
default="test-returnProperty">
> > >
> > >   <!-- Our custom tasks we are testing -->
> > >   <taskdef
resource="com/lgc/buildmagic/tasks.properties" />
> > >   <typedef
resource="com/lgc/buildmagic/types.properties" />
> > >
> > >   <target name="test-returnProperty">
> > >     <antreturn antfile="AntReturnNestedTest.xml"
> target="set-properties">
> > >       <return>
> > >         <property name="propA" />
> > >         <property name="propC" />
> > >       </return>
> > >     </antreturn>
> > >   </target>
> > >
> > >   <target name="test-returnReference">
> > >     <antreturn antfile="AntReturnNestedTest.xml"
> target="set-references">
> > >       <return>
> > >         <reference refid="pathRef" />
> > >         <reference refid="filesetRef" />
> > >       </return>
> > >     </antreturn>
> > >   </target>
> > >
> > > </project>
> > >
> > > <?xml version="1.0"?>
> > >
> > > <project name="AntReturnNestedTest"
default="set-properties">
> > >
> > >   <target name="set-properties">
> > >     <property name="propA" value="a" />
> > >     <property name="propB" value="bb" />
> > >     <property name="propC" value="ccc" />
> > >     <property name="propD" value="dddd" />
> > >   </target>
> > >
> > >   <target name="set-references">
> > >     <path id="pathRef" location="${basedir}" />
> > >     <fileset id="filesetRef" dir="${basedir}">
> > >       <include name="AntReturn*Test.xml" />
> > >     </fileset>
> > >     <patternset id="patternsetRef">
> > >       <include name="dummy" />
> > >     </patternset>
> > >   </target>
> > >
> > > </project>
> > >
> > > // 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 &lt;antreturn&gt;.
> > >  *
> > >  * @author <a
href="mailto:ddevienne@lgc.com">Dominique Devienne</a>
> > >  * @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 <a
href="mailto:ddevienne@lgc.com">Dominique Devienne</a>
> > >  * @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$376asdbfandbfa
7347");
> > >       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 <return>");
> > >     }
> > >     _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
>
>



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


Mime
View raw message