Fork me on Github s

Posts Tagged rake

Does Your Build Suck?

I have come up with a few questions you should ask yourself if your build is up to snuff. 

  • Does it take longer than 10 minutes to setup a new computer to build a project?
  • Are there only a one or two people who know how to completely setup a new computer?
  • Do builds sometimes fail on the integration server when they are passing on your development machine?
  • Do you often make cross-repository commits?
  • Does building a subproject force you to build several other subprojects?
  • Does it take longer than 2 minutes to checkout a new project and build it successfully?
  • Is it possible for other developers (or other external factors) to break your development build without checking in code?
  • Can you use any IDE with your project?

If you answered yes to any of these questions, perhaps you should spend some time refactoring your build and/or project structure.  A nasty build can be very frustrating for developers yet is an oft overlooked part of development.

Tags: , , , , , ,

1 Comment

JRuby 1.5 to provide native support for Ant

In case you haven’t heard, the next version of JRuby will provide native support for Ant.  Much like antwrap, you will be able to call ant tasks straight from Ruby.  There are some pretty good examples here, but no examples of how to get it running on your machine today.

  1. First, you will need to install Git SCM
  2. Next, create a directory, JRuby on your machine
  3. CD to that directory, and run ‘git init’
  4. Next, run ‘git pull git://github.com/jruby/jruby.git’
  5. Once it has finished downloading, you can run ‘ant’ to build it
  6. Now, just use the executable jar under bin to run the latest version of JRuby

Now get started converting those nasty ant builds to rake.

Tags: , ,

No Comments

Build & Install Ruby Gems with Rake

Are you using rake to build your gems?  Have you ever wished there were an install task to install it to your machine?  I, for one, have written something like this a few times:


desc 'Install the gem'
task :install do
  exec 'gem install pkg/goodies-0.1.gem'
end

That is pretty straightforward.  However, this will not work under JRuby on Mac where the command should be ‘jgem’.  So we can enhance it to detect the platform, and host OS:


desc 'Install the gem'
task :install do
  executable = RUBY_PLATFORM[/java/] && Config::CONFIG[/darwin/] ? 'jgem' : 'gem'
  exec "#{executable} install pkg/goodies-0.1.gem"
end

This is a little better.  I am still not comfortable with the sloppiness of building a shell command and executing it though.  It is possible to do it with strictly Ruby.  I am also going namespace it to integrate better with the GemPackageTask.  Now it will be accessed via ‘rake gem:install’


desc 'Install the gem'
namespace 'gem' do
  task :install do
    Gem::Installer.new('pkg/goodies-0.1.gem').install
  end
end

I have included this in the goodies gem 0.2, so go ahead and install it!  ‘gem install goodies’

Tags: , , ,

No Comments