SlideShare a Scribd company logo
1 of 17
Building with
Laurynas Tretjakovas
laurynas.tretjakovas@gmail.com
1Kaunas Java User Group, 2014
Why Gradle?
• Ant makes you reinvent the wheel every time;
• Ant build scripts can get hard to maintain very quickly;
• Maven does not care about your project, you must make sure that your project
works well with Maven – it enforces convention;
• You must do everything “The Maven Way” or implement custom plugins;
• Gradle combines the power and flexibility of Ant with dependency management
of Ivy and conventions of Maven;
• Gradle is a programming build tool with DSL based on Groovy.
2Kaunas Java User Group, 2014
Features
• Build Java, Android, Scala, Groovy, c++ and others;
• Dependency management;
• Incremental builds;
• Task exclusion;
• Supports plugins;
• Multi-project builds;
• Hook into any build step;
• Camel case invocation – helloWorld task can be called by doing gradle hW;
• Gradle wrapper;
• HTML test reporting;
• Ant integration.
3Kaunas Java User Group, 2014
Hello World
• Gradle has two phases – configuration and execution;
• Run each task and see what gets printed out
• How would you do that with Maven?
4Kaunas Java User Group, 2014
Tasks
• Gradle has task types for most common operations;
• You can specify inputs and outputs for a task. If those haven‘t changed since last
execution, it won‘t be executed again;
• You can create your own task types by extending DefaultTask.
5Kaunas Java User Group, 2014
Task Dependencies
• shouldRunAfter is used for task ordering, not for dependencies. For example, it
can be used for running unit tests before integration tests. This may be ignored
during parallel task execution;
• mustRunAfter will never be ignored, use this for strong ordering;
6Kaunas Java User Group, 2014
Building Java Projects
• Simply include the plugin
7Kaunas Java User Group, 2014
Java Plugin Tasks
• compileJava - compiles production Java source files using javac;
• processResources - copies production resources into the production classes
directory;
• classes - assembles the production classes directory;
• compileTestJava - compiles test Java source files using javac;
• processTestResources - Copies test resources into the test classes directory;
• testClasses - Assembles the test classes directory;
• jar - Assembles the jar file;
• javadoc - Generates API documentation for the production Java source, using
Javadoc;
• test - Runs the unit tests using JUnit or TestNG.
8Kaunas Java User Group, 2014
Lifecycle Tasks
• assemble - Assembles all the archives in the project;
• check - Performs all verification tasks in the project;
• build - Performs a full build of the project (check and assemble);
• buildNeeded - Performs a full build of the project and all projects it depends on;
• buildDependents - Performs a full build of the project and all projects which
depend on it.
9Kaunas Java User Group, 2014
Dependency Management
10Kaunas Java User Group, 2014
Source Sets
11Kaunas Java User Group, 2014
Test Reporting
• Tests have XML and HTML reporting by default;
• If you have multiple test tasks, you will need a separate reporting task;
• HTML reporting includes execution time, stdout and stderr outputs.
12Kaunas Java User Group, 2014
The Gradle Wrapper
• Gradle wrapper allows developers to use gradle, without even downloading it
manually;
• Every developer will be using the same version for building and CI server won‘t
need additional configuration;
• Run wrapper task once, it will create gradle executables which you will commit
into source control;
• You can specify the version or full url.
13Kaunas Java User Group, 2014
Init Scripts
• Init scripts can be run each time before task execution;
• You can pass init scripts with -I flag or include .gradle files in
GRADLE_HOME/init.d/ directory;
• This can be useful for enterprise policies and repositories.
14Kaunas Java User Group, 2014
Roadmap
• Incremental Java compilation;
• Persistable and much faster configuration;
• Improved parallel execution;
• Global cache;
• Dependency variants;
• Watcher mode;
15Kaunas Java User Group, 2014
Demo
• Sources - https://github.com/n3ziniuka5/gradle-examples
16Kaunas Java User Group, 2014
Thank You!
Laurynas Tretjakovas
laurynas.tretjakovas@gmail.com
17Kaunas Java User Group, 2014

More Related Content

What's hot

Саша Белецкий "Continuous Delivery в продуктовой разработке"
Саша Белецкий "Continuous Delivery в продуктовой разработке"Саша Белецкий "Continuous Delivery в продуктовой разработке"
Саша Белецкий "Continuous Delivery в продуктовой разработке"
Agile Base Camp
 

What's hot (20)

Continuous Integration & Drupal
Continuous Integration & DrupalContinuous Integration & Drupal
Continuous Integration & Drupal
 
2015 05-06-elias weingaertner-docker-intro
2015 05-06-elias weingaertner-docker-intro2015 05-06-elias weingaertner-docker-intro
2015 05-06-elias weingaertner-docker-intro
 
Introduction to gradle
Introduction to gradleIntroduction to gradle
Introduction to gradle
 
How Nuxeo uses the open-source continuous integration server Jenkins
How Nuxeo uses the open-source continuous integration server JenkinsHow Nuxeo uses the open-source continuous integration server Jenkins
How Nuxeo uses the open-source continuous integration server Jenkins
 
