Return-Path: Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 18761 invoked by uid 500); 12 Aug 2003 22:10:08 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 18748 invoked from network); 12 Aug 2003 22:10:08 -0000 Received: from smtp-send.load.com (209.58.232.28) by daedalus.apache.org with SMTP; 12 Aug 2003 22:10:08 -0000 Received: (qmail 11088 invoked from network); 12 Aug 2003 22:10:12 -0000 Received: from unknown (HELO ?172.29.128.122?) (63.145.195.2) by smtp04.load.com with SMTP; 12 Aug 2003 22:10:12 -0000 Date: Tue, 12 Aug 2003 15:28:00 -0700 (PDT) From: Robert Rice X-X-Sender: robert@localhost.localdomain To: Dominique Devienne cc: 'Ant Users List' Subject: RE: Custom Selectors missing Project and logging? In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Thanks for the clear example. That worked perfectly. My params are now coming into the custom selector. Robert Rice On Tue, 12 Aug 2003, Dominique Devienne wrote: > I used the protected parameters myself. Here's an example. You probably need > to override verifySettings() and call explicitly validate() in your > isSelected() method, as demonstrated below. --DD > > PS: Note that Ant CVS HEAD configures selectors using the same introspection > rules as for types and tasks, and thus supercedes the Parameter-based stuff. > > public class TestTypeAndConfigSelector > extends BaseExtendSelector { > > /** > * Converters the recorded parameters into setter calls. > *

> * This selector can be configured either explicitly in code using the > * non-default constructor, and by calling explicitly {@link #setType} > * or {@link #setConfig}, or by the Ant selector mechanism using > * parameters, and thus requires to keep track whether is was configured > * or not. > */ > public void verifySettings() { > if (_configured) { > return; > } > if (parameters == null) { > setError("Nested 'type' and/or 'config' params required!"); > return; > } > for (int i = 0; i < parameters.length; ++i) { > Parameter param = parameters[i]; > String name = param.getName().toLowerCase().intern(); > String value = param.getValue(); > if (name == "type") { > setType(value); > } > else if (name == "config") { > setConfig(value); > } > else if (name == "typefield") { > setTypeField(value); > } > else if (name == "configfield") { > setConfigField(value); > } > else { > setError("Invalid param name: " + name); > return; > } > } > _configured = true; > } > > // Implements FileSelector#isSelected > // thru BaseExtendSelector#isSelected > public boolean isSelected(File basedir, String filename, File file) > throws BuildException { > validate(); // calls verifySettings... > ... > return true; > } > > } // END class TestTypeAndConfigSelector > > > > -----Original Message----- > > From: Robert Rice [mailto:robert@windermere.com] > > Sent: Tuesday, August 12, 2003 4:29 PM > > To: Ant Users List > > Subject: RE: Custom Selectors missing Project and logging? > > > > Any chance this also goes for the list of parameters? getParameters( ) > > seems to return null, though I am setting two parameters on the custom > > selector using the nested element. > > > > Robert Rice > > > > On Tue, 12 Aug 2003, Dominique Devienne wrote: > > > > > I think I spoke too soon... > > > > > > You can get back the current Task, thru Project#getThreadTask, but you > > need > > > a Project instance to do that. I'm not sure the current project is ever > > > registered... Sorry, --DD > > > > > > > -----Original Message----- > > > > From: Robert Rice [mailto:robert@windermere.com] > > > > Sent: Tuesday, August 12, 2003 2:54 PM > > > > To: Dominique Devienne > > > > Subject: RE: Custom Selectors missing Project and logging? > > > > > > > > Thanks for the help. I was guessing that it might be a bug. Just > > seemed > > > > too strange since Project is usually readily available. > > > > > > > > If you find the reference to getting the current project, I would sure > > be > > > > interested. I had previously poked around thinking I might be able to > > > > find it but no luck. I will follow your suggestions and see what I > > can > > > > find. > > > > > > > > Thanks again, > > > > Robert Rice > > > > > > > -----Original Message----- > > > > From: Dominique Devienne [mailto:DDevienne@lgc.com] > > > > Sent: Tuesday, August 12, 2003 2:19 PM > > > > To: 'Ant Users List' > > > > Subject: RE: Custom Selectors missing Project and logging? > > > > > > > > I think there was a bug (now fixed in CVS) where setProject() was not > > > > called for custom selectors in 1.5.x. > > > > > > > > As a turn around, somebody posted a few months back a trick getting > > back > > > > the > > > > current project for the current thread either thru the context loaded, > > or > > > > a > > > > thread local (I think it was the former). I cannot find the reference > > > > though... --DD > > > > > > > > > -----Original Message----- > > > > > From: Robert Rice [mailto:robert@windermere.com] > > > > > Sent: Tuesday, August 12, 2003 2:32 PM > > > > > To: user@ant.apache.org > > > > > Subject: Custom Selectors missing Project and logging? > > > > > > > > > > I'm writing a simple custom selector that extends > > > > > BaseExtendSelector. Thus far, I have only implemented the one > > required > > > > > method: public boolean isSelected( File basedir, String filename, > > File > > > > > file ); > > > > > My custom selector is declared using the tag nested > > within > > > > a > > > > > . > > > > > > > > > > I am trying to log messages from this custom selector. It does not > > log. > > > > > As I look closer, I find that the project reference ( getProject( ) > > ) is > > > > > null, which may explain why no logging takes place. > > > > > > > > > > Is there something I need to do within my selector implementation, > > or in > > > > > the way that I reference it in my build file, to cause the project > > to > > > > get > > > > > set on the selector? > > > > > > > > > > Robert Rice > > > > > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org > > > > For additional commands, e-mail: user-help@ant.apache.org > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org > > > For additional commands, e-mail: user-help@ant.apache.org > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org > > For additional commands, e-mail: user-help@ant.apache.org > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org > For additional commands, e-mail: user-help@ant.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org