SlideShare uma empresa Scribd logo
1 de 17
Building with 
Laurynas Tret jakovas 
laurynas.tret jakovas@gmail.com 
Kaunas Java User Group, 2014 1
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. 
Kaunas Java User Group, 2014 2
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. 
Kaunas Java User Group, 2014 3
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? 
Kaunas Java User Group, 2014 4
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. 
Kaunas Java User Group, 2014 5
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; 
Kaunas Java User Group, 2014 6
Building Java Projects 
• Simply include the plugin 
Kaunas Java User Group, 2014 7
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. 
Kaunas Java User Group, 2014 8
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. 
Kaunas Java User Group, 2014 9
Dependency Management 
Kaunas Java User Group, 2014 10
Source Sets 
Kaunas Java User Group, 2014 11
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. 
Kaunas Java User Group, 2014 12
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. 
Kaunas Java User Group, 2014 13
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. 
Kaunas Java User Group, 2014 14
Roadmap 
• Incremental Java compilation; 
• Persistable and much faster configuration; 
• Improved parallel execution; 
• Global cache; 
• Dependency variants; 
• Watcher mode; 
Kaunas Java User Group, 2014 15
Demo 
• Sources - https://github.com/n3ziniuka5/gradle-examples 
Kaunas Java User Group, 2014 16
Thank You! 
Laurynas Tret jakovas 
laurynas.tret jakovas@gmail.com 
Kaunas Java User Group, 2014 17

Mais conteúdo relacionado

Mais procurados (20)

Android presentation - Gradle ++
Android presentation - Gradle ++Android presentation - Gradle ++
Android presentation - Gradle ++
 
What is Jenkins | Jenkins Tutorial for Beginners | Edureka
What is Jenkins | Jenkins Tutorial for Beginners | EdurekaWhat is Jenkins | Jenkins Tutorial for Beginners | Edureka
What is Jenkins | Jenkins Tutorial for Beginners | Edureka
 
introduction to Vue.js 3
introduction to Vue.js 3 introduction to Vue.js 3
introduction to Vue.js 3
 
Jenkins tutorial
Jenkins tutorialJenkins tutorial
Jenkins tutorial
 
How to earn a black belt in Graphql testing
How to earn a black belt in Graphql testingHow to earn a black belt in Graphql testing
How to earn a black belt in Graphql testing
 
Maven ppt
Maven pptMaven ppt
Maven ppt
 
Jenkins tutorial
Jenkins tutorialJenkins tutorial
Jenkins tutorial
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - Explained
 
Interview questions
Interview questionsInterview questions
Interview questions
 
Angular
AngularAngular
Angular
 
An introduction to Maven
An introduction to MavenAn introduction to Maven
An introduction to Maven
 
Jenkins
JenkinsJenkins
Jenkins
 
Svelte
SvelteSvelte
Svelte
 
Reactjs
ReactjsReactjs
Reactjs
 
Maven Overview
Maven OverviewMaven Overview
Maven Overview
 
Hacking Jenkins
Hacking JenkinsHacking Jenkins
Hacking Jenkins
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Introduction Node.js
Introduction Node.jsIntroduction Node.js
Introduction Node.js
 
An Introduction To Jenkins
An Introduction To JenkinsAn Introduction To Jenkins
An Introduction To Jenkins
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
 

Destaque

Gradle - time for a new build
Gradle - time for a new buildGradle - time for a new build
Gradle - time for a new buildIgor Khotin
 
From Ant to Maven to Gradle a tale of CI tools for JVM
From Ant to Maven to Gradle a tale of CI tools for JVMFrom Ant to Maven to Gradle a tale of CI tools for JVM
From Ant to Maven to Gradle a tale of CI tools for JVMBucharest Java User Group
 
Gradle: The Build System you have been waiting for!
Gradle: The Build System you have been waiting for!Gradle: The Build System you have been waiting for!
Gradle: The Build System you have been waiting for!Corneil du Plessis
 

Destaque (6)

Gradle - time for a new build
Gradle - time for a new buildGradle - time for a new build
Gradle - time for a new build
 
Gradle
GradleGradle
Gradle
 
