Tuesday, 5 April 2016

What are the best practices for writing Ant scripts ?


Use Simple Targets
  • Each target should do a single well defined job
  • Targets that do multiple jobs should be split up into multiple targets with dependencies between them
  • Targets that do too much make the build harder to maintain
  • Library scripts need to allow targets to be overridden. This is easier when the targets perform a single job

Use Standard Targets
  • It is easier for people to use a standard set of commands
  • Developers can switch from one project to another and immediately understand how the build script works
  • Standard targets can be easily overridden in a project build file

Use Properties for Configurability
  • Properties should be defined for :
    • Any piece of information that needs to be configured
    • Any piece of information that might change
    • Any piece of information that is used in more than one place
  • Properties should be defined at the top of the build file or in a standalone properties file
  • Properties explicitly define the configurable portion of the build
  • You can provide a different version of this properties file for different :
    platforms / environments / operating systems / developers

No comments:

Post a Comment

Note: only a member of this blog may post a comment.