Tag Archives: buildr

Thought about build infrustructure

What makes software workable?

In Java world it’s obvious that to make software workable we need to compile it and package into jar file or whatever to be deployed to your container or simply ran as desktop application.

With TDD way to develop software we got understandable necessity to compile and run automatic tests. There are different kind of tests (unit, function, integration etc) and approaches like BDD, but the main idea is to automate testing process of what you written. In terms of build there are additional steps to be done to make software ready to be deployed.

So the conclusion is to make software workable not only in Java we need a build scripts. Often build scripts are written in different language then application one, for example, Ant – XML, Buildr – Ruby, Maven – XML etc. And some times teams argue that they required some person to do the build job. But if we account several points depicted above it’s obious that build scripts are part of developing software we’re writing. And team should care about scripts. Another point to this is the ability to know something new with your build tool, infrastructure, environment configuration stuff and etc.

So let’s do your build job by yourself it’s too important to be left to someone else.

What’s new in up-coming BuildR

Сегодня заглянул в треккер проекта Buildr и по всей вероятности уже очень скоро можно будет насладится вкусностями, которые обещают включить в версию 1.4.

Итак, что же в этой версии ожидается:

  • поддержка JRuby 1.5, JMock 2.5.1, Ant 1.8.0, JUnit 4.7
  • устранена ошибка падения при работе с rubygems 1.3.6
  • include/exclude методы научились поддерживать лямбда выражения, принимать на вход таски Rake, а так же поддрежка регулярных выражений
  • улучшена поддержка Scala
  • имплементирована поддержка protobuf
  • поддержка в качестве билд-файла файлы buildfile.rb и Buildfile.rb на ряду с buildfile.

Полный список изменений можно узнать тут.

P.S. Немного рекламы – если вы используете Buildr для сборки вашего проекта и ваш проект на Java, то вооспользуйтесь екстеншеном для форматирования кода http://rubygems.org/gems/jstyler.

Jstyler v0.0.3 – code formatting extension for BuildR

There I’m going to post information related to Jstyler – code formatting extension for BuildR.
Some time ago the v0.0.3 was released and is ready to use.
The main goal of this gem is to provide functionality to perform java code formatting for buildr. I’ve made a little research but it had no luck and decided to make own extension with such functionality. But there was a requirement to not to implement whole staff by my self.  I knew there is a cool functionality built-in Eclipse, but I’d like to have it outside of IDE. After research I’ve found out a lot of libraries, but most of them were not feed my needs and I decided to concentrate my attention on functionality provided by Eclipse. That can be ran through command line, actually here you can find out how it can be configured. But this was not what I wanted also, but I believed in Eclipse “magic”.
Then I’ve tried to extract classes required to perform formatting and had a luck. Now I have a jar files to for this and my runners – 2 java classes to prepare context and invoke format action using  Eclipse classes. All that staff I packed into one jar file.
Now it’s a Ruby‘s turn…
With Ruby things were a bit complicated as I don’t know to much of this language, but have a big desire to make it closer to me. At the end I have several Ruby files with BuildR extension definition.
That’s all about pre-history of this gem.
To use this extension you need to install BuildR and gem with extension itself.
sudo gem install buildr
sudo gem install jstyler
After installation you should add several lines of code into your project build-file (buildfile).
require 'jstyler' # this is inclusion of extension's code
And if you agree with Java convention about code formatting that’s it. To perform formatting you need to run command:
buildr format
But if you are disagree with Java conventions and want to use Eclipse convention you need to define a configuration options like following:
jstyler.options[:convention] = 'eclipse'
After all if you would like to have own style you should create it in Eclipse and save under some directory, then define path to it in your buildfile like following:
jstyler.options[:config] = 'path_to_your_org.eclipse.jdt.core.prefs'
Also you can define following configuration options:
  • jstyler.options[:config]  – receives path to config file with formatting style definition (Eclipse generated).
  • jstyler.options[:verbose] – if is specified output should be more detailed

  • jstyler.options[:convention] – java or eclipse – which convention should be used if config path was not specified, by default java is used.

Those options can be defined in ~/.buildr/settings.yaml or per project folder in the build.yaml files.
Next I give you a buildfile for sample project to start with.
# Sample project buildfile
require 'jstyler' # include extension
jstyler.options[:config] = "path_to_config"
define 'testsrc' do
  # extend Jstyler::Beautify #to extend buildr only for this project
  project.version = 1.0
  project.group = 'name.webdizz.jstyler'
  compile.options.target = '1.5'
  package :jar
Source code of the gem can be find here http://github.com/webdizz/jstyler. And the gem itself http://rubygems.org/gems/jstyler
If you have any question related to gem ask here.
That’s it.
Have a fun formatting.