Archive for July, 2009

Visualize dependencies between Ant targets

  1. Get the ant2dot XSLT stylesheet.
  2. Run it using xsltproc which comes with libxml: $ xsltproc ~/software/ant2dot.xsl build.xml >
  3. Generate a picture from the GraphViz dot file: $ dot -Tpng -o build.xml.png.

The main clues about how to read it, from the ant2dot website:

1. the various TARGETS in the build script are visualized as rectangular nodes
2. the default TARGET in the script is highlighted as a node with a dashed border
3. the target DEPENDENCIES are visualized as solid edges between the nodes
4. the target DEPENDENCIES are numbered on the graph


Mailtrap with JRuby


Mailtrap, a mock SMTP server in a few lines of Ruby, doesn’t work with JRuby out of the box. One of its dependencies, the Daemons gem, uses fork which JRuby doesn’t implement as it’s not safe on the JVM:

$ mailtrap start
/work/software/jruby-1.2.0/lib/ruby/gems/1.8/gems/daemons-1.0.10/lib/daemons/daemonize.rb:103:in `safefork': fork is unsafe and disabled by default on JRuby (NotImplementedError)

My quick and dirty workaround was to simply ignore the daemon part and instantiate a non-forking instance of mailtrap running in the foreground:

$ jirb
irb(main):002:0> load 'PATH/TO/jruby/lib/ruby/gems/1.8/gems/mailtrap-0.2.1/lib/mailtrap.rb'
=> true
irb(main):003:0>'localhost', 5555, false, '/tmp/mailtrap.log')

You now have a Mailtrap running on port 5555, and see arriving messages right there in your IRB window. That should be enough for simple tests during development.