Generates an Ant build file from a Rakefile so Rake can be used from a Java IDE
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

The AntTrap Ruby Gem

A tiny Gem that can generate an Apache Ant build file from a Rakefile. This allows for a developer to work in Rake, but integrate with any tool that supports Ant. The generated build file simply calls exec on the selected Rake task.

Note: I believe this gem is broken with the latest and greatest version of Rake, but I haven't had time to investigate. I'll dig into it soon and also write up some unit tests.

Use It In Your Favorite IDE

Tested on:
IntelliJ Idea 10.5.1
NetBeans 7.0
Eclipse Indigo
Windows & Linux

Sample rakefile

require 'anttrap'

AntTrap.antproject="RakeFile #{}"
AntTrap.rake = '/usr/bin/rake'
AntTrap.rakeargs = ["-v"]

desc "The Bar task"
task :Bar do
	puts "Bar!"

desc "The Foo Task"
task :Foo do 
	puts "Hello world"

Sample Generated Ant Build File

<!-- this file is generated automatically -->
<?xml version="1.0" encoding="ASCII"?>
<project name="RakeFile Tue Aug 09 13:35:22 -0400 2011">
<target name="AntTrap" description="Generate an ant build file from this Rake file">
	<exec executable="/usr/bin/rake">
		<arg value="-v"/>
		<arg value="AntTrap"/>

<target name="Clean" description="Clean">
	<exec executable="/usr/bin/rake">
		<arg value="-v"/>
		<arg value="Clean"/>
<target name="Compile" description="Compile Java">
	<exec executable="/usr/bin/rake">
		<arg value="-v"/>
		<arg value="Compile"/>

Generating an Ant Build File

rake AntTrap

Using the Ant Build file in an IDE

Simply use the Ant build file in your favorite IDE like you always have. Each time you modify the rakefile, be sure to run "rake AntTrap" (or just run the AntTrap task from your IDE).

Whenever you the build.xml file is generated, the Ant file will need to be refreshed in your IDE. In Eclipse, right click in the Ant view and select "Refresh Buildfiles".

Compiling Multiple Java Files from Rake

see the sample rakefile


Unix: sudo gem install anttrap

Windows: gem install anttrap

Submitting an Issue

I use the GitHub issue tracker to track bugs and features. Before submitting a bug report or feature request, check to make sure it hasn't already been submitted. You can indicate support for an existing issuse by voting it up. When submitting a bug report, please include a Gist that includes a stack trace and any details that may be necessary to reproduce the bug, including your gem version, Ruby version, and operating system.


If you find this Gem useful, please send feedback to diparfitt at gmail dot com.


Copyright (c) 2011 Dave Parfitt