-2

The issue that I am trying to figure out is whether it is best to keep the buildfile together with the source code, i.e. trunk and branches, or in some separate location (obviously still under SCM).

The question: (to keep in mind while reading the rest of the text) Buildfile that ensures branch re-buildability at any time (at expense of maintenance), or one that ensures latest bugfixes/improvements (to build process) are quickly used by multiple branches and different projects (at expense of backward compatibility with older branches)

It doesn't matter what we are building, or what technologies are used, but just for the sake of completeness: making a mobile application, building/packaging with ANT, using SVN for SCM.

Buildfile = instructions for your builder/compiler/packager to compile and package an application from source.

Buildfile with code

This is what we have right now. Ant's build.xml is stored alongside the main code in SVN. A number of other supporting "packaging" files (Apple's provisioning profiles and certs) are stored there as well.

Pros:

  • Single checkout from DEV perspective. When developers checkout the trunk or one of its branches, the buildfile is right there. They don't need to search for it elsewhere. A simple ant build after checkout is all they need.

  • When changes to the build/packaging process are done on trunk that require some reorganization in code (different file locations, support for compiler constants, etc), I need not worry about breaking existing branches, since each branch gets its own revision.

Cons:

  • When changes to the build/packaging process are done on trunk that improve the process and fix bugs, I now need to worry about merging those changes to all active branches, which means having to keep track of all dev/feature branches in addition to release branches.

  • No reusability. A technologically identical project, that only requires a few switches/property changes to the buildfile should be able to use identical buildfile. But because they are spread across multiple project locations (in addition to multiple branches, as from the point above), it becomes a nightmare to do a generic improvement that affects all those locations. Mainly due to the fact that no matter what, these files end up with little "patch-works" here and there, and eventually with conflicting merges and ever-so-slightly different processes that cannot be resolved without putting one of the projects on hold and modifying that process to "catch up" with the other.

Buildfile separate from code

To address the cons of the previous scenario in regards to re-using a single file and avoid a plethora of small fixes all over the place, I was thinking of keeping the build file separate. Shareable between the trunk, branches and other similar projects.

Pros:

  • Single file to modify, improve and bugfix, reusable by multiple other projects.

Cons:

  • No "single checkout" for DEVs (but it can be solved with svn externals or other linking solution

  • Breaking old/existing builds. Since there is only one version of the file now, introducing an improvement that requires code restructuring would make it incompatible with older branches. When that older branch needs to be rebuild (urgent fix to already released software), the build file will no longer work. Yes, it's solvable by getting a previous revision of the file, however:

    1. It is not directly obvious which previous revision had worked with this branch
    2. The older revision may be missing some other critical bugfixes to the build process.

Toss up question

So for me it is a toss up between making my life easier and only maintaining one file for bugfixes and improvements, and thus ensuring that projects use identical processes, latest bugfixes to the build process, etc. Or making developer's life easier by providing a single point of checkout, and ensuring branch "stability/re-buildability" because the buildfile that's checked in with the branch is guaranteed to work with that branch.

Is there a proper way for this? What is the proper way for this? Am I approaching this wrong?

Slav
  • 27,057
  • 11
  • 80
  • 104
  • I consider the build process *part* of the given code base - and hold that it should be versioned *with* the code, however the *particular* SCM allows for this. Various build tools (rake, ant, etc) can help extract the details of the process, which means that general "improvements in the process" are handled externally and are already managed as part of some DSL. – user2864740 May 01 '14 at 20:04

1 Answers1

0
  1. I would suggest tagging your code with a version number every time you build. IF you ever want to roll back to a revision , you can always create a new branch from the tag of that revision and use the build.xml from that revision

    You can also publish all your artefacts into a revision named directory. If you want to rollback you can just use the artefacts from this directory instead of going through the build process again .

  2. Your build file should always be part of your code . That way a developer can check out his/her code into an IDE and start building from there for his local testing.

  3. If you have env related configurations that are different per environment you should separate it out into a deployment configuration that is used when the code is deployed.

  4. If you want to reuse your build files across projects , you can create a master build file with macros that is fetched prior to starting a build. The only thing you need to do is override the macros in your local project if you want to override the default behaviour

Community
  • 1
  • 1
Biswajit_86
  • 3,661
  • 2
  • 22
  • 36