Monday, May 19, 2008

Pimp My Build - TS-5596

DISCLAIMER:
These are the tidied up notes I took from the session at the JavaOne 2008 conference in San Francisco, California. There may well be mistakes and ommissions. I will come back and correct them once the conference has completed. However my first priority is to get the information published before the backlog gets too large and swamps me. All comments welcome. Enjoy!

Matt Quail & Conor MacNeil, Atlassian

You might Learn
- Ways to improve your Ant build
- How to make your Maven build work

#1 - Use Imports and Macros
  • to import the files containing macros you are using in your build
  • means other folks can reuse (on diff projects even) your macros without knowing about their details
  • and keeps your main ant.xml clean and simple and factors out commonality
  • Tip!: add some guards in the macro to make sure stuff won't fail
  • You get:
    • A modularised build (kind of like Maven)
    • Move all the targets that don't change across your builds into an importable module
    • Import the module and override as appropriate
#2 - Use Macros and Presets

#3 - Don't build stuff you don't need
  • use ant's "uptodate" task
    • it is complex
  • invest the time to get it right in the build
  • keep you and your team productive
  • the build will remember how to do it
  • seperate it out into a macro and make its use simple
  • also use outofdate from ant-contrib
    • even better

#4 - Spice up your build
  • Show a splash screen while the build is running
    • nice and cute
  • iIf a test fails - play "blame train" audio
  • Add a splash image
    • and associate it with a sprint, scrum iteration, etc.
  • Can I do this with maven?:
    • Yup, use growler (run the output of maven through an awk script which pattern matches and push out to growlnotify script)
  • Can I use growl with ant?:
    • yup
#5 - Don't be afraid to write tasks
  • Don't seperate the team into builders and coders
    • everyone should know how the build works
    • the build should not be precious or off limits
#6 - Use Scripts
  • Ant lests you define tasks with scripts
    • e.g. in javascript (in BSF in ANT)
#7 - Use Conditional Tasks
  • Yes, you should try to be declarative but...
    • e.g. you are dependent upon the OS platform => use the "if" task
    • use the ant-contrib tasks (where "if" is from)
#8 - Don't do One-Off Analysis
  • Your build is a way to record how to do a set of complex operations
  • There are heaps of analysis tools out there - USE THEM
  • Put them in your build, in your CI, generate reports
#9 - Document Your Build
  • Ant allows you to put descriptions on all your targets
    • Add comments
    • Use the -target_name convention for private targets
      • can't be invoked from the command line
      • no its not perfect
      • yes it does work
      • its called an idiom
  • Remember your build is where you document and remember things
    • run tests
    • run the build
    • create the licence file
    • generate coverage reports
    • attach debuggers, run profilers
  • Gives newbies a leg up
  • Continuous Integration
  • Controlled build environent
  • Automated testing and reporting - its easy because its already in your build file
#10 - Maven Best Practice Tips
  • Use a remote repository proxy (e.g. apache archiva) for stability and performance
  • Create a local repository for private artefacts
    • your own artefacts
    • missing third party artitafcts
  • Create a local repository for public artefacts
    • artifacts you are making available
  • You need to manage your build infrastructure

No comments: