· buildr

buildr - using another project's dependencies

Through my continued use of buildr on my current project one thing we wanted to do last week was to run our production code tests using some code from the test-utilities project along with its dependencies.

I thought this would be the default behaviour but it wasn’t. Looking at the documentation suggested we could achieve this by calling ‘compile.dependencies’ on the project, but from what I can tell you still need to explicitly state that you want to use the main test utilities code as well.

The following code in our buildfile does the job:

DEPENDENCY_JAR='depedency:dependency:jar:1.0' # change this to whatever the path to the dependency is
define "test.utilities" do
  compile.with DEPENDENCY_JAR

define "main.code" do
  # Some other code
  test.with project("test.utilities"), project("test.utilities").compile.dependencies

It seems a bit verbose but it achieves our objective in a cleaner way than having to repeat test-utilities dependencies when we run main.code’s tests.

I’m sure there must be an even cleaner way than this but I’m not yet aware of it!

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket