buildr - build like you code
DESCRIPTION
Introduction presentation to Buildr as a build tool for Java/Groovy/Scala projects written in Ruby demonstrates how JVM languages projects could be built and automated using Buildr and Ruby.TRANSCRIPT
- build like you
codeIzzet Mustafayev@EPAM Systems@webdizzhttp://webdizz.name
this is me● SA at EPAM Systems
● primary skill is Java
● hands-on-coding with Ruby, Groovy and
some Scala
● passionate about agile, clean code
practices and devops movement
agenda● introduction
● why does my build tool suck?
● how does it taste?
● integration
● summary
● q&a
why does my build tool suck?
xml
try to extend...
copy-paste
performance
dependencies
how does it taste?
Buildr
follows philosophy
of Maven
with simplicity
of Ant
ruby
rake
buildr
awesome language for scripting,expressive, lightweight
tasks, files, dependencies
projects, lifecycle, artifacts, plugins
simple installation steps1. wget -c http://jruby.org.s3.amazonaws.
com/downloads/1.7.5/jruby-bin-1.7.5.zip
2. unzip jruby-bin-1.7.5.zip
3. add JRuby bin folder to PATH
4. gem install buildr
help➔ buildr help # for tasks
➔ buildr --help # for options
new project➔ buildr
build java http://goo.gl/pf669x
repositories.remote << ’http://repo1.maven.org/maven2’
define ‘junit’ do
project.version = ’4.11’
project.group = ’junit’
compile.with 'org.hamcrest:hamcrest-core:jar:1.3'
test.compile.with
package :jar
end
build scala http://goo.gl/4UQajarequire 'scala_version'
require 'buildr/scala'
require 'dependencies'
repositories.remote << 'http://repo1.maven.org/maven2'
define 'spring-scala' do
project.version = '1.0.0'
project.group = 'org.springframework.scala'
compile.options.javac = ['-feature', '-language:implicitConversions', '-
language:reflectiveCalls']
compile.with COMPILE_DEPS
test.using(:scalatest).with('org.hsqldb:hsqldb-j5:jar:2.2.4')
package :jar
end
build groovy http://goo.gl/iO1aVK
require 'buildr/groovy'
groovyVersion = '1.7.5’
Buildr::Groovy::Groovyc::REQUIRES.groovy = groovyVersion
repositories.remote << 'http://repo1.maven.org/maven2'
define 'codenarc' do
project.group = 'org.codenarc'
project.version = '0.19'
compile.from('src/main/java').with 'log4j:log4j:jar:1.2.13', 'org.gmetrics:
GMetrics:jar:0.5', “org.codehaus.groovy:groovy-all:jar:#{groovyVersion}”
compile.from('src/main/groovy').using(:groovyc).with 'junit:junit:jar:4.8.2'
package :jar
end
tests inclusion➔ test.include "com.package.*" # in
buildfile
➔ buildr test:GoodTest,WorkingTest
➔ buildr test:failed
➔ buildr test=only specific_project:test
tests exclusion➔ test.exclude ’*BadTest’, ’
*SomeOtherTest*’ # in buildfile
➔ buildr test:-BadTest
➔ buildr test=no
tests for builddefine ’some project’ do
project.version = ‘1.11’
project.group = ’company.com’
compile.with # a lot of dependencies
test.compile.with # a lot of dependencies
check package(:jar).entry(’META-INF/MANIFEST’), ’Should have
license’ do
it.should contain(/Copyright (C) 2013/)
end
end
packaging➔ package :jar # :war, :rar, :ear, :zip, :tar,
:bundle
➔ package(:jar).add project(’client’), :
type=>:jar
➔ package(:war).libs += artifacts(MYSQL)
➔ package(:war).libs -= artifacts(LOG4J)
➔ package(:jar).include _(’docs’), ’
README’
parameterisation➔ YAML - Ain't Markup Language
➔ YAML is a human friendly data serialization
standard for all programming languages
parameterisation➔ personal in ~/.buildr/settings.yaml
➔ build in build.yaml
➔ profiles in profiles.yaml
➔ buildr -e env
extension
require 'buildr'
module YourExtension
include Extension
first_time do
# Define task not specific to any project.
end before_define do |project|
# Define task for this particular project.
end after_define do |project|
# Do a job
end
end
end
class Buildr::Project
include YourExtension
end
integration with CI/CD
➔ buildr clean install
summary
pros● fast
● easy to extend
● expressive
● polyglot
● wysiwyg
cons● ruby knowledge
● pure IDE support
when to use?● need to easily tweak build/automation
● need flexibility in configuration
● need speed
● or you need something new
when not to use?● in tough time-line
● your current build is over-customized
● team does not want to learn ruby
getting started● http://buildr.apache.org/
● http://www.amazon.
com/Buildr/dp/1442160942/
● https://github.com/phoet/buildr-examples
● https://cwiki.apache.
org/confluence/display/BUILDR
q&a
Izzet Mustafayev@EPAM Systems@webdizzhttp://webdizz.name
thank you!- build
like you
code