1 Rake as build management tool for developers and project managers Denis Lutz
Rake for Developers The Hyphothesis about Ant “Hello World” from Rake Ant Hypothesis proove 1 Rake for Project Managers Ant Hypothesis proove 2 Case Study “The Perfect Build” Riskmanagement 3 Improvements you can make with rake 2
3 Ant We use ant in java projects
initial project setup / configurations
product data load
4 Ant Hypothesis 1. Ant is not sufficient for what we want to do 2. We don’t use Ant often enough to learn it properly Solution: RAKE!
5 Rake What is Rake (from JRuby) ?
build management language based on ruby
domain specific language (DSL) for builds based on ruby
rake for ruby is like ant for java “the build management tool”
existing rake version in jruby
rake from jruby is able to call any other ant task or target (!)
6 What is rake? Download jruby at http://jruby.org/download
7 What is rake? Calling a core ant task… rake is a plain mapping to the ant java classes ! We can call any task or target that ant has!
8 What is rake? Create a task that is dependent on the unzip task It should create a folder and move the unzipped file into it
9 Ant is not sufficient for what we want to do Back to Hypothesis… Ant is not sufficient for what we want to do. Not anymore since we have better choices. It was created as no scripting languages were supporting java. What are we usually doing with Ant?
10 Ant is not sufficient for what we want to do
initial project setup
data load (csv, fixtures)
cron job execution
moving / copying / deleting files or directories
writing to files
processing data sets
building dependencies on coditions
11 Ant is not sufficient for what we want to do moving / copying / deleting files and directories Ant: Looks pretty simple right? Just couple lines, markup was always easy… Rake: I want to do operations as would it be in a unix environment, and rake realizes it:
12 Ant is not sufficient for what we want to do processing a data set (Array) in a loop Ant: See, for anything that a normal language has, ant has a markup version of it Ant: So you will be always fine and be able to write what you want Rake: Well lets just take a scripting language then… like ruby Rake: and by the way, can you use unique ant syntax somewhere else ouside the build scripts?
13 Ant is not sufficient for what we want to do Ant: Yea, conditions are definded on the tasks themselves, since its all about tasks.
14 Ant is not sufficient for what we want to do Rake: that’s all we wanted:
15 Ant is not sufficient for what we want to do Rake: How about some methods to don’t repeat yourself in the build? Ant: Methods??? Your kidding me right? Targets are your methods, or create a macrodef Ant: If it gets too complicated soo create your java class and call it from ant… Ant: Here is the macrodef syntax Rake: Dude, I just want a method ok? So attribute is clear … that’s what I need Whats the deal with the <element /> ? What is the <sequential/> suppose to mean? So I predefine what tasks I will call inside my new macro ? Should I always use sequential ?
16 Ant is not sufficient for what we want to do Rake: Watch, that’s what I want..
17 Ant is not sufficient for what we want to do Rake: I want to create some objects in my script… Ant: Objects??? Lets not exagerrate here ok? Ant: If its that complicated just create a custom ant task with a java class Rake: Yea, its like object orientation = elegance , so we should use it directly in the script…
18 Ant is not sufficient for what we want to do Ant: LOL, it should not be that complicated Ant: unless you really want to fly to the moon… Rake: Well lets say I have a deployment script and I deal with servers… Rake: This is what I could do with object orientation, all this in one file, within mins
19 Ant is not sufficient for what we want to do
no external classes to do it
20 Ant is not sufficient for what we want to do Why project managers should love rake?
21 Ant is not sufficient for what we want to do 2. We don’t use Ant often enough to learn it properly
We have proper ant experience only at the project setup
its mostly done by one dedicated person
everyone else is not familiar with ant and the build script
developers tend to do fast adjustments to the script using the ant api
you are good with ant if you worked with it for a longer time
the ant knowledge can not be used somewhere else
developers have no motivation to learn it properly
trivial language construtcs in ant are too complicated to remember
22 Ant is not sufficient for what we want to do Why would it be different with rake?
rake is a subset of ruby => ruby syntax
jruby can be declared as the core scripting language in each (java) project anyways
because we need ruby for: data import, front end, parsing, any scripting language tasks
the knowledge of rake ( = ruby ) is a good investment for developers
ruby is a great, simple, elegant and powerfull language
developers can do with ruby knowledge much more then with same amount of ant knowledge
23 But java has its scripting languages But java has its scripting languages.. Why don’t we use groovy, beanshell, jsr?
ruby has a bigger community then the java scripting languages (proofes on next slides)
ruby knowledge is reused much more in projects with ruby if declared as scripting language
front ends can be written in ruby on rails
ruby knowledge can be reused much more on the US market
java scripting languages = languages that are running on jvm
well, ruby runs on jvm too, so same integration as e.g. groovy
24 Ant is not sufficient for what we want to do Ruby gained a lot of popularity within the scripting languages
25 Ant is not sufficient for what we want to do Rails competes with JSF in the meanwhile, which indirectly shows the power and acceptance of the ruby language on the us market.
26 Improvements we could reach by using rake Which parts of your java project can be improved by using rake? 1. Setting up the project initially and for any new team member 2. Working with the project everyday 3. Deployment management
27 Improvements we could reach by using rake Setting up the project initially and for any new team member
setting up the system always a time consuming task
knowledge is mostly party written on the wiki and outdated
no one really knows what the project setup steps are
the older the project the more out of sync is it
the project setup takes usually the time of the new person and one team member
At the end you loose a lot of time, instead of initially investing little bit more!
28 Improvements we could reach by using rake What the a new member feels at the project setup: What database do I need? What are the database properties? Where should I configure them? Who should I ask about it? Where is the wiki page about this project? I have a windows machine, are there any differences to a macs? What should I write into my “hosts” file? How do I start this special backend / front end / solr server?
29 Improvements we could reach by using rake How can we fix it? = What can be automated? = Run in one workflow?
Local database setup (setting up mysql/oracle + create database)
Unzipping of vendor files (commercial integrated systems, solr, patches)
Cofiguration files setup: user setting + default + environment
Build (starting automatically)
Database initialization (without entering any client)
different data imports (* n times)
other step by a cronjob (* n times)
server startup (front end, back end, solr, any other server)
commercial integrated system configuration
generating data load files with ruby (just another ruby script execution
30 Improvements we could reach by using rake 1. The project itself should know about its setup, not the wiki, it will be outdated and lost 2. The only one thing that the user should do is the database installation and checkout 3. Even in the manual steps, the user should be guided by the rake script
using of rake as much a more powerful tool then ant
dedicated person in each project responsible for the build maintenance
project planned time investment for a complete project setup by a build
investment will immidiatelly pay off, with a new team member at the latest
thinking in a perspective of a beginner who has no project knowledge
thinking in a perspective of one big setup workflow without interruptions
31 Improvements we could reach by using rake Demo / Case Study The perfect project setup Hi, how are you doing? …. Yea, nice to meet you and welcome…. My manager told me to help you to setup your system You are a junior developer? Got you, you just starting, no problem You have a mac? Great…. So here is what I want you to do: Install jruby http://jruby.org.s3.amazonaws.com/downloads/1.5.3/jruby-bin-1.5.3.zip Unzip and add it to your classpath, so it works from console Checkout out the trunk of the project http://yourdomain.com/svn/fromjavatoruby/trunk During the checkout, you can install mysql if you don’t have it yet, create a mysql user Then just call “jruby –S rake full_project_setup” , the script will guide you from there
32 Improvements we could reach by using rake Demo / Case Study The perfect Project Setup, what did we do? :
SVN Checkout --> manually
Local database setup (setting up mysql/oracle + create database) (still potentially automatable)