The world of gradle  - an introduction for developers
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

The world of gradle - an introduction for developers

on

  • 747 views

This Slide Share gives you an insight in the world of Gradle. Why is it a better option than for example maven, and how to use Gradle.

This Slide Share gives you an insight in the world of Gradle. Why is it a better option than for example maven, and how to use Gradle.

Statistics

Views

Total Views
747
Views on SlideShare
735
Embed Views
12

Actions

Likes
1
Downloads
28
Comments
0

2 Embeds 12

https://twitter.com 8
http://www.slideee.com 4

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

The world of gradle - an introduction for developers Presentation Transcript

  • 1. The world of Gradle Tricode Slide Share Februari 2014 Tricode BV De Schutterij 12 -18 3905 PL Veenendaal The Netherlands tel: 0318 - 559210 fax: 0318 - 650909 www.tricode.nl info@tricode.nl
  • 2. What is Gradle? “Gradle is build automation evolved”
  • 3. Why create Gradle? What happened since Ant (2000) and Maven (2003): ● Agile Manifesto ● Continues Development ● Continues Integration ● Continues Deployment Gradle adapts these innovation in its building tool
  • 4. Why use Gradle? (2) “Gradle combines the power and flexibility of Ant with the dependency management and conventions of Maven into a more effective way to build.”
  • 5. Why use Gradle? Declarative Imperative Ant Gradle Maven
  • 6. Gradle vs. Maven Maven <!-- The smallest possible Maven POM.xml --> <project> <modelVersion>4.0.0</modelVersion> <groupId>com.tricode.academy.samples</groupId> <artifactId>sample</artifactId> <version>0.0.1-SNAPSHOT</version> </project> Gradle apply plugin: 'java'
  • 7. Maven vs. Gradle build |── classes | └── main | └── Main.class |── dependency-cache |── libs | └── maven-gradle-comparison-simple.jar |── reports | └── tests | ├── css3-pie-1.0beta3.htc | ├── index.html | ├── report.js | └── style.css |── test-results |── tmp └── jar └── MANIFEST.MF
  • 8. Gradle Tasks build.gradle task helloWorld << { println 'hello, world' } run gradle -q helloWorld output hello, world
  • 9. Available Gradle plugins Language plugins: Java ● Groovy ● Scala ● Antlr ● Integration plugins: EAR ● Maven ● OSGI ● War ●
  • 10. Gradle Plugin: Java apply plugin: 'java' Tasks: ●assemble ●build ●buildDependencies ●buildNeeded ●check ●classes ●clean ●compileJava compileTestJava ●jar ●javadoc ●processResources ●processTestResources ●test ●testClasses ●
  • 11. Dependency Management repositories { mavenCentral() mavenRepo(urls: 'http://repo.gradle.org/gradle/libs-releases-local') } Dependencies { compile 'com.google.guava:guava:15.0' testCompile group: 'junit', name: 'junit', version:'4.11+' }
  • 12. Start testing with jUnit apply plugin: 'java' repositories { mavenCentral() } dependencies { testCompile 'junit:junit:4.8.2' } test { maxParallelForks = 5 forkEvery = 50 }
  • 13. Start testing with TestNG apply plugin: 'java' repositories { mavenCentral() } test { useTestNG() } dependencies { testCompile 'org.testng:testng:6.0.1' }
  • 14. Testing test { include '**/Test*.*' } task integrationTest(type: Test, dependsOn: "test") << { include '**/IntegrationTest*.*' }
  • 15. Gradle Tasks task hello << { print 'hello, ' } hello << { println 'world' } $ gradle -q hello hello, world $
  • 16. dependsOn (Task) task hello { print 'hello, ' } task world << { dependsOn hello } world << { println 'world' }
  • 17. dependsOn (Task) task world(dependsOn: hello) { println 'world' } task world { println 'world' } world.dependsOn hello
  • 18. doFirst & doLast (closure) task hello << { println 'world' } hello.doFirst { print 'hello, ' }
  • 19. doFirst & doLast (closure) (2) task hello << { println 'world' } hello.doFirst { print 'hello, ' } hello.doFirst { print 'hi, ' }
  • 20. onlyIf (closure) task createSchema << { println 'create database schema' } task loadTestData(dependsOn: createSchema) << { println 'load test data' } loadTestData.onlyIf { System.properties['load.data'] == 'true' } $ build loadTestData :createSchema create database schema :loadTestData SKIPPED $ gradle -Dload.data=true loadTestData
  • 21. DefaultTask properties task emailMe(dependsOn: compileJava) << { if(tasks.compileJava.didWork) { println 'SEND EMAIL ANNOUNCING SUCCESS' } } task sendEmails(dependsOn: compileJava) << { println 'send emails' } sendEmails.enabled = false
  • 22. How to build Multi Projects project build.gradle apply plugin: 'java' settings.gradle include 'api', 'service' Dependency Management dependencies { compile project(':api') }
  • 23. How to build Multi Projects One build file allprojects { apply plugin: 'java' repositories { mavenCentral() } dependencies { testCompile: 'junit:junit:4.11' } } project(':service'') { dependencies { compile project(':api') } }
  • 24. How to build Multi Projects Hybrid allprojects { apply plugin: 'java' repositories { mavenCentral() } dependencies { testCompile: 'junit:junit:4.11' } }
  • 25. Upload artifacts apply plugin: 'java' apply plugin: 'maven' group = 'com.gradleware.samples' uploadArchives { repositories.mavenDeployer { repository(url: "file:///mytemprepo/") } }
  • 26. Want to know more? We suggest to read: Building and Testing with Gradle Tim Bergland ISBN-10: 144930463X ISBN-13: 978-1449304638
  • 27. Thank you for watching this slide share Follow us on: tricode.nl facebook.com/tricode linkedin.com/company/tricode slideshare.net/tricode twitter.com/tricode