39
Denis Lutz/ Rake as buildmanagement tool for developers and managers Freitag, 21. Jan uar 2022 1 Rake as build management tool for developers and project managers Denis Lutz

From Ant to Rake

Embed Size (px)

Citation preview

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 1

Rake as build management tool

for developers and project managers

Denis Lutz

AgendaRake 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

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 3

Ant

We use ant in java projects

• build management

• deployments

• initial project setup / configurations

• product data load

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 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!

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 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 (!)

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 6

What is rake?

Download jruby at http://jruby.org/download

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 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!

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 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

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 9

Ant is not sufficient for what we want to do

1. 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?

Back to Hypothesis…

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 10

Ant is not sufficient for what we want to do

• build management

• deployments

• 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

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 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:

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 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?

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 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.

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 14

Ant is not sufficient for what we want to do

Rake: that’s all we wanted:

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 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…

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 ?

Ant: Here is the macrodef syntax Rake:

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 16

Ant is not sufficient for what we want to do

Rake: Watch, that’s what I want..

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 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…

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 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

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 19

Ant is not sufficient for what we want to do

• elegant

• powerful

• maintable

• easy understanble

• no external classes to do it

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 20

Ant is not sufficient for what we want to do

Why project managers should love rake?

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 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

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 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

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 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

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 24

Ant is not sufficient for what we want to do

Ruby gained a lot of popularity within the scripting languages

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 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.

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 26

Improvements we could reach by using rake

1. Setting up the project initially and for any new team member

2. Working with the project everyday

3. Deployment management

Which parts of your java project can be improved by using rake?

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 27

Improvements we could reach by using rake

1. 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!

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 28

Improvements we could reach by using rake

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?

What the a new member feels at the project setup:

How do I start this special backend / front end / solr server?

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 29

Improvements we could reach by using rake

How can we fix it? = What can be automated? = Run in one workflow?

• Git/SVN Checkout

• 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

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 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

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 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:

1. Install jruby http://jruby.org.s3.amazonaws.com/downloads/1.5.3/jruby-bin-1.5.3.zip

2. Unzip and add it to your classpath, so it works from console

3. Checkout out the trunk of the project http://yourdomain.com/svn/fromjavatoruby/trunk

4. During the checkout, you can install mysql if you don’t have it yet, create a mysql user

5. Then just call “jruby –S rake full_project_setup” , the script will guide you from there

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 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)

• Unzipping of vendor files (solr, patches) DONE

• Cofiguration files setup: user setting + default + environment DONE

• Build (starting automatically) DONE

• Database initialization (without entering the webclient) DONE

• different data imports (* n times) DONE

• other step by a cronjob (* n times) DONE

• server start up / which beanshell script should I call? DONE started, informed the user how to do it

• solr setup and startup / how should I call it, on which port is it running? (same as config step

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 33

Perfect Build: Highlights

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 34

Improvements we could reach by using rake

Demo / Case Study

The perfect Project Setup, why was that much more time and money saving?

• did the user need any project specific knowledge yet? No

• did he need to ask someone for something? No

• did he need to look up a wiki page and wait till his account on it is created? No

• even if there was a manual step we were exactly telling the user what to do at the right time

• our assumtion for now was: he works on a mac / unix system

• he had to be able to install mysql database by himself

• he should have been able to check out the project

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 35

Improvements we could reach by using rake

Why the rake integration has no risks for any java environment?

• jruby rake runs on the java virtual machine and calls the old ant tasks

• we have the old ant build.xml still inside the project

• we can go back to ant all the time, just by adding old ant targets

• jruby is used anyways if this is the official project scripting language

• so we are not introducing something new to our standard setup

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 36

Improvements: Working with the project everyday

• each developer should get familiar with the build

• the build is your source for any automation

• server starts (back end/ sorl/ front end/ any server)

• cronjob execution (instead of looking it up in a client and executing)

• repetitive data load (you work on a data load and need repetitive execution)

• any new task that can be added, is easy to add with rake

2. Working with the project everyday

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 37

Improvements: Deployment management

3. Deployment management

• granular understandable / maintable

• same advantages as for the project setup apply

• ivy integration

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 38

Conslusion

Conclusion/Suggestions

• ant => has weak points, was ok a long time, but its time to move on…

• rake => great new option to use, has a lot of synergies and is fun

• separate discussion needed for deployments strategy based on rake

• start saving money and time today

• start having smooth builds today

Denis Lutz/ Rake as buildmanagement tool for developers and managers12. April 2023 39

Thanks

Thanks

Questions?