jQuery in Action, 2nd edition
The moose likes Ant, Maven and Other Build Tools and the fly likes using Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Reply Bookmark "using "ant" for different build environments" Watch "using "ant" for different build environments" New topic
Author

using "ant" for different build environments

Satchit Talla
Greenhorn

Joined: Nov 26, 2002
Posts: 10
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
David Duran
Ranch Hand

Joined: Feb 11, 2002
Posts: 122
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.
Glenn Opdycke-Hansen
Ranch Hand

Joined: Feb 16, 2001
Posts: 40
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-", ...


--glenn
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
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?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
David Duran
Ranch Hand

Joined: Feb 11, 2002
Posts: 122
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
bas duijzings
Ranch Hand

Joined: Apr 07, 2004
Posts: 83
use different targets for different environments and then use filters in the files where you want the variables to change
look at ant - filter


have a nice one
Fred Grott
Ranch Hand

Joined: Oct 05, 2002
Posts: 346
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!


MobileBytes blog - Sharing Technology - My Programming Knols
 
 
subject: using "ant" for different build environments
 
Threads others viewed
server specific config
Multiple Input Pages for struts
How to Forward to a Particular Page for a Particular Role ?
Loading Configuration files
how to change port 8080 for jboss 4.0
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture