SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Downloaden Sie, um offline zu lesen
Gradle for Beginners
Coding Serbia, 18.10.2013
Joachim Baumann
Gradle for Beginners

• 

Build-Management
–  Needs
–  Wishes

• 

Gradle - Basics

• 

Conguration and Execution Phase

• 

Groovy – Short Overview

• 

Plug-ins – Basics

• 

Our
– 
– 
– 
– 
– 
– 

First Project
Directory Structure
Dependencies
Manipulating the Jar
Tests
Quality Assurance
Publishing the Artefacts
What do we need from a Build-Management System?
• 
• 
• 
• 
• 

• 
• 
• 
• 
• 

Translating the Source Code (using a compiler)
Linking the Results
Check out the source code from a repository (optional)
Creating Tags (optional)
Execution of different types of tests: Examples:
–  Unit Tests for single Classes
–  Module or Component Tests
–  Integration Tests
–  Functional and Non-Functional System Tests
–  Automated Acceptance Tests
Detailed Test Reports combining all Test Results (optional)
Packing the Result (e.g., into a Jar, War or Ear)
Transfer the Results to the different Stages / Test Systems and Execution of
the respective Tests (optional)
Support for multi-language Projects
Creation of Documentation and Release Notes
What do we wish for in our Build-Management System?
•  Explicit Support of the Workflow implemented by the BuildManagement-System
•  Simple Modifiability and Extensibility of the Workflow to adapt to
local processes
•  Readability and self-documentation of the notation in the build
script
•  Use of sensible conventions (e.g., where to find the sources)
•  Simple change of the conventions to adap to local environment
•  Incremental Build that can identify artefacts that have already
been built
•  Parallelisation of independent steps in the workflow to minimize
waiting
•  Programmatic access to all artefacts being created by the build
•  Status reports that summarize the current state of the build
Gradle - Basics
• 

Gradle uses build scripts which are named build.gradle

• 

Every build script is a Groovy script

• 

Two very important Principles
–  Convention over Configuration
–  Don’t Repeat Yourself

• 

Gradle creates a dynamic model of the workflow as a Directed Acyclic Graph
(DAG)

• 

(Nearly) Everything is convention and can be changed

tset

tseTelipmoc

dliub

elipmoc
elbmessa
Conguration Phase
• 
• 

• 
• 

Executes the build script
The contained Groovy- and DSL-commands congure the underlying
object tree
The root of the object tree is the Project object
–  Is directly available in the script (methods and properties)
Creation of new Tasks that can be used
Manipulation of the DAG

• 

Our rst script build.gradle

• 

println ”Hello from the configuration phase"
Execution Phase
• 

Executes all tasks that have been called (normally on the command line)

• 

For a task that is executed every task it depends on is executed beforehand

• 

Gradle uses the DAG to identify all task relationships

tset

tseTelipmoc

dliub

elipmoc
elbmessa
Task Denition
• 
• 

Takes an (optional) conguration closure
Alternatively: can be congured directly

• 
• 

The operator << (left-shift) appends an action (a closure) to this task’s list of actions
Equivalent to doLast()

• 

Insert at the beginning of the list with doFirst()
task halloTask
halloTask.doLast { print "from the " }
halloTask << { println "execution phase" }
halloTask.doFirst { print "Hello " }
task postHallo (dependsOn: halloTask) << {
println "End"
}
postHallo { // configuration closure
dependsOn halloTask
}
Groovy – Short Overview
• 

Simplied Java Syntax
–  Semicolon optional
–  GString
–  Everything is an Object
–  Simplification e.g., “println”

• 

Scripts

• 

Operator Overloading
–  Predefined
•  Example <<
•  Operator for secure navigation a.?b
–  You can provide your own implementations

• 

Named Parameters

• 

Closures

• 

Collection Iterators
Plug-ins - Basics
• 

Plug-ins encapsulate functionality

• 

Can be written in any VM-language
–  Groovy is a good choice

• 

Possible Plug-in Sources
–  Plug-ins packed with Gradle
–  Plug-ins included using URLs (don’t do it)
–  Plug-ins provided by repositories (use your own repository)
–  Self-written Plug-ins (normally in the directory buildSrc)

