You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Clifton C. Craig" <cc...@icsaward.com> on 2004/01/29 18:02:54 UTC

Updating Java source, JavaCC?

Hello all,

I have a requirement to update Java source files and insert a version
string in files that don't have one. We have a large source repository
so it would make most sense to automate this process. I've spent some
time investigating JavaCC to see if it could help me or if it would be
overkill for what I'm attempting. I noticed there is a javacc task in
Ant. It doesn't appear to have any external dependencies. I'm not even
sure which jar under ANT_HOME/lib it runs out of. Basically what I want
to do is create a Java source code parser that can update and insert
version string constants into Java classes (this includes inner classes
as well). If I didn't have the inner classes to bother with I would be
able to use our existing technologies which introspect binary .class
files to determine whether or not the version string is present and just
insert the string somewhere after the class declaration. Is what I'm
doing feasible or practical? Are there any better solutions available?

Cliff


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


Re: Updating Java source, JavaCC?

Posted by Thorbjørn Ravn Andersen <no...@c.dk>.
RADEMAKERS Tanguy wrote:

> World First: ant-users list member promotes non-ant solution ;)
>
> on a tangentially related matter, i'm trying to get ant to make me a 
> cup of coffee whilst my build is processing... any ideas?

This is quite simple if your coffee device implements htcpcp.

http://www.faqs.org/rfcs/rfc2324.html

-- 
  Thorbjoern Ravn Andersen      "...plus...Tubular Bells!"



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


Re: Updating Java source, JavaCC?

Posted by RADEMAKERS Tanguy <ta...@swift.com>.
World First: ant-users list member promotes non-ant solution ;)

on a tangentially related matter, i'm trying to get ant to make me a cup 
of coffee whilst my build is processing... any ideas?



Erik Hatcher wrote:

> JavaCC sounds way overkill (and tangential even) to what you are 
> attempting.  The <javacc> task does have a dependency on the JavaCC 
> library itself (which is not included with Ant, you must obtain it 
> yourself.).  Personally, I got fed up with the <javacc> task and just 
> use <java> to launch it.
>
> Your job sounds most suited to a little command-line scripting magic 
> using Perl, sed, awk, Ruby, or something that is made for ripping 
> through text files.
>
>     Erik
>
>
>
> On Jan 29, 2004, at 12:02 PM, Clifton C. Craig wrote:
>
>> Hello all,
>>
>> I have a requirement to update Java source files and insert a version
>> string in files that don't have one. We have a large source repository
>> so it would make most sense to automate this process. I've spent some
>> time investigating JavaCC to see if it could help me or if it would be
>> overkill for what I'm attempting. I noticed there is a javacc task in
>> Ant. It doesn't appear to have any external dependencies. I'm not even
>> sure which jar under ANT_HOME/lib it runs out of. Basically what I want
>> to do is create a Java source code parser that can update and insert
>> version string constants into Java classes (this includes inner classes
>> as well). If I didn't have the inner classes to bother with I would be
>> able to use our existing technologies which introspect binary .class
>> files to determine whether or not the version string is present and just
>> insert the string somewhere after the class declaration. Is what I'm
>> doing feasible or practical? Are there any better solutions available?
>>
>> Cliff
>>
>>
>> ---------------------------------------------------------------------
>> 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


Re: Updating Java source, JavaCC?

Posted by "Clifton C. Craig" <cc...@icsaward.com>.
Ok, I know this question probably should be on the JavaCC list but I 
need to know how to automate inserting VERSION strings into my Java 
source files. I've downloaded JavaCC and a Java 1.4 grammar. I've 
successfully generated a parser in a matter of seconds. Now, what's the 
most straight-foward way of hacking this parser to insert a version 
string only if it's missing? I need for it to dig into inner classes as 
well as regular classes. Has anyone done this before by any means?

Cliff

Clifton C. Craig wrote:

