You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Josh Lucas <jo...@stonecottage.com> on 2001/01/18 00:33:52 UTC
other tokens
I was wondering if there has been any discussion of allowing tokens
other than '@' for filtering. I looked through the archives but didn't
really see anything. I would assume it could be a target attribute but
if it's already been discussed, I don't want to work on a patch.
thanks,
josh
Re: [PATCH] Re: other tokens
Posted by Josh Lucas <jo...@stonecottage.com>.
Jon Stevens wrote:
>
> on 1/17/01 5:20 PM, "Josh Lucas" <jo...@stonecottage.com> wrote:
>
> > here ya go...
>
> I just checked this in. could you also please update the index.html?
>
> thx.
>
> -jon
>
done.
Index: index.html
===================================================================
RCS file: /home/cvspublic/jakarta-ant/docs/index.html,v
retrieving revision 1.190
diff -u -r1.190 index.html
--- index.html 2001/01/16 13:28:36 1.190
+++ index.html 2001/01/18 02:05:22
@@ -405,6 +405,7 @@
the target will always be executed.</p>
<p>The optional <code>description</code> attribute can be used to
provide a one-line description of this target, which is printed by the
<nobr><code>-projecthelp</code></nobr> command-line option.</p>
+<p>The optional <code>token</code> attribute can be used to change the
string used for the filtering of values. For example, "***" can be used
as both the start and end of the token instead of "@". If the attribute
is not there, the default value of "@" will be used.</p>
<p>It is a good practice to place your <a
href="#tstamp">tstamp</a> tasks in a so-called
<i>initialization</i> target, on which
@@ -445,6 +446,11 @@
<td valign="top">description</td>
<td valign="top">a short description of this target's
function.</td>
<td align="center" valign="top">No</td>
+ </tr>
+ <tr>
+ <td valign="top">token</td>
+ <td valign="top">the string which will be used as the filtering
token.</td>
+ <td align="top">No (Defaults to "@")</td>
</tr>
</table>
RE: [PATCH] Re: other tokens
Posted by Peter Donald <do...@apache.org>.
At 01:09 18/1/01 +1100, Conor MacNeill wrote:
>I think the
>whole copy functionality should be refactored out of Project, perhaps into
><copy>
Agreed - or event better into a IOUtils or FileUtils (steal the code from
Avalon which does just this???).
>Why not make this token attribute an attribute of copy, along with a nested
>filter element, so filtering can become more explicit in operation.
>Something like
>
><copy tokendelimiter="%" ...>
> <filter token="year" value="2000"/>
></copy>
+1
I wanted to do this for ages but am too lazy ;) Another thing that was
requested a fair bit was the notion of filtersets to allow easy resuse of
filters.
Cheers,
Pete
*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof." |
| - John Kenneth Galbraith |
*-----------------------------------------------------*
RE: [PATCH] Re: other tokens
Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
Thanks Jon and Josh.
Conor
Re: [PATCH] Re: other tokens
Posted by Josh Lucas <jo...@stonecottage.com>.
Honestly, my initial thought was how to add this 'feature' with a
minimal amount of pain.
To factor out copy functionality from Project would be great and
something which would be quite useful. I submitted this patch as a way
for this to work since I was somewhat surprised that you couldn't
specify the token.
It seems that I was a bit premature in my choice of implementation as I
would agree that Target isn't the best place for this info.
I have no problems with that patch being rolled back and I will look at
moving that functionality into the filter task though changes to Project
will be necessary.
josh
Conor MacNeill wrote:
>
> Jon,
>
> It appears that you have reformatted the files a little here - I guess that
> was intentional. Rather than wading through that, I'll assume you committed
> the patch exactly as Josh submitted it.
>
> I'm not that keen on this. The patch lets you specify a token attribute at
> the target level. What does copy filtering have to do with a target, really?
> As well, the target just sets the value on the project object. I think the
> whole copy functionality should be refactored out of Project, perhaps into
> <copy>
>
> Why not make this token attribute an attribute of copy, along with a nested
> filter element, so filtering can become more explicit in operation.
> Something like
>
> <copy tokendelimiter="%" ...>
> <filter token="year" value="2000"/>
> </copy>
>
> Of course, we would still support the current "global" filters implicitly.
>
> If we let this go ahead now, we create a backward compatibility issue later
> on.
>
> Thoughts?
>
> Conor
>
> --
> Conor MacNeill
> conor@cortexebusiness.com.au
> Cortex eBusiness
> http://www.cortexebusiness.com.au
>
> > -----Original Message-----
> > From: Jon Stevens [mailto:jon@latchkey.com]
> > Sent: Thursday, 18 January 2001 12:45
> > To: ant-dev@jakarta.apache.org
> > Subject: Re: [PATCH] Re: other tokens
> >
> >
> > on 1/17/01 5:20 PM, "Josh Lucas" <jo...@stonecottage.com> wrote:
> >
> > > here ya go...
> >
> > I just checked this in. could you also please update the index.html?
> >
> > thx.
> >
> > -jon
> >
> > --
> > Honk if you love peace and quiet.
> >
RE: [PATCH] Re: other tokens
Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
Jon,
It appears that you have reformatted the files a little here - I guess that
was intentional. Rather than wading through that, I'll assume you committed
the patch exactly as Josh submitted it.
I'm not that keen on this. The patch lets you specify a token attribute at
the target level. What does copy filtering have to do with a target, really?
As well, the target just sets the value on the project object. I think the
whole copy functionality should be refactored out of Project, perhaps into
<copy>
Why not make this token attribute an attribute of copy, along with a nested
filter element, so filtering can become more explicit in operation.
Something like
<copy tokendelimiter="%" ...>
<filter token="year" value="2000"/>
</copy>
Of course, we would still support the current "global" filters implicitly.
If we let this go ahead now, we create a backward compatibility issue later
on.
Thoughts?
Conor
--
Conor MacNeill
conor@cortexebusiness.com.au
Cortex eBusiness
http://www.cortexebusiness.com.au
> -----Original Message-----
> From: Jon Stevens [mailto:jon@latchkey.com]
> Sent: Thursday, 18 January 2001 12:45
> To: ant-dev@jakarta.apache.org
> Subject: Re: [PATCH] Re: other tokens
>
>
> on 1/17/01 5:20 PM, "Josh Lucas" <jo...@stonecottage.com> wrote:
>
> > here ya go...
>
> I just checked this in. could you also please update the index.html?
>
> thx.
>
> -jon
>
> --
> Honk if you love peace and quiet.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ant-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: ant-dev-help@jakarta.apache.org
>
>
Re: [PATCH] Re: other tokens
Posted by Jon Stevens <jo...@latchkey.com>.
on 1/17/01 5:20 PM, "Josh Lucas" <jo...@stonecottage.com> wrote:
> here ya go...
I just checked this in. could you also please update the index.html?
thx.
-jon
--
Honk if you love peace and quiet.
[PATCH] Re: other tokens
Posted by Josh Lucas <jo...@stonecottage.com>.
Jon Stevens wrote:
>
> on 1/17/01 4:48 PM, "Josh Lucas" <jo...@stonecottage.com> wrote:
>
> [good points understood and deleted]
>
> > At any rate, I adjusted Project, ProjectHelper and Target to handle this
> > and I can send the patches if wanted.
> >
> > josh
>
> please.
>
here ya go...
Index: Project.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/Project.java,v
retrieving revision 1.50
diff -u -r1.50 Project.java
--- Project.java 2001/01/03 14:18:27 1.50
+++ Project.java 2001/01/18 00:56:04
@@ -90,8 +90,8 @@
public static final String JAVA_1_2 = "1.2";
public static final String JAVA_1_3 = "1.3";
- public static final String TOKEN_START = "@";
- public static final String TOKEN_END = "@";
+ private String TOKEN_START;
+ private String TOKEN_END;
private String name;
@@ -1026,6 +1026,11 @@
public Hashtable getReferences() {
return references;
+ }
+
+ public void setToken(String token) {
+ TOKEN_START=token;
+ TOKEN_END=token;
}
protected void fireBuildStarted() {
Index: ProjectHelper.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/ProjectHelper.java,v
retrieving revision 1.45
diff -u -r1.45 ProjectHelper.java
--- ProjectHelper.java 2001/01/16 13:36:38 1.45
+++ ProjectHelper.java 2001/01/18 00:56:04
@@ -352,6 +352,7 @@
String unlessCond = null;
String id = null;
String description = null;
+ String token = null;
for (int i = 0; i < attrs.getLength(); i++) {
String key = attrs.getName(i);
@@ -369,6 +370,8 @@
id = value;
} else if (key.equals("description")) {
description = value;
+ } else if (key.equals("token")) {
+ token = value;
} else {
throw new SAXParseException("Unexpected attribute
\"" + key + "\"", locator);
}
@@ -383,6 +386,11 @@
target.setIf(ifCond);
target.setUnless(unlessCond);
target.setDescription(description);
+ if (token == null) {
+ target.setToken("@");
+ }
+ else
+ target.setToken(token);
project.addTarget(name, target);
if (id != null && !id.equals(""))
Index: Target.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/Target.java,v
retrieving revision 1.15
diff -u -r1.15 Target.java
--- Target.java 2001/01/03 14:18:27 1.15
+++ Target.java 2001/01/18 00:56:04
@@ -71,6 +71,7 @@
private Vector tasks = new Vector(5);
private Project project;
private String description = null;
+ private String token = null;
public void setProject(Project project) {
this.project = project;
@@ -80,6 +81,14 @@
return project;
}
+ public void setToken(String token) {
+ this.token = token;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
public void setDepends(String depS) {
if (depS.length() > 0) {
StringTokenizer tok =
@@ -143,6 +152,7 @@
public void execute() throws BuildException {
if (testIfCondition() && testUnlessCondition()) {
+ project.setToken(token);
Enumeration enum = tasks.elements();
while (enum.hasMoreElements()) {
Task task = (Task) enum.nextElement();
Re: other tokens
Posted by Jon Stevens <jo...@latchkey.com>.
on 1/17/01 4:48 PM, "Josh Lucas" <jo...@stonecottage.com> wrote:
[good points understood and deleted]
> At any rate, I adjusted Project, ProjectHelper and Target to handle this
> and I can send the patches if wanted.
>
> josh
please.
-jon
--
Honk if you love peace and quiet.
Re: other tokens
Posted by Josh Lucas <jo...@stonecottage.com>.
Jon Stevens wrote:
>
> on 1/17/01 3:33 PM, "Josh Lucas" <jo...@stonecottage.com> wrote:
>
> > I was wondering if there has been any discussion of allowing tokens
> > other than '@' for filtering. I looked through the archives but didn't
> > really see anything. I would assume it could be a target attribute but
> > if it's already been discussed, I don't want to work on a patch.
> >
> > thanks,
> > josh
>
> You can do this with the <replace> task. :-)
>
umm.. sort of but not really.. :)
Basically what I'm trying to do is copy files from blah.in to blah. The
.in files have tokens in them which are not '@TOKEN@' so I'd like to be
able to specify what the token is that I'm using.
By specifying the token, I could use the existing <copy> task with
filtering and everything works fine. Also, I don't have to type out
every token I want to replace like I do using <replace>.
At any rate, I adjusted Project, ProjectHelper and Target to handle this
and I can send the patches if wanted.
josh
Re: other tokens
Posted by Jon Stevens <jo...@latchkey.com>.
on 1/17/01 3:33 PM, "Josh Lucas" <jo...@stonecottage.com> wrote:
> I was wondering if there has been any discussion of allowing tokens
> other than '@' for filtering. I looked through the archives but didn't
> really see anything. I would assume it could be a target attribute but
> if it's already been discussed, I don't want to work on a patch.
>
> thanks,
> josh
You can do this with the <replace> task. :-)
-jon
--
Honk if you love peace and quiet.