4F Migrating to Gradle Project

57
Migrating to Gradle @4finance, 2013

Transcript of 4F Migrating to Gradle Project

Migrating to Gradle@4finance, 2013

Agenda● Why are we migrating?● Migration Plan● How to setup development environment

○ Gradle wrapper○ Gradle lifecycle○ Importing projects into Eclipse / Idea○ How to do basic tasks ( compile, test, build)○ How to compile, test and run apps

● Continuous Integration○ Build triggers○ Deploying on Test/Stage environments○ Regression Tests○ Semantic Versioning○ Sonar Integration

● Production deployment○ Release management○ Liquibase ○ Deploying specific CMS version○ Rundeck (DeployAll job)

Why are we migrating ?

Migration plan

One-by-one, a country each day starting from 23.dec.

mvn lifecycle vs gradle lifecycle

mvn lifecycle vs gradle lifecycle (2)

Gradle wrapper on windows

Gradle wrapper on Linux

Gradle wrapper prerequisite

* JDK 1.5 or higher

Project structure

“/loans/build.gradle” - root build file “/loans/settings.gradle” - multi mod. proj. set.“/loans/gradle.properties” - properties “/loans/gradlew.[bat, sh]” - wrapper “/loans/modules/build.gradle” - submodules“/loans/gradle/*.gradle” - common gradle tasks

Importing Gradle project in Eclipse1. Clean Eclipse project definitions using “gradlew cleanEclipse” command2. Generate Eclipse projects using “gradlew eclipse” command

3. Import projects into Eclipse: File -> Import -> Existing Projects into Eclipse

3. Ensure “Search for nested projects” is selected

4. Import projects

Gradle import to IDEA

Gradle import to IDEA (2)

Gradle import to IDEA (3)

Gradle import to IDEA (4)

Gradle import to IDEA (5)

Gradle project structure

“gradle projects”

Gradle project structure (2)

Add dependency (lib.) to gradle

Add lib to “/loans/gradle/libraries.gradle”

Add dependency (lib.) to gradle (2)

Implement in sub. module

Add dependency (lib.) to gradle (3)

Gradle basic tasks : compile

“gradle modules:util:compileJava” - will compile java files to class’es

Gradle basic tasks : compile : (2)

Gradle basic tasks : compile : (3)

Gradle basic tasks : test“gradle test” -> will test ALL modules (not recommended)

“gradle modules-es:web-vivus-es:test” -> will test web module and dependent modules

-> “:modules-es:web-es:test”-> “:modules:loans-api-impl:test” -> “: x : x : ...”

Gradle basic tasks : test : (2)

Gradle basic tasks : test : (3)

Gradle basic tasks : test : (4)

Gradle basic tasks : test : (5)

Gradle basic tasks : build

“gradle modules-es:web-vivus-es:build” -> compile classes + check + create jar + run tests for all dependent modules

Gradle basic tasks : build : 2

Gradle basic tasks : build : 3

gradle dependent modules

gradle show me your muscles : how about module dependencies ?

gradle dependent modules (2)

gradle dependent modules (3)

Up to date mechanism

Gradle basic tasks : build app

“gardle modules-es:web-vivus-es:war” - produce war container

Gradle basic tasks : build and store“gradle modules-es:web-vivus-es:uploadAchives” - build [war / jar] and store in Nexus

Gradle basic tasks : run local

“gardle modules-es:web-vivus-es:run” or “gradle modules-es:web-vivus-es:jettyRunWar”

Gradle basic tasks : short naming

“gradle testEs” - test all spain modules“gradle buildEs” - build/test all spain modules“gradle deployEs” - store [cola/ web] artifacts [war/ uber-jar] on nexus

“gradle accpetUk” - run all acceptance tests

Essential gradle commands

* “gradle --help”* “gradlew“* “gradle tasks“* “gradle projects“ * “gradle dependencies“* “gradle [any module name]:[build , test]“

Essential gradle commands (2)* “gradle clean”* “gradle modules-es:web-vivus-es:run“ * “gradle modules-es:web-vivus-es:uploadArchives“

Build triggers

Deploying to Test / Stage env.

Regression Tests

Semantic versioning “MAJOR.MINOR”

1. MAJOR version when you make incompatible API changes,

2. MINOR version when you add functionality in a backwards-compatible

manner

For example : “1.61.01 - 131216063543”

* http://semver.org/

Semantic versioning (2)To change core version search “gradle.properties”

Sonar

Release management

Liquibase

Deploying specific CMS version

Rundeck (DeployAll job)

Question?