• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

modifying source from within ant (to auto-version code)

 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've skimmed the ANT docs, but don't see a task that 'looks' like what I'm describing:
So here, we have a class that implements 'versioned', so we have to supply a method called getVersion().

The question is... is there a way to get an existing ant task to inspect the source for the ver_build String, and to auto-update the date to the current timestamp?

I vaguely am aware of using $Revision$ in CVS to accomplish versioning. But I want to be able to manually figure out the major and minor releases and have only the build number automated (and based on a timestamp, not revision numbering, which CVS uses).

FYI, for my scheme:
major -> signifigant new functionality, or a changed interface (meaning 2.x *breaks* apps that use 1.x, so not just 'enhanced')
minor -> enhancements to the interface (new methods) and bug fixes within existing methods.
build -> identifies the exact time the major.minor version was last compiled.

ANT experts help a newbie please!
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm.....

So if they're compiling and what-not on localhost, it will work, but the getVersion method would return "2.14_$Date$".

But when they "check back in" (a single task that will update CVS, compile, jar and optionally deploy) ... it will timestamp the file and the compiled version from the "check back in" task will get the actual date.

But my question still stands... what about if I'm not using CVS ?
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use ant's built-in filtering for this sort of stuff.
I keep files which need to have tokens substituted at build time in a separate parallel directory structure and do an ant "copy" operation with filtering enabled into the "real" source directory before I start the compilation.
It's easy to set up filter tokens either statically in the build file itself, from a resource such as a properties file, or from an ant variable (like the date from a TSTAMP).
Is this what you are looking for?
 
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do this in the same manner as Frank. I can post some examples if you'd like...
hth,
bear
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
'filtering' you say... hmm.....

yah, I think I might need an example.

And it would be "all" files, because I want the timestamp to basically say "someone was here and did a compile". So I'm not sure if I can 'filter' without the 'copy' from a parallel directory.
I'll look into it myself as well.. but I learn by example faster, so feel free to post a small example Bear.

And thanks.
 
Frank Carver
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And it would be "all" files, because I want the timestamp to basically say "someone was here and did a compile".
That's even easier, copy and filter the whole lot before compiling.
So I'm not sure if I can 'filter' without the 'copy' from a parallel directory.
Why is this a problem? It's part of the "zen" of Ant. Don't be afraid of copying, it's the way ant makes changes. After all, what is a compile from java source to class files if not a copy-and-transform operation?
As for an example:

Does that help ?
 
Bear Bibeault
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Frank beat me to the example! Mine wouldn't add anything that Frank's doesn't cover, so I won't post it (unless someone specifically requests it as further data).
bear
 
I got this tall by not having enough crisco in my diet as a kid. This ad looks like it had plenty of shortening:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic