From the Pimp My Build session by the Atlassian guys.
- Use Ant imports. The imported stuff can check for preconditions and fail cleanly using the <fail unless=”…”> tag.
- Use macros.
- Don’t build stuff you don’t need using the <uptodate> task. Use <outofdate> from ant-contrib, which is even better.
- You can use audio snippets to tell you when you screw it all up 🙂
- You can filter messages in builds using the Unix shell to notify you of actually important stuff rather than the standard boiler plate.
- Don’t be afraid to write tasks – everyone should know how the build works. Don’t be precious about it. If you have repetitive tasks, why not script it?
- Use scripts. You can embed Javascript directly into your Ant build via a <[CDATA[..]]> block
- Use conditional tasks (ant-contrib) <if> <then> <else>
- Don’t do one-off analysis. PMD, Checkstyle and Findbugs can be scripted! I found this to be particularly useful. Much easier to find issues, especially if coupled with continuous integration.
- Document your build! Ant targets have descriptions. You do it with your code, why not your build artefacts? Use the -target_name convention for private targets.
- Use continuous integration. This has been an absolute life changing thing for me as a developer.
- Test in your builds!!! JUnit, TestNG et al.
- Maven tips:
- Use a remote repository proxy – caches are good (Apache Archiva). Helps performance and stability – make sure you can run when the net goes down.
- Create a local repository for private artifacts
- Local repository for public artifacts – third party Jars or commercial stuff not available in public repositories
Oh yeah, Ivy is good when you aren’t using Maven.