Continuous Integration Testing Techniques to Improve Chef Cookbook Quality
Continuous Integration Testing Techniques to Improve Chef Cookbook QualityContinuous Integration Testing Techniques to Improve Chef Cookbook Quality
Continuous Integration Testing Techniques to Improve Chef Cookbook Quality
 
Ice breaker with dev ops
Ice breaker with dev opsIce breaker with dev ops
Ice breaker with dev ops
 
Continuous Development with Jenkins - Stephen Connolly at PuppetCamp Dublin '12
Continuous Development with Jenkins - Stephen Connolly at PuppetCamp Dublin '12Continuous Development with Jenkins - Stephen Connolly at PuppetCamp Dublin '12
Continuous Development with Jenkins - Stephen Connolly at PuppetCamp Dublin '12
 
Top 10 reasons to migrate to Gradle
Top 10 reasons to migrate to GradleTop 10 reasons to migrate to Gradle
Top 10 reasons to migrate to Gradle
 
The Automated Monolith
The Automated MonolithThe Automated Monolith
The Automated Monolith
 
How To Be a Java Automated Testing Superstar
How To Be a Java Automated Testing SuperstarHow To Be a Java Automated Testing Superstar
How To Be a Java Automated Testing Superstar
 
Gradle 2.breaking stereotypes.
Gradle 2.breaking stereotypes.Gradle 2.breaking stereotypes.
Gradle 2.breaking stereotypes.
 
Drupal Continuous Integration (European Drupal Days 2015)
Drupal Continuous Integration (European Drupal Days 2015)Drupal Continuous Integration (European Drupal Days 2015)
Drupal Continuous Integration (European Drupal Days 2015)
 
Cloud native development without the toil
Cloud native development without the toilCloud native development without the toil
Cloud native development without the toil
 
At Your Service: Using Jenkins in Operations
At Your Service: Using Jenkins in OperationsAt Your Service: Using Jenkins in Operations
At Your Service: Using Jenkins in Operations
 
CI and CD Across the Enterprise with Jenkins (devops.com Nov 2014)
CI and CD Across the Enterprise with Jenkins (devops.com Nov 2014)CI and CD Across the Enterprise with Jenkins (devops.com Nov 2014)
CI and CD Across the Enterprise with Jenkins (devops.com Nov 2014)
 
PuppetConf 2016: Continuous Delivery and DevOps with Jenkins and Puppet Enter...
PuppetConf 2016: Continuous Delivery and DevOps with Jenkins and Puppet Enter...PuppetConf 2016: Continuous Delivery and DevOps with Jenkins and Puppet Enter...
PuppetConf 2016: Continuous Delivery and DevOps with Jenkins and Puppet Enter...
 
Database CI/CD Pipeline
Database CI/CD PipelineDatabase CI/CD Pipeline
Database CI/CD Pipeline
 
Саша Белецкий "Continuous Delivery в продуктовой разработке"
Саша Белецкий "Continuous Delivery в продуктовой разработке"Саша Белецкий "Continuous Delivery в продуктовой разработке"
Саша Белецкий "Continuous Delivery в продуктовой разработке"
 
Migration Spring PetClinic to Quarkus
Migration Spring PetClinic to QuarkusMigration Spring PetClinic to Quarkus
Migration Spring PetClinic to Quarkus
 
Ich brauche einen Abstraktions-Layer für meine Cloud
Ich brauche einen Abstraktions-Layer für meine CloudIch brauche einen Abstraktions-Layer für meine Cloud
Ich brauche einen Abstraktions-Layer für meine Cloud
 

Similar to Building with Gradle

Gradle 2.Breaking stereotypes
Gradle 2.Breaking stereotypesGradle 2.Breaking stereotypes
Gradle 2.Breaking stereotypes
Strannik_2013
 

Similar to Building with Gradle (20)

Building with Gradle
Building with GradleBuilding with Gradle
Building with Gradle
 
Gradle 2.Write once, builde everywhere
Gradle 2.Write once, builde everywhereGradle 2.Write once, builde everywhere
Gradle 2.Write once, builde everywhere
 
Gradle.Enemy at the gates
Gradle.Enemy at the gatesGradle.Enemy at the gates
Gradle.Enemy at the gates
 
Gradle - Build System
Gradle - Build SystemGradle - Build System
Gradle - Build System
 
Gradle 2.Breaking stereotypes
Gradle 2.Breaking stereotypesGradle 2.Breaking stereotypes
Gradle 2.Breaking stereotypes
 
Gradle
GradleGradle
Gradle
 
Comparison of Java Web Application Frameworks
Comparison of Java Web Application FrameworksComparison of Java Web Application Frameworks
Comparison of Java Web Application Frameworks
 
Maven
MavenMaven
Maven
 
Gradle - Build system evolved
Gradle - Build system evolvedGradle - Build system evolved
Gradle - Build system evolved
 
Automated infrastructure
Automated infrastructureAutomated infrastructure
Automated infrastructure
 
