• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Putting a version number in source code

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm working on a build process for a Java project which is part of a larger project containing Java and C++ code. I want the Java code to have access to a global version number. If I were doing this in C++ I'd compile it as "g++ -DVERSION=...", but that capability doesn't seem to exist in Java.

Instead, I'm implementing an Ant task as below. Is this the "correct" way of doing things? I haven't seen the <filter> task used this way in any of the documentation I've consulted so I'm a little concerned. I've also noticed that this won't remake the file if the version number changes. How do I get around this? Should I add a task that removes the generated file, that gets called from the scripts that build the full release?

My task is:




Thanks!
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Robert Miller:
Instead, I'm implementing an Ant task as below. Is this the "correct" way of doing things? I haven't seen the <filter> task used this way in any of the documentation I've consulted so I'm a little concerned.



Well, it's at least what we are doing, too...

I've also noticed that this won't remake the file if the version number changes. How do I get around this? Should I add a task that removes the generated file, that gets called from the scripts that build the full release?



Yes, deleting the generated file sounds like the right thing to do. I will to look what we are doing tomorow...
 
Saloon Keeper
Posts: 28121
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The "depends" task can be used to indicate dependencies.
 
Aaaaaand ... we're on the march. Stylin. Get with it tiny ad.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic