ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Clifton C. Craig" <...@icsaward.com>
Subject Re: Updating Java source, JavaCC?
Date Fri, 06 Feb 2004 18:11:32 GMT
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


Mime
View raw message