1

I am quite new to Buildr and I am trying to get it up and running on my projects. Is there a way to debug and step through the actual script inside the »buildfile« while executed by buildr?

If yes, which IDE supports this and can this be set up?

Thanks so far!

philipp
  • 15,947
  • 15
  • 61
  • 106

2 Answers2

3

You can pass the -t / --trace flag to Buildr to trace execution, e.g.,

% buildr -t debug package

The trace flag support several (undocumented) categories to narrow down the amount of tracing to specific topics; here are some of the current ones:

-t java   # runs java in -verbose mode
-t javac  # runs javac in -verbose mode
...

If you want the entire list of topics, you can grep the source code:

$ find lib -name "*.rb" | xargs grep -E "trace\?"
lib/buildr/scala/doc.rb:        cmd_args << '-verbose' if trace?(:scaladoc)
lib/buildr/scala/doc.rb:        cmd_args = [ '-d', target, (trace?(:vscaladoc) ? '-verbose' : ''),
lib/buildr/scala/compiler.rb:      cmd_args << "-debug" if trace?(:scalac)
lib/buildr/scala/compiler.rb:      args << "-verbose" if trace?(:scalac)
lib/buildr/java/doc.rb:        cmd_args = [ '-d', target, trace?(:javadoc) ? '-verbose' : '-quiet' ]
lib/buildr/java/ecj.rb:        args << '-verbose' if trace?(:ecj)
lib/buildr/java/compiler.rb:        args << '-verbose' if trace? :javac
lib/buildr/java/compiler.rb:        cmd_args = [ trace?(:apt) ? '-verbose' : '-nowarn' ]
lib/buildr/java/external.rb:        args << '-verbose' if trace?(:javac)
lib/buildr/java/ant.rb:      options.merge!(:logger=> Logger.new(STDOUT), :loglevel=> Logger::DEBUG) if trace?(:ant)
lib/buildr/java/ant.rb:          setMessageOutputLevel((trace?(:ant) && 4) || (verbose && 2) || 0)
lib/buildr/java/emma.rb:          ant.emma :verbosity=>(trace?(:emma) ? 'verbose' : 'warning') do
lib/buildr/java/commands.rb:        options[:verbose] ||= trace?(:java)
lib/buildr/java/commands.rb:        cmd_args = [ trace?(:apt) ? '-verbose' : '-nowarn' ]
lib/buildr/java/commands.rb:        cmd_args = [ '-d', options[:output], trace?(:javadoc) ? '-verbose' : '-quiet' ]
lib/buildr/groovy/doc.rb:        cmd_args = [ '-d', target, trace?(:groovydoc) ? '-verbose' : nil ].compact
lib/buildr/groovy/compiler.rb:      options[:verbose] ||= trace?(:groovyc) if options[:verbose].nil?
lib/buildr/core/application.rb:def trace?(*category)
lib/buildr/core/test.rb:          error ex.backtrace.join("\n") if trace?
Alex Boisvert
  • 2,850
  • 2
  • 19
  • 18
  • thank you very much for this! This actually very helpful. I found a way to debug the buildfile, see my answer below, but since I am a bit new to Ruby this should be no suprise… – philipp Oct 26 '13 at 18:06
0

On the way to debug the »buildfile« I came over the general Problem of debugging ruby. I found several solutions including a aptana plugin for eclipse and more, but since I am using ruby 1.9 nothing was working properly.

Fortunately, with the help of SO, I could find this project which just works fine as it should. I feels strange a bit new to use the commandline to debug, but it works nice for the »buildfile« too, so this solution fits best for my needs.

Here is a nice little screencast that shows how to use the cli debugger and here some very useful page which helped me very much to install buildr using ruby 1.9. The line on the cli needed to finish the installation was:

sudo env JAVA_HOME=$JAVA_HOME gem install buildr
philipp
  • 15,947
  • 15
  • 61
  • 106