Saturday, March 15, 2008

Replacing Ant

Ant uses XML as a scripting language. It is not a valid use case for XML. How can you debug Ant script? You can only run its target and see what is a result and fix it if the result is not good.

Raven to the rescue! Raven is a build tool for Java programs based on Rake and Ruby Gems.
Raven gives you a small library of Rake tasks that you can use to compile your java classes, build a jar file, build a war file, produce javadoc, wrap the jar you built in a Gem. This effectively gives you everything you need to build Java projects, using Gems for dependencies management and Rake for scripts.

Other alternative is Buildr. Buildr is a build system for Java applications.

Wiring up Spring with JRuby

I'd like to use Spring Framework for Java development but I hate its XML configuration because the configuration is just too verbose and awkward. So what to do? Springy to the rescue! It lets you use a simple DSL based on JRuby to wire up your Spring context.

So instead of this:

<bean id="bean3" class="springy.beans.Bean3">
<constructor-arg value="${vic}">
<constructor-arg ref="bean2">
<property name="aProperty">
<list>
<ref bean="bean1"/>
<value>A String</value>
</list>
</property>
</bean>

I can use Springy's DSL:

bean :bean3, "springy.beans.Bean3" do |b|
b.new(vic, :bean2)
b.aProperty = [ :bean1, "A String" ]
end