• 

Plug-ins
–  Extend objects
–  Provide new objects and / or abstractions
–  Configure existing objects

• 

Plug-ins are load with the command apply plugin
apply plugin: ‘java’
Our rst Project

• 

We use the Java Plug-in

• 

Default paths used by the
Java Plug-in
–  Derived from Maven
Conventions
The Class HelloWorld

package de.gradleworkshop;
import java.util.ArrayList;
import java.util.List;
public class HelloWorld {
public static void main(String[] args) {
HelloWorld hw = new HelloWorld();
for(String greeting : hw.generateGreetingsData())
System.out.println(greeting);
}
public List<String> generateGreetingsData() {
List <String> greetings = new ArrayList <String>();
greetings.add("Hallo Welt");
return greetings;
}
}
Manipulation of the Manifest
• 

Every Jar-Archive contains a le MANIFEST.MF

• 

Is generated by Gradle (see directory build/tmp/jar/MANIFEST.MF)

• 

Contains information e.g., about the main class of the jar

• 

Can be changed
jar {

manifest {
attributes 'Main-Class':
'de.gradleworkshop.HelloWorld'
}
}
• 

Alternatively
jar.manifest.attributes 'Main-Class':
'de.gradleworkshop.HelloWorld'
Tests
package de.gradleworkshop;
import java.util.List;
import org.junit.*;
import static org.junit.Assert.*;
public class HelloWorldTest {
HelloWorld oUT;
@Before
public void setUp() {
oUT = new HelloWorld();
}
@Test
public void testGenerateGreetingsData() {
List<String> res = oUT.generateGreetingsData();
assertEquals("wrong number of results", 1, res.size());
}
}
Congurations and Dependencies
• 

Gradle denes Conguration Objects. These encapsulate
–  Dependency Information
–  Paths to Sources and Targets
–  Associated Artefacts
–  Additional Configuration Information

• 

Tasks use these Congurations

• 

For most pre-dened Task a Conguration exists
–  compile, testCompile, runtime, testRuntime

• 
• 

Dependencies are dened using the key word dependencies
Maven-like notation for the dependencies
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.+’
}
Repositories
• 

Repositories provide libraries (normally jar archives)

• 

You can dene Ivy or Maven Repositories, both public and private

• 

Predened Repositories
–  JCenter
–  Maven Central
–  Local Maven Repository (~/.m2/repository)

• 

Repositories are dened using the keyword repositories
repositories {
mavenLocal()
}
repositories {
jcenter()
mavenCentral()
}

• 

Multiple Repositories can be dened
The Application Plug-in
• 

The Application-Plug-in
–  Adds a Task run
–  Creates start scripts, that can be used with the Task run
–  Creates a Task distZip, that packs all necessary files into a ziparchive
–  Definition of the Main Class
mainClassName = "de.gradleworkshop.HelloWorld"
–  Usage with
apply plugin: 'application'
Using TestNG
• 

Very Simple

dependencies {
testCompile group: 'org.testng', name: 'testng',
version: '6.+'
}
test {
useTestNG()
}
Test Class for TestNG
package de.gradleworkshop;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.*;
public class TestHelloWorld {
HelloWorld oUT;
@BeforeTest
public void setUp() {
oUT = new HelloWorld();
}
@Test
public void testGenerateGreetingsData() {
List<String> res = oUT.generateGreetingsData();
assertEquals("Wrong Number of Entries", 1, res.size());
}
}
Quality Assurance
• 

Support for PMD, Checkstyle, Findbugs, Emma, Sonar …

• 

Example PMD
apply plugin: 'pmd'
pmdMain {
ruleSets = [ "basic", "strings" ]
ignoreFailures = true
}

• 

Another Example conguring all Tasks of Type Pmd using withType()
tasks.withType(Pmd) {
ruleSets = [ "basic", "strings" ]
ignoreFailures = true
ruleSetFiles = files('config/pmd/rulesets.xml')
reports {
xml.enabled false
html.enabled true
}
}
Publishing the Artefacts
• 

