• 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
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

using "ant" for different build environments

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would like to know what kind of practices other developers use for building different environments like, development, certification and production. Currently I adopt using different directories under config consisting of sub directories dev, cert and prod consisting of environment related config files. Is there any better approach that I can use. If possible, please include a sample.
Thanks
 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Too bad no one ever answered this question because I'm finding myself in the same boat.
At the current moment, I use a technique borrowed from the JGuru Ant FAQ. I opted for "-prod"/"-dev" in the filename rather than as separate directories. I only do it for one configuration file, a log4j config file, so it works even though it may not be the best solution.
http://www.jguru.com/faq/view.jsp?EID=535861
But now I'm finding myself needing different code implementation (same classes) for development/production environments and that I'm not sure how to implement.
I would hate to support two types of Java classes, -dev/-prod between environments. But in my limited experience, this seems like one of the obvious solutions. This is where I wish there was a pre-processor in Java so I could do things like #DEV or #PROD and have them excluded depending on the environment the code is going to be used in.
If anyone has feedback, I sure would appreciate it.
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Satchit Talla:
I would like to know what kind of practices other developers use for building different environments like, development, certification and production. Currently I adopt using different directories under config consisting of sub directories dev, cert and prod consisting of environment related config files. Is there any better approach that I can use. If possible, please include a sample.
Thanks


We have a similar sitation, deploying code for different systems/environments. The ant script packages and customizes the application in a dist subdirectory. It also records a log file which has information of the customization that was done. Finally, the dist directory and the log file are written to a zip file that has the environment name as part of the zip file name, "-dev-", "-local-", ...
 
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 David Duran:
I would hate to support two types of Java classes, -dev/-prod between environments.


Could you make use of the Strategy design pattern?
 
David Duran
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ilja Preuss:

Could you make use of the Strategy design pattern?


Thanks Ilja. I'll read up on it because I've never heard of it
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use different targets for different environments and then use filters in the files where you want the variables to change
look at ant - filter
 
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by David Duran:
Too bad no one ever answered this question because I'm finding myself in the same boat.
At the current moment, I use a technique borrowed from the JGuru Ant FAQ. I opted for "-prod"/"-dev" in the filename rather than as separate directories. I only do it for one configuration file, a log4j config file, so it works even though it may not be the best solution.
http://www.jguru.com/faq/view.jsp?EID=535861
But now I'm finding myself needing different code implementation (same classes) for development/production environments and that I'm not sure how to implement.
I would hate to support two types of Java classes, -dev/-prod between environments. But in my limited experience, this seems like one of the obvious solutions. This is where I wish there was a pre-processor in Java so I could do things like #DEV or #PROD and have them excluded depending on the environment the code is going to be used in.
If anyone has feedback, I sure would appreciate it.


David,
Have you tireed looking at VPP? Its hosted at sourceforge.net
Its a preprocessor for java that does not alter the source code base and uses a veloctiy template/macro engine.. I us ein J2me work its very handy!
 
reply
    Bookmark Topic Watch Topic
  • New Topic