From Ant to Maven to Gradle a tale of CI tools for JVM
From Ant to Maven to Gradle a tale of CI tools for JVMFrom Ant to Maven to Gradle a tale of CI tools for JVM
From Ant to Maven to Gradle a tale of CI tools for JVM
 
Gradle: The Build System you have been waiting for!
Gradle: The Build System you have been waiting for!Gradle: The Build System you have been waiting for!
Gradle: The Build System you have been waiting for!
 
Gradle presentation
Gradle presentationGradle presentation
Gradle presentation
 
Gradle by Example
Gradle by ExampleGradle by Example
Gradle by Example
 

Semelhante a Building with Gradle

Сергей Моренец: "Gradle. Write once, build everywhere"
Сергей Моренец: "Gradle. Write once, build everywhere"Сергей Моренец: "Gradle. Write once, build everywhere"
Сергей Моренец: "Gradle. Write once, build everywhere"Provectus
 
Gradle 2.breaking stereotypes.
Gradle 2.breaking stereotypes.Gradle 2.breaking stereotypes.
Gradle 2.breaking stereotypes.Stfalcon Meetups
 
Gradle 2.Write once, builde everywhere
Gradle 2.Write once, builde everywhereGradle 2.Write once, builde everywhere
Gradle 2.Write once, builde everywhereStrannik_2013
 
Gradle.Enemy at the gates
Gradle.Enemy at the gatesGradle.Enemy at the gates
Gradle.Enemy at the gatesStrannik_2013
 
Gradle 2.Breaking stereotypes
Gradle 2.Breaking stereotypesGradle 2.Breaking stereotypes
Gradle 2.Breaking stereotypesStrannik_2013
 
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.0Eric Wendelin
 
Gradle - Build system evolved
Gradle - Build system evolvedGradle - Build system evolved
Gradle - Build system evolvedBhagwat Kumar
 
Comparison of Java Web Application Frameworks
Comparison of Java Web Application FrameworksComparison of Java Web Application Frameworks
Comparison of Java Web Application FrameworksAngelin R
 
OUG Ireland Meet-up 12th January
OUG Ireland Meet-up 12th JanuaryOUG Ireland Meet-up 12th January
OUG Ireland Meet-up 12th JanuaryBrendan Tierney
 
Getting to Walk with DevOps
Getting to Walk with DevOpsGetting to Walk with DevOps
Getting to Walk with DevOpsEklove Mohan
 
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 androidzhang ghui
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulMert Çalışkan
 
Ci jenkins maven svn
Ci jenkins maven svnCi jenkins maven svn
Ci jenkins maven svnAnkur Goyal
 

Semelhante a Building with Gradle (20)

Building with Gradle
Building with GradleBuilding with Gradle
Building with Gradle
 
Сергей Моренец: "Gradle. Write once, build everywhere"
Сергей Моренец: "Gradle. Write once, build everywhere"Сергей Моренец: "Gradle. Write once, build everywhere"
Сергей Моренец: "Gradle. Write once, build everywhere"
 
Gradle 2.breaking stereotypes.
Gradle 2.breaking stereotypes.Gradle 2.breaking stereotypes.
Gradle 2.breaking stereotypes.
 
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 2.Breaking stereotypes
Gradle 2.Breaking stereotypesGradle 2.Breaking stereotypes
Gradle 2.Breaking stereotypes
 
Gradle - Build System
Gradle - Build SystemGradle - Build System
Gradle - Build System
 
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
 
Gradle
GradleGradle
Gradle
 
Gradle - Build system evolved
Gradle - Build system evolvedGradle - Build system evolved
Gradle - Build system evolved
 
Comparison of Java Web Application Frameworks
Comparison of Java Web Application FrameworksComparison of Java Web Application Frameworks
Comparison of Java Web Application Frameworks
 
Automated Infrastructure
Automated InfrastructureAutomated Infrastructure
Automated Infrastructure
 
OUG Ireland Meet-up 12th January
OUG Ireland Meet-up 12th JanuaryOUG Ireland Meet-up 12th January
OUG Ireland Meet-up 12th January
 
Gradle
GradleGradle
Gradle
 
Maven
MavenMaven
Maven
 