Gradle denes for every Conguration a Task upload<Conguration>
–  Builds and publishes the Artefact belonging to the Configuration

• 

The Java-Plug-in creates a Conguration archives, which contains all artefacts
created in the Task jar
–  uploadArchives is the natural choice for publishing the artefacts

• 

Use of the Maven-Plug-in with apply plugin: ‘maven’
–  Doesn’t use the normal repository (intentionally)
apply plugin: 'maven'
version = '0.1-SNAPSHOT'
group = 'de.gradleworkshop'
uploadArchives {
repositories {
flatDir { dirs "repo" }
mavenDeployer { repository
(url : "file://$projectDir/mavenRepo/") }
}
}
The whole Script (less than 20 lines)
apply plugin: 'java'
apply plugin: 'pmd'
jar.manifest.attributes 'Main-Class': 'de.gradleworkshop.HelloWorld'
pmdMain {
ruleSets = [ "basic", "strings" ]
ignoreFailures = true
}
repositories { mavenCentral() }
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.+'
}
apply plugin: ‘maven’
version = '0.1-SNAPSHOT’
group = 'de.gradleworkshop’
uploadArchives {
repositories {
flatDir { dirs "repo" }
mavenDeployer { repository (url : "file:///gradleWS/myRepo/")
} } }
Recap
• 

We have, with Gradle
–  Built an Application
–  Created Tests and executed them
–  Used an alternative Test Framework TestNG
–  Used Quality Assurance
–  Uploaded the Artefacts into two Repositories

• 

You now know everything to build normal Projects with Gradle

• 

Gradle
–  Is simple
–  Easily understood
–  Has sensible conventions
–  That can be easily changed

• 

Gradle adapts to your needs
Questions?

Dr. Joachim Baumann
codecentric AG
An der Welle 4
60322 Frankfurt
Joachim.Baumann@codecentric.de
www.codecentric.de
blog.codecentric.de

24	
  

Weitere ähnliche Inhalte

Was ist angesagt?

Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle IntroductionDmitry Buzdin
 
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...ZeroTurnaround
 
Basic Gradle Plugin Writing
Basic Gradle Plugin WritingBasic Gradle Plugin Writing
Basic Gradle Plugin WritingSchalk CronjĂŠ
 
Gradle - time for another build
Gradle - time for another buildGradle - time for another build
Gradle - time for another buildIgor Khotin
 
Gradle plugins, take it to the next level
Gradle plugins, take it to the next levelGradle plugins, take it to the next level
Gradle plugins, take it to the next levelEyal Lezmy
 
In the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: GradleIn the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: GradleSkills Matter
 
SBT Crash Course
SBT Crash CourseSBT Crash Course
SBT Crash CourseMichal Bigos
 
Scala and Play with Gradle
Scala and Play with GradleScala and Play with Gradle
Scala and Play with GradleWei Chen
 
NetBeans Support for EcmaScript 6
NetBeans Support for EcmaScript 6NetBeans Support for EcmaScript 6
NetBeans Support for EcmaScript 6Kostas Saidis
 
Simple Build Tool
Simple Build ToolSimple Build Tool
Simple Build ToolDavid Galichet
 
Idiomatic gradle plugin writing
Idiomatic gradle plugin writingIdiomatic gradle plugin writing
Idiomatic gradle plugin writingSchalk CronjĂŠ
 
Gradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 versionGradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 versionSchalk CronjĂŠ
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingSchalk CronjĂŠ
 
Managing dependencies with gradle
Managing dependencies with gradleManaging dependencies with gradle
Managing dependencies with gradleLiviu Tudor
 
Using the Groovy Ecosystem for Rapid JVM Development
Using the Groovy Ecosystem for Rapid JVM DevelopmentUsing the Groovy Ecosystem for Rapid JVM Development
Using the Groovy Ecosystem for Rapid JVM DevelopmentSchalk CronjĂŠ
 
Cool JVM Tools to Help You Test
Cool JVM Tools to Help You TestCool JVM Tools to Help You Test
Cool JVM Tools to Help You TestSchalk CronjĂŠ
 
