This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example | |
import org.gradle.api.DefaultTask; | |
import org.gradle.api.tasks.TaskAction; | |
class GreetingTask extends DefaultTask { | |
def greeting = 'Hello' | |
@TaskAction | |
def greet() { | |
println greeting | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'groovy' | |
apply plugin: 'eclipse' | |
apply plugin: 'maven' | |
group = 'com.example' | |
archivesBaseName = 'greet' | |
version = '1.0-SNAPSHOT' | |
dependencies { | |
compile gradleApi() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'eclipse' | |
apply plugin: 'maven' | |
apply plugin: 'greeting' | |
buildscript { | |
repositories { mavenLocal() } | |
dependencies { classpath 'com.example:greet:1.0-SNAPSHOT' } | |
} | |
task hi(type:com.example.GreetingTask){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defaultTasks 'checkProperty' | |
task checkProperty << { | |
println hasProperty('test') | |
println project.hasProperty('test') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'eclipse' | |
apply plugin: 'maven' | |
buildscript { | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
classpath 'org.apache.commons:commons-email:1.2' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ant.condition(property: "os", value: "windows") { os(family: "windows") } | |
ant.condition(property: "os", value: "unix" ) { os(family: "unix") } | |
task typeos << { | |
switch(ant.properties.os){ | |
case 'windows': | |
println 'This is windows.' | |
break | |
case 'unix': | |
println 'This is unix.' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'java' | |
apply plugin: 'eclipse' | |
apply plugin: 'maven' | |
dependencies { compile 'commons-lang:commons-lang:2.6' } | |
repositories { | |
mavenCentral() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the contents of .gradle/other.gradle is: | |
// ext.prop1 = 'value1' | |
apply from: "${System.properties['user.home']}/.gradle/other.gradle" | |
task testProperties << { | |
println project.prop1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task hello << { | |
println 'hello' | |
} | |
hello.group = 'greeting' | |
hello.description = 'Say hello.' | |
task hi << { | |
println 'hi' | |
} | |
hi.group = 'greeting' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Greeting implements Plugin<Project> { | |
void apply(Project target) { | |
def helloTask = target.task('hello', type: HelloTask) | |
helloTask .group = 'greeting' | |
helloTask .description = 'Say hello.' | |
target.task('hi', type: HiTask){ | |
group = 'greeting' | |
description = 'Say hi.' | |
} | |
} |