Getting to Walk with DevOps
Getting to Walk with DevOpsGetting to Walk with DevOps
Getting to Walk with DevOps
 
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
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest Istanbul
 
Ci jenkins maven svn
Ci jenkins maven svnCi jenkins maven svn
Ci jenkins maven svn
 

Mais de Kaunas Java User Group

Mais de Kaunas Java User Group (12)

Smart House Based on Raspberry PI + Java EE by Tadas Brasas
Smart House Based on Raspberry PI + Java EE by Tadas BrasasSmart House Based on Raspberry PI + Java EE by Tadas Brasas
Smart House Based on Raspberry PI + Java EE by Tadas Brasas
 
Presentation
PresentationPresentation
Presentation
 
Adf presentation
Adf presentationAdf presentation
Adf presentation
 
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)Bye Bye Cowboy Coder Days! (Legacy Code & TDD)
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)
 
Flyway
FlywayFlyway
Flyway
 
Eh cache in Kaunas JUG
Eh cache in Kaunas JUGEh cache in Kaunas JUG
Eh cache in Kaunas JUG
 
Apache Lucene Informacijos paieška
Apache Lucene Informacijos paieška Apache Lucene Informacijos paieška
Apache Lucene Informacijos paieška
 
Java 8 Stream API (Valdas Zigas)
Java 8 Stream API (Valdas Zigas)Java 8 Stream API (Valdas Zigas)
Java 8 Stream API (Valdas Zigas)
 
Intro to Java 8 Closures (Dainius Mezanskas)
Intro to Java 8 Closures (Dainius Mezanskas)Intro to Java 8 Closures (Dainius Mezanskas)
Intro to Java 8 Closures (Dainius Mezanskas)
 
Kaunas JUG#1: Intro (Valdas Zigas)
Kaunas JUG#1: Intro (Valdas Zigas)Kaunas JUG#1: Intro (Valdas Zigas)
Kaunas JUG#1: Intro (Valdas Zigas)
 
Kaunas JUG#1: Java History and Trends (Dainius Mezanskas)
Kaunas JUG#1: Java History and Trends (Dainius Mezanskas)Kaunas JUG#1: Java History and Trends (Dainius Mezanskas)
Kaunas JUG#1: Java History and Trends (Dainius Mezanskas)
 
Kaunas JUG#2: Devoxx 2013 (Saulius Tvarijonas)
Kaunas JUG#2: Devoxx 2013 (Saulius Tvarijonas)Kaunas JUG#2: Devoxx 2013 (Saulius Tvarijonas)
Kaunas JUG#2: Devoxx 2013 (Saulius Tvarijonas)
 

Último

Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
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 educationjfdjdjcjdnsjd
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
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...apidays
 
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 WorkerThousandEyes
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 

Último (20)

Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
+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...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
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
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

Building with Gradle

  • 1. Building with Laurynas Tret jakovas laurynas.tret jakovas@gmail.com Kaunas Java User Group, 2014 1
  • 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. Kaunas Java User Group, 2014 2
  • 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. Kaunas Java User Group, 2014 3
  • 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? Kaunas Java User Group, 2014 4
  • 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. Kaunas Java User Group, 2014 5
  • 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; Kaunas Java User Group, 2014 6
  • 7. Building Java Projects • Simply include the plugin Kaunas Java User Group, 2014 7
  • 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. Kaunas Java User Group, 2014 8
  • 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. Kaunas Java User Group, 2014 9
  • 10. Dependency Management Kaunas Java User Group, 2014 10
  • 11. Source Sets Kaunas Java User Group, 2014 11
  • 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. Kaunas Java User Group, 2014 12
  • 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. Kaunas Java User Group, 2014 13
  • 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. Kaunas Java User Group, 2014 14
  • 15. Roadmap • Incremental Java compilation; • Persistable and much faster configuration; • Improved parallel execution; • Global cache; • Dependency variants; • Watcher mode; Kaunas Java User Group, 2014 15
  • 16. Demo • Sources - https://github.com/n3ziniuka5/gradle-examples Kaunas Java User Group, 2014 16
  • 17. Thank You! Laurynas Tret jakovas laurynas.tret jakovas@gmail.com Kaunas Java User Group, 2014 17