File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes Examples of production builds (ant or maven) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Examples of production builds (ant or maven)" Watch "Examples of production builds (ant or maven)" New topic
Author

Examples of production builds (ant or maven)

Janko Mlakar
Greenhorn

Joined: Mar 20, 2010
Posts: 7
I'm looking for examples of production build files (ant and maven). Can someone suggest where can i find them?
I need to learn by example and implement some ideas in my projects.

I'm looking for ideas/solutions for:
- automatic versioning during build period
- jar signing
- different application and log4j properties and persistence.xml files (profile for development, for test purposes, for costumers...)
- building jar, war and ear files (several depandant projects)
- ....


Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

Ant in Action


JBoss In Action
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15957
    
  19

My first rule of production builds is that unless absolutely necessary, production builds are identical to test builds. In other words, one build can construct a deployable that can be interchangeably used on both testing and production systems. All context-specific information is injected in from the outside.

I do this for several reasons.

First and foremost, the only thing more embarrassing than having a test version of a system land on a production server is having a production version running on a test machine, only to discover that the mechanisms for restricting access to production databases are also defective. I don't want to get yelled at that I should have been more careful - I'm already being careful on 20 other things, and when a panic sets in, I don't want even the possibility of forgetting to set the "production" switch on the build.

Secondly, the more of the production environment I can replicate on the test system, the easier it is to diagnose problems and provide other support.

It actually isn't that hard to make general-use products if a little care is taken in design. After all, it's just an extension of Java's "write once/run anywhere" strategy.


Customer surveys are for companies who didn't pay proper attention to begin with.
Janko Mlakar
Greenhorn

Joined: Mar 20, 2010
Posts: 7
Tim Holloway wrote:All context-specific information is injected in from the outside.


Can you please explain how you do it?

Thanks for answer.
Janko Mlakar
Greenhorn

Joined: Mar 20, 2010
Posts: 7
Peter Johnson wrote:Ant in Action


Thanks... i just got it
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15957
    
  19

Janko Mlakar wrote:
Tim Holloway wrote:All context-specific information is injected in from the outside.


Can you please explain how you do it?

Thanks for answer.


There are a number of ways. For web applications, use JDNI, for example. For stand-alone apps, you can use the "-Dname=value" command-line option to pass in the location of a configuration file if there's lots of parameters. And/or define items directly. For applets, normally I rely on the parameter tags. Mobile apps typically have some sort of datastore that can be referenced. And, of course, you can also keep options in databases and use one of the above features to point the the appropriate test or production database.

I set up one set of Unix servers with an "identity" configuration file in the /etc directory. That file described whether the machine was development, Beta Test or Production, where the default (test or production) database was, and various other features. There is, in fact a convention for app-specific config file locations for Unix machines, and, to the extent that such things are possible, it's also often used on Windows machines as well.
 
jQuery in Action, 2nd edition
 
subject: Examples of production builds (ant or maven)
 
Similar Threads
Should i move my builds from ANT to Maven?
Trying to combine ant files into one run, and have java pull information from the Manifest.
Eclipse problem
Ant-Maven Integration - Using Maven Ant tasks
how to make a .war file