On my computer I have Jenkins installed for viewing analysis of code, and as I code with PHP and not Java, I use Phing instead of Ant as the build system. I run several PHP programs against the code I’ve written or auditing, and automate the creation of API documentation using DocBlox, as well as send that documentation via FTP to a docs subdomain.
I’ve refined my build file over time, but it has always been pretty much an identical file duplicated over many projects, and this wasn’t scaling well as I found the need to refine it further. Instead, I discovered the ImportTask in Phing, which meant I could have one generic build file kept outside of my project folders, and import that into each bare bones project build file and amend as necessary.
Here’s my generic build file code (obviously you may have a different set of targets and procedures you want to undertake like unit testing, deploying to git or svn, etc.):
View this code snippet on GitHub.And then each project build file is simply:
View this code snippet on GitHub.If I want to create a tweaked target for a particular project, then I can simply add that to the project build file (as per the commented-out section), and it takes precedence over the generic target of the same name. An example of this is the following, which adds a custom target when parsing the coding standards for the WordPress project, so it can exclude all of the 3rd party libraries that won’t be expected to follow the coding standards:
View this code snippet on GitHub.That default build file pulls in both a global default properties file, and a per-project properties file too, with the properties in the latter taking precedence. Here’s an example of my global default properties file:
View this code snippet on GitHub.Which leaves a typical per-project properties file down to the bare basics:
View this code snippet on GitHub.The post Phing Build File General default build file for automating a PHP project appeared first on Gary's Code.