buildr > ant > maven

I chose buildr as our build tool for project candlepin, primarily because I don’t care for the large amounts of XML required by maven pom files. And ant seems to have become passe with most Java projects.

On project Spacewalk, we used checkstyle to ensure the code was consistently formatted, so I wanted to do this with candlepin as well. At the moment, there isn’t an official checkstyle plugin for buildr, but it has the ability to create ant tasks (in Ruby). Here is my task to run checkstyle against the candlepin codebase.

  # CHECKSTYLE task, a Buildr plugin would be better, but this is faster
  task :checkstyle do
      ant('checkstyle') do |ant|
        rm_rf 'reports/checkstyle_report.xml'
        mkdir_p 'reports'

        ant.taskdef :resource=>"", :classpath=>Buildr.artifacts(CHECKSTYLE).each(&:invoke).map(&:name).join(File::PATH_SEPARATOR)
        ant.checkstyle :config=>"buildconf/checkstyle.xml" do
          ant.formatter :type=>'plain'
          ant.formatter :type=>'xml', :toFile=>"reports/checkstyle_report.xml"

 :key=>'javadoc.method.scope', :value=>'public'
 :key=>'javadoc.type.scope', :value=>'package'
 :key=>'javadoc.var.scope', :value=>'package'
 :key=>'javadoc.lazy', :value=>'false'
 :key=>'checkstyle.cache.file', :value=>'target/checkstyle.cache.src'
 :key=>'checkstyle.header.file', :value=>'buildconf/LICENSE.txt'

          ant.fileset :dir=>"src/main/java", :includes=>'**/*.java'

Notice the lack of XML šŸ™‚ that’s my favorite part. I think a better integration would be to write a plugin for buildr, but for now this will suffice. Now to go fix all 800 checkstyle errors I found.


One thought on “buildr > ant > maven

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s