うさぎ組 in G* WorkShop -うさみみの日常-
うさぎ組 in G* WorkShop -うさみみの日常-うさぎ組 in G* WorkShop -うさみみの日常-
うさぎ組 in G* WorkShop -うさみみの日常-kyon mm
 

Was ist angesagt? (20)

Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle Introduction
 
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
 
Basic Gradle Plugin Writing
Basic Gradle Plugin WritingBasic Gradle Plugin Writing
Basic Gradle Plugin Writing
 
Gradle - time for another build
Gradle - time for another buildGradle - time for another build
Gradle - time for another build
 
Gradle plugins, take it to the next level
Gradle plugins, take it to the next levelGradle plugins, take it to the next level
Gradle plugins, take it to the next level
 
In the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: GradleIn the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: Gradle
 
SBT Crash Course
SBT Crash CourseSBT Crash Course
SBT Crash Course
 
Gradle como alternativa a maven
Gradle como alternativa a mavenGradle como alternativa a maven
Gradle como alternativa a maven
 
Scala and Play with Gradle
Scala and Play with GradleScala and Play with Gradle
Scala and Play with Gradle
 
NetBeans Support for EcmaScript 6
NetBeans Support for EcmaScript 6NetBeans Support for EcmaScript 6
NetBeans Support for EcmaScript 6
 
Simple Build Tool
Simple Build ToolSimple Build Tool
Simple Build Tool
 
Idiomatic gradle plugin writing
Idiomatic gradle plugin writingIdiomatic gradle plugin writing
Idiomatic gradle plugin writing
 
Gradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 versionGradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 version
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin Writing
 
Managing dependencies with gradle
Managing dependencies with gradleManaging dependencies with gradle
Managing dependencies with gradle
 
Building with Gradle
Building with GradleBuilding with Gradle
Building with Gradle
 
Using the Groovy Ecosystem for Rapid JVM Development
Using the Groovy Ecosystem for Rapid JVM DevelopmentUsing the Groovy Ecosystem for Rapid JVM Development
Using the Groovy Ecosystem for Rapid JVM Development
 
Cool JVM Tools to Help You Test
Cool JVM Tools to Help You TestCool JVM Tools to Help You Test
Cool JVM Tools to Help You Test
 
Gradle
GradleGradle
Gradle
 
うさぎ組 in G* WorkShop -うさみみの日常-
うさぎ組 in G* WorkShop -うさみみの日常-うさぎ組 in G* WorkShop -うさみみの日常-
うさぎ組 in G* WorkShop -うさみみの日常-
 

Ähnlich wie Gradle For Beginners (Serbian Developer Conference 2013 english)

Oscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneOscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneAndres Almiray
 
Boosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with GroovyBoosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with GroovyJames Williams
 
Javaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 GroovytestingJavaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 GroovytestingAndres Almiray
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFXHendrik Ebbers
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVMSylvain Wallez
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT studentsPartnered Health
 
Practical Glusto Example
Practical Glusto ExamplePractical Glusto Example
Practical Glusto ExampleGluster.org
 
ITB_2023_CommandBox_Task_Runners_Brad_Wood.pdf
ITB_2023_CommandBox_Task_Runners_Brad_Wood.pdfITB_2023_CommandBox_Task_Runners_Brad_Wood.pdf
ITB_2023_CommandBox_Task_Runners_Brad_Wood.pdfOrtus Solutions, Corp
 
Testing basics for developers
Testing basics for developersTesting basics for developers
Testing basics for developersAnton Udovychenko
 
Improving your Gradle builds
Improving your Gradle buildsImproving your Gradle builds
Improving your Gradle buildsPeter Ledbrook
 
Refactoring In Tdd The Missing Part
Refactoring In Tdd The Missing PartRefactoring In Tdd The Missing Part
Refactoring In Tdd The Missing PartGabriele Lana
 
2014 International Software Testing Conference in Seoul
2014 International Software Testing Conference in Seoul2014 International Software Testing Conference in Seoul
2014 International Software Testing Conference in SeoulJongwook Woo
 