What's new in Gradle 4.0
What's new in Gradle 4.0What's new in Gradle 4.0
What's new in Gradle 4.0
 
Automated Infrastructure
Automated InfrastructureAutomated Infrastructure
Automated Infrastructure
 
Gradle
GradleGradle
Gradle
 
OUG Ireland Meet-up 12th January
OUG Ireland Meet-up 12th JanuaryOUG Ireland Meet-up 12th January
OUG Ireland Meet-up 12th January
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest Istanbul
 
End_to_End_DevOps.pptx
End_to_End_DevOps.pptxEnd_to_End_DevOps.pptx
End_to_End_DevOps.pptx
 
Gradle,the new build system for android
Gradle,the new build system for androidGradle,the new build system for android
Gradle,the new build system for android
 
Getting to Walk with DevOps
Getting to Walk with DevOpsGetting to Walk with DevOps
Getting to Walk with DevOps
 
Oracle Developer Cloud - 소개 (신기능 포함)
Oracle Developer Cloud - 소개 (신기능 포함)Oracle Developer Cloud - 소개 (신기능 포함)
Oracle Developer Cloud - 소개 (신기능 포함)
 
Building a Continuous Delivery Pipeline With Visual Studio
Building a Continuous Delivery Pipeline With Visual StudioBuilding a Continuous Delivery Pipeline With Visual Studio
Building a Continuous Delivery Pipeline With Visual Studio
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 

Building with Gradle

  • 2. Why Gradle? • Ant makes you reinvent the wheel every time; • Ant build scripts can get hard to maintain very quickly; • Maven does not care about your project, you must make sure that your project works well with Maven – it enforces convention; • You must do everything “The Maven Way” or implement custom plugins; • Gradle combines the power and flexibility of Ant with dependency management of Ivy and conventions of Maven; • Gradle is a programming build tool with DSL based on Groovy. 2Kaunas Java User Group, 2014
  • 3. Features • Build Java, Android, Scala, Groovy, c++ and others; • Dependency management; • Incremental builds; • Task exclusion; • Supports plugins; • Multi-project builds; • Hook into any build step; • Camel case invocation – helloWorld task can be called by doing gradle hW; • Gradle wrapper; • HTML test reporting; • Ant integration. 3Kaunas Java User Group, 2014
  • 4. Hello World • Gradle has two phases – configuration and execution; • Run each task and see what gets printed out • How would you do that with Maven? 4Kaunas Java User Group, 2014
  • 5. Tasks • Gradle has task types for most common operations; • You can specify inputs and outputs for a task. If those haven‘t changed since last execution, it won‘t be executed again; • You can create your own task types by extending DefaultTask. 5Kaunas Java User Group, 2014
  • 6. Task Dependencies • shouldRunAfter is used for task ordering, not for dependencies. For example, it can be used for running unit tests before integration tests. This may be ignored during parallel task execution; • mustRunAfter will never be ignored, use this for strong ordering; 6Kaunas Java User Group, 2014
  • 7. Building Java Projects • Simply include the plugin 7Kaunas Java User Group, 2014
  • 8. Java Plugin Tasks • compileJava - compiles production Java source files using javac; • processResources - copies production resources into the production classes directory; • classes - assembles the production classes directory; • compileTestJava - compiles test Java source files using javac; • processTestResources - Copies test resources into the test classes directory; • testClasses - Assembles the test classes directory; • jar - Assembles the jar file; • javadoc - Generates API documentation for the production Java source, using Javadoc; • test - Runs the unit tests using JUnit or TestNG. 8Kaunas Java User Group, 2014
  • 9. Lifecycle Tasks • assemble - Assembles all the archives in the project; • check - Performs all verification tasks in the project; • build - Performs a full build of the project (check and assemble); • buildNeeded - Performs a full build of the project and all projects it depends on; • buildDependents - Performs a full build of the project and all projects which depend on it. 9Kaunas Java User Group, 2014
  • 11. Source Sets 11Kaunas Java User Group, 2014
  • 12. Test Reporting • Tests have XML and HTML reporting by default; • If you have multiple test tasks, you will need a separate reporting task; • HTML reporting includes execution time, stdout and stderr outputs. 12Kaunas Java User Group, 2014
  • 13. The Gradle Wrapper • Gradle wrapper allows developers to use gradle, without even downloading it manually; • Every developer will be using the same version for building and CI server won‘t need additional configuration; • Run wrapper task once, it will create gradle executables which you will commit into source control; • You can specify the version or full url. 13Kaunas Java User Group, 2014
  • 14. Init Scripts • Init scripts can be run each time before task execution; • You can pass init scripts with -I flag or include .gradle files in GRADLE_HOME/init.d/ directory; • This can be useful for enterprise policies and repositories. 14Kaunas Java User Group, 2014
  • 15. Roadmap • Incremental Java compilation; • Persistable and much faster configuration; • Improved parallel execution; • Global cache; • Dependency variants; • Watcher mode; 15Kaunas Java User Group, 2014
  • 16. Demo • Sources - https://github.com/n3ziniuka5/gradle-examples 16Kaunas Java User Group, 2014