Tech talk - Richard Hsu
Text
task hello << {
println 'Hello world!'
}
$ gradle hello
:hello
Hello world!
BUILD SUCCESSFUL
Total time: 2.001 secs
Text
task joke << {
String punchLine = " Part A!"
println "What comes before Part B?\n" + punchLine
}
$ gradle joke -q
What comes before Part B?
Part A!
Text
task countUp << {
4.times { print "$it " }
}
Text
$ gradle -q countUp
0 1 2 3
Text
task distribution << {
println "We build the zip with version=$version"
}
task release(dependsOn: 'distribution') << {
println 'We release now'
}
gradle.taskGraph.whenReady {taskGraph ->
if (taskGraph.hasTask(release)) {
version = '1.0'
} else {
version = '1.0-SNAPSHOT'
}
}
Text
$ gradle -q distribution
We build the zip with version=1.0-SNAPSHOT
$ gradle -q release
We build the zip with version=1.0
We release now
apply plugin: 'java'
project
name
path
description
projectDir
buildDir
group
version
ant
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
compile 'commons-collections:commons-collections:3.2'
testCompile group: 'junit', name: 'junit', version: '4.+'
}
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
compile 'commons-collections:commons-collections:3.2'
testCompile group: 'junit', name: 'junit', version: '4.+'
}
// Use a String path to specify the source directory
compile {
source = 'src/main/java'
}
$ gradle build
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build
BUILD SUCCESSFUL
Total time: 2.622 secs
$gradle -gui
DEMO
docs.gradle.org
Gradle in action