Make Your Build Great Again (DroidConSF 2017)
Make Your Build Great Again (DroidConSF 2017)Make Your Build Great Again (DroidConSF 2017)
Make Your Build Great Again (DroidConSF 2017)Jared Burrows
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestSeb Rose
 
Svcc Groovy Testing
Svcc Groovy TestingSvcc Groovy Testing
Svcc Groovy TestingAndres Almiray
 
"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James Nelson"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James NelsonGWTcon
 

Ähnlich wie Gradle For Beginners (Serbian Developer Conference 2013 english) (20)

Oscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneOscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast Lane
 
Boosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with GroovyBoosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with Groovy
 
Javaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 GroovytestingJavaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 Groovytesting
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFX
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVM
 
Why Gradle?
Why Gradle?Why Gradle?
Why Gradle?
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
 
Practical Glusto Example
Practical Glusto ExamplePractical Glusto Example
Practical Glusto Example
 
ITB_2023_CommandBox_Task_Runners_Brad_Wood.pdf
ITB_2023_CommandBox_Task_Runners_Brad_Wood.pdfITB_2023_CommandBox_Task_Runners_Brad_Wood.pdf
ITB_2023_CommandBox_Task_Runners_Brad_Wood.pdf
 
Testing basics for developers
Testing basics for developersTesting basics for developers
Testing basics for developers
 
Improving your Gradle builds
Improving your Gradle buildsImproving your Gradle builds
Improving your Gradle builds
 
Refactoring In Tdd The Missing Part
Refactoring In Tdd The Missing PartRefactoring In Tdd The Missing Part
Refactoring In Tdd The Missing Part
 
2014 International Software Testing Conference in Seoul
2014 International Software Testing Conference in Seoul2014 International Software Testing Conference in Seoul
2014 International Software Testing Conference in Seoul
 
Make Your Build Great Again (DroidConSF 2017)
Make Your Build Great Again (DroidConSF 2017)Make Your Build Great Again (DroidConSF 2017)
Make Your Build Great Again (DroidConSF 2017)
 
Dart Workshop
Dart WorkshopDart Workshop
Dart Workshop
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under Test
 
Svcc Groovy Testing
Svcc Groovy TestingSvcc Groovy Testing
Svcc Groovy Testing
 
Mastering Java ByteCode
Mastering Java ByteCodeMastering Java ByteCode
Mastering Java ByteCode
 
Enter the gradle
Enter the gradleEnter the gradle
Enter the gradle
 
"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James Nelson"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James Nelson
 

Mehr von Joachim Baumann

Erfahrungen mit agilen Festpreisen
Erfahrungen mit agilen FestpreisenErfahrungen mit agilen Festpreisen
Erfahrungen mit agilen FestpreisenJoachim Baumann
 
"Agilität, Unternehmen und Menschen." ErÜffnungs-Keynote der "Embedded Meets ...
"Agilität, Unternehmen und Menschen." ErÜffnungs-Keynote der "Embedded Meets ..."Agilität, Unternehmen und Menschen." ErÜffnungs-Keynote der "Embedded Meets ...
"Agilität, Unternehmen und Menschen." ErÜffnungs-Keynote der "Embedded Meets ...Joachim Baumann
 
ErĂśffnungs-Keynote der Manage Agile 2014
ErĂśffnungs-Keynote der Manage Agile 2014ErĂśffnungs-Keynote der Manage Agile 2014
ErĂśffnungs-Keynote der Manage Agile 2014Joachim Baumann
 