> Thanks Eric,
>
> My concern here is primarily with the precision of the text 
> replacement. While I agree that JavaCC is overkill for what I'm doing 
> I'm of the thinking that parsing a Java source file is a bit more 
> complicated than regular expression technologies. It feels like one of 
> those in between areas where I'd rather err on the side of caution due 
> to the overall complexity. Also I'm no whiz with regular expressions. 
> I feel they are cryptic, complicated, and dangerous if not used 
> correctly. This is especially true when automating Java source 
> editing. If there's an in-between solution that I'm overlooking please 
> inform me. Thank you much for pointing me to the location of the 
> JavaCC stuff. (I don't know why I could find this from the Ant docs.)
>
> Cliff
>
> Erik Hatcher wrote:
>
>> JavaCC sounds way overkill (and tangential even) to what you are 
>> attempting.  The <javacc> task does have a dependency on the JavaCC 
>> library itself (which is not included with Ant, you must obtain it 
>> yourself.).  Personally, I got fed up with the <javacc> task and just 
>> use <java> to launch it.
>>
>> Your job sounds most suited to a little command-line scripting magic 
>> using Perl, sed, awk, Ruby, or something that is made for ripping 
>> through text files.
>>
>>     Erik
>>
>>
>>
>> On Jan 29, 2004, at 12:02 PM, Clifton C. Craig wrote:
>>
>>> Hello all,
>>>
>>> I have a requirement to update Java source files and insert a version
>>> string in files that don't have one. We have a large source repository
>>> so it would make most sense to automate this process. I've spent some
>>> time investigating JavaCC to see if it could help me or if it would be
>>> overkill for what I'm attempting. I noticed there is a javacc task in
>>> Ant. It doesn't appear to have any external dependencies. I'm not even
>>> sure which jar under ANT_HOME/lib it runs out of. Basically what I want
>>> to do is create a Java source code parser that can update and insert
>>> version string constants into Java classes (this includes inner classes
>>> as well). If I didn't have the inner classes to bother with I would be
>>> able to use our existing technologies which introspect binary .class
>>> files to determine whether or not the version string is present and 
>>> just
>>> insert the string somewhere after the class declaration. Is what I'm
>>> doing feasible or practical? Are there any better solutions available?
>>>
>>> Cliff
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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


Re: Updating Java source, JavaCC?

Posted by "Clifton C. Craig" <cc...@icsaward.com>.
Thanks Eric,

My concern here is primarily with the precision of the text replacement. 
While I agree that JavaCC is overkill for what I'm doing I'm of the 
thinking that parsing a Java source file is a bit more complicated than 
regular expression technologies. It feels like one of those in between 
areas where I'd rather err on the side of caution due to the overall 
complexity. Also I'm no whiz with regular expressions. I feel they are 
cryptic, complicated, and dangerous if not used correctly. This is 
especially true when automating Java source editing. If there's an 
in-between solution that I'm overlooking please inform me. Thank you 
much for pointing me to the location of the JavaCC stuff. (I don't know 
why I could find this from the Ant docs.)

Cliff

Erik Hatcher wrote:

> JavaCC sounds way overkill (and tangential even) to what you are 
> attempting.  The <javacc> task does have a dependency on the JavaCC 
> library itself (which is not included with Ant, you must obtain it 
> yourself.).  Personally, I got fed up with the <javacc> task and just 
> use <java> to launch it.
>
> Your job sounds most suited to a little command-line scripting magic 
> using Perl, sed, awk, Ruby, or something that is made for ripping 
> through text files.
>
>     Erik
>
>
>
> On Jan 29, 2004, at 12:02 PM, Clifton C. Craig wrote:
>
>> Hello all,
>>
>> I have a requirement to update Java source files and insert a version
>> string in files that don't have one. We have a large source repository
>> so it would make most sense to automate this process. I've spent some
>> time investigating JavaCC to see if it could help me or if it would be
>> overkill for what I'm attempting. I noticed there is a javacc task in
>> Ant. It doesn't appear to have any external dependencies. I'm not even
>> sure which jar under ANT_HOME/lib it runs out of. Basically what I want
>> to do is create a Java source code parser that can update and insert
>> version string constants into Java classes (this includes inner classes
>> as well). If I didn't have the inner classes to bother with I would be
>> able to use our existing technologies which introspect binary .class
>> files to determine whether or not the version string is present and just
>> insert the string somewhere after the class declaration. Is what I'm
>> doing feasible or practical? Are there any better solutions available?
>>
>> Cliff
>>
>>
>> ---------------------------------------------------------------------
>> 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


Re: Updating Java source, JavaCC?

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
JavaCC sounds way overkill (and tangential even) to what you are 
attempting.  The <javacc> task does have a dependency on the JavaCC 
library itself (which is not included with Ant, you must obtain it 
yourself.).  Personally, I got fed up with the <javacc> task and just 
use <java> to launch it.

Your job sounds most suited to a little command-line scripting magic 
using Perl, sed, awk, Ruby, or something that is made for ripping 
through text files.

	Erik



On Jan 29, 2004, at 12:02 PM, Clifton C. Craig wrote:

> Hello all,
>
> I have a requirement to update Java source files and insert a version
> string in files that don't have one. We have a large source repository
> so it would make most sense to automate this process. I've spent some
> time investigating JavaCC to see if it could help me or if it would be
> overkill for what I'm attempting. I noticed there is a javacc task in
> Ant. It doesn't appear to have any external dependencies. I'm not even
> sure which jar under ANT_HOME/lib it runs out of. Basically what I want
> to do is create a Java source code parser that can update and insert
> version string constants into Java classes (this includes inner classes
> as well). If I didn't have the inner classes to bother with I would be
> able to use our existing technologies which introspect binary .class
> files to determine whether or not the version string is present and 
> just
> insert the string somewhere after the class declaration. Is what I'm
> doing feasible or practical? Are there any better solutions available?
>
> Cliff
>
>
> ---------------------------------------------------------------------
> 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