Integration agiler und klassischer Vorgehensweisen (Embedded-Meets-Agile 18.2...
Integration agiler und klassischer Vorgehensweisen (Embedded-Meets-Agile 18.2...Integration agiler und klassischer Vorgehensweisen (Embedded-Meets-Agile 18.2...
Integration agiler und klassischer Vorgehensweisen (Embedded-Meets-Agile 18.2...Joachim Baumann
 
Introduction to Groovy (Serbian Developer Conference 2013)
Introduction to Groovy (Serbian Developer Conference 2013)Introduction to Groovy (Serbian Developer Conference 2013)
Introduction to Groovy (Serbian Developer Conference 2013)Joachim Baumann
 
Gradle - Beginner's Workshop (german)
Gradle - Beginner's Workshop (german)Gradle - Beginner's Workshop (german)
Gradle - Beginner's Workshop (german)Joachim Baumann
 
Warum agile Organisationen?
Warum agile Organisationen?Warum agile Organisationen?
Warum agile Organisationen?Joachim Baumann
 

Mehr von Joachim Baumann (8)

Multi speed IT
Multi speed ITMulti speed IT
Multi speed IT
 
Erfahrungen mit agilen Festpreisen
Erfahrungen mit agilen FestpreisenErfahrungen mit agilen Festpreisen
Erfahrungen mit agilen Festpreisen
 
"Agilität, Unternehmen und Menschen." ErÜffnungs-Keynote der "Embedded Meets ...
"Agilität, Unternehmen und Menschen." ErÜffnungs-Keynote der "Embedded Meets ..."Agilität, Unternehmen und Menschen." ErÜffnungs-Keynote der "Embedded Meets ...
"Agilität, Unternehmen und Menschen." ErÜffnungs-Keynote der "Embedded Meets ...
 
ErĂśffnungs-Keynote der Manage Agile 2014
ErĂśffnungs-Keynote der Manage Agile 2014ErĂśffnungs-Keynote der Manage Agile 2014
ErĂśffnungs-Keynote der Manage Agile 2014
 
Integration agiler und klassischer Vorgehensweisen (Embedded-Meets-Agile 18.2...
Integration agiler und klassischer Vorgehensweisen (Embedded-Meets-Agile 18.2...Integration agiler und klassischer Vorgehensweisen (Embedded-Meets-Agile 18.2...
Integration agiler und klassischer Vorgehensweisen (Embedded-Meets-Agile 18.2...
 
Introduction to Groovy (Serbian Developer Conference 2013)
Introduction to Groovy (Serbian Developer Conference 2013)Introduction to Groovy (Serbian Developer Conference 2013)
Introduction to Groovy (Serbian Developer Conference 2013)
 
Gradle - Beginner's Workshop (german)
Gradle - Beginner's Workshop (german)Gradle - Beginner's Workshop (german)
Gradle - Beginner's Workshop (german)
 
Warum agile Organisationen?
Warum agile Organisationen?Warum agile Organisationen?
Warum agile Organisationen?
 

KĂźrzlich hochgeladen

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...apidays
 
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
 
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
 
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
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
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 TerraformAndrey Devyatkin
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
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
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
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
 

KĂźrzlich hochgeladen (20)

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...
 
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
 
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
 
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
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
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
 
+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...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
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
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
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
 

Gradle For Beginners (Serbian Developer Conference 2013 english)

  • 1. Gradle for Beginners Coding Serbia, 18.10.2013 Joachim Baumann
  • 2. Gradle for Beginners •  Build-Management –  Needs –  Wishes •  Gradle - Basics •  Conguration and Execution Phase •  Groovy – Short Overview •  Plug-ins – Basics •  Our –  –  –  –  –  –  First Project Directory Structure Dependencies Manipulating the Jar Tests Quality Assurance Publishing the Artefacts
  • 3. What do we need from a Build-Management System? •  •  •  •  •  •  •  •  •  •  Translating the Source Code (using a compiler) Linking the Results Check out the source code from a repository (optional) Creating Tags (optional) Execution of different types of tests: Examples: –  Unit Tests for single Classes –  Module or Component Tests –  Integration Tests –  Functional and Non-Functional System Tests –  Automated Acceptance Tests Detailed Test Reports combining all Test Results (optional) Packing the Result (e.g., into a Jar, War or Ear) Transfer the Results to the different Stages / Test Systems and Execution of the respective Tests (optional) Support for multi-language Projects Creation of Documentation and Release Notes
  • 4. What do we wish for in our Build-Management System? •  Explicit Support of the Workflow implemented by the BuildManagement-System •  Simple Modiability and Extensibility of the Workflow to adapt to local processes •  Readability and self-documentation of the notation in the build script •  Use of sensible conventions (e.g., where to nd the sources) •  Simple change of the conventions to adap to local environment •  Incremental Build that can identify artefacts that have already been built •  Parallelisation of independent steps in the workflow to minimize waiting •  Programmatic access to all artefacts being created by the build •  Status reports that summarize the current state of the build
  • 5. Gradle - Basics •  Gradle uses build scripts which are named build.gradle •  Every build script is a Groovy script •  Two very important Principles –  Convention over Conguration –  Don’t Repeat Yourself •  Gradle creates a dynamic model of the workflow as a Directed Acyclic Graph (DAG) •  (Nearly) Everything is convention and can be changed tset tseTelipmoc dliub elipmoc elbmessa
  • 6. Conguration Phase •  •  •  •  Executes the build script The contained Groovy- and DSL-commands congure the underlying object tree The root of the object tree is the Project object –  Is directly available in the script (methods and properties) Creation of new Tasks that can be used Manipulation of the DAG •  Our rst script build.gradle •  println ”Hello from the configuration phase"
  • 7. Execution Phase •  Executes all tasks that have been called (normally on the command line) •  For a task that is executed every task it depends on is executed beforehand •  Gradle uses the DAG to identify all task relationships tset tseTelipmoc dliub elipmoc elbmessa
  • 8. Task Denition •  •  Takes an (optional) conguration closure Alternatively: can be congured directly •  •  The operator << (left-shift) appends an action (a closure) to this task’s list of actions Equivalent to doLast() •  Insert at the beginning of the list with doFirst() task halloTask halloTask.doLast { print "from the " } halloTask << { println "execution phase" } halloTask.doFirst { print "Hello " } task postHallo (dependsOn: halloTask) << { println "End" } postHallo { // configuration closure dependsOn halloTask }
  • 9. Groovy – Short Overview •  Simplied Java Syntax –  Semicolon optional –  GString –  Everything is an Object –  Simplication e.g., “println” •  Scripts •  Operator Overloading –  Predened •  Example << •  Operator for secure navigation a.?b –  You can provide your own implementations •  Named Parameters •  Closures •  Collection Iterators
  • 10. Plug-ins - Basics •  Plug-ins encapsulate functionality •  Can be written in any VM-language –  Groovy is a good choice •  Possible Plug-in Sources –  Plug-ins packed with Gradle –  Plug-ins included using URLs (don’t do it) –  Plug-ins provided by repositories (use your own repository) –  Self-written Plug-ins (normally in the directory buildSrc) •  Plug-ins –  Extend objects –  Provide new objects and / or abstractions –  Congure existing objects •  Plug-ins are load with the command apply plugin apply plugin: ‘java’
  • 11. Our rst Project •  We use the Java Plug-in •  Default paths used by the Java Plug-in –  Derived from Maven Conventions
  • 12. The Class HelloWorld package de.gradleworkshop; import java.util.ArrayList; import java.util.List; public class HelloWorld { public static void main(String[] args) { HelloWorld hw = new HelloWorld(); for(String greeting : hw.generateGreetingsData()) System.out.println(greeting); } public List<String> generateGreetingsData() { List <String> greetings = new ArrayList <String>(); greetings.add("Hallo Welt"); return greetings; } }
  • 13. Manipulation of the Manifest •  Every Jar-Archive contains a le MANIFEST.MF •  Is generated by Gradle (see directory build/tmp/jar/MANIFEST.MF) •  Contains information e.g., about the main class of the jar •  Can be changed jar { manifest { attributes 'Main-Class': 'de.gradleworkshop.HelloWorld' } } •  Alternatively jar.manifest.attributes 'Main-Class': 'de.gradleworkshop.HelloWorld'
  • 14. Tests package de.gradleworkshop; import java.util.List; import org.junit.*; import static org.junit.Assert.*; public class HelloWorldTest { HelloWorld oUT; @Before public void setUp() { oUT = new HelloWorld(); } @Test public void testGenerateGreetingsData() { List<String> res = oUT.generateGreetingsData(); assertEquals("wrong number of results", 1, res.size()); } }
  • 15. Congurations and Dependencies •  Gradle denes Conguration Objects. These encapsulate –  Dependency Information –  Paths to Sources and Targets –  Associated Artefacts –  Additional Conguration Information •  Tasks use these Congurations •  For most pre-dened Task a Conguration exists –  compile, testCompile, runtime, testRuntime •  •  Dependencies are dened using the key word dependencies Maven-like notation for the dependencies dependencies { testCompile group: 'junit', name: 'junit', version: '4.+’ }
  • 16. Repositories •  Repositories provide libraries (normally jar archives) •  You can dene Ivy or Maven Repositories, both public and private •  Predened Repositories –  JCenter –  Maven Central –  Local Maven Repository (~/.m2/repository) •  Repositories are dened using the keyword repositories repositories { mavenLocal() } repositories { jcenter() mavenCentral() } •  Multiple Repositories can be dened
  • 17. The Application Plug-in •  The Application-Plug-in –  Adds a Task run –  Creates start scripts, that can be used with the Task run –  Creates a Task distZip, that packs all necessary les into a ziparchive –  Denition of the Main Class mainClassName = "de.gradleworkshop.HelloWorld" –  Usage with apply plugin: 'application'
  • 18. Using TestNG •  Very Simple dependencies { testCompile group: 'org.testng', name: 'testng', version: '6.+' } test { useTestNG() }
  • 19. Test Class for TestNG package de.gradleworkshop; import java.util.List; import static org.junit.Assert.assertEquals; import static org.testng.AssertJUnit.*; import org.testng.annotations.*; public class TestHelloWorld { HelloWorld oUT; @BeforeTest public void setUp() { oUT = new HelloWorld(); } @Test public void testGenerateGreetingsData() { List<String> res = oUT.generateGreetingsData(); assertEquals("Wrong Number of Entries", 1, res.size()); } }
  • 20. Quality Assurance •  Support for PMD, Checkstyle, Findbugs, Emma, Sonar … •  Example PMD apply plugin: 'pmd' pmdMain { ruleSets = [ "basic", "strings" ] ignoreFailures = true } •  Another Example conguring all Tasks of Type Pmd using withType() tasks.withType(Pmd) { ruleSets = [ "basic", "strings" ] ignoreFailures = true ruleSetFiles = files('config/pmd/rulesets.xml') reports { xml.enabled false html.enabled true } }
  • 21. Publishing the Artefacts •  Gradle denes for every Conguration a Task upload<Conguration> –  Builds and publishes the Artefact belonging to the Conguration •  The Java-Plug-in creates a Conguration archives, which contains all artefacts created in the Task jar –  uploadArchives is the natural choice for publishing the artefacts •  Use of the Maven-Plug-in with apply plugin: ‘maven’ –  Doesn’t use the normal repository (intentionally) apply plugin: 'maven' version = '0.1-SNAPSHOT' group = 'de.gradleworkshop' uploadArchives { repositories { flatDir { dirs "repo" } mavenDeployer { repository (url : "file://$projectDir/mavenRepo/") } } }
  • 22. The whole Script (less than 20 lines) apply plugin: 'java' apply plugin: 'pmd' jar.manifest.attributes 'Main-Class': 'de.gradleworkshop.HelloWorld' pmdMain { ruleSets = [ "basic", "strings" ] ignoreFailures = true } repositories { mavenCentral() } dependencies { testCompile group: 'junit', name: 'junit', version: '4.+' } apply plugin: ‘maven’ version = '0.1-SNAPSHOT’ group = 'de.gradleworkshop’ uploadArchives { repositories { flatDir { dirs "repo" } mavenDeployer { repository (url : "file:///gradleWS/myRepo/") } } }
  • 23. Recap •  We have, with Gradle –  Built an Application –  Created Tests and executed them –  Used an alternative Test Framework TestNG –  Used Quality Assurance –  Uploaded the Artefacts into two Repositories •  You now know everything to build normal Projects with Gradle •  Gradle –  Is simple –  Easily understood –  Has sensible conventions –  That can be easily changed •  Gradle adapts to your needs
  • 24. Questions? Dr. Joachim Baumann codecentric AG An der Welle 4 60322 Frankfurt Joachim.Baumann@codecentric.de www.codecentric.de blog.codecentric.de 24 Â