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
def reader = new File('in.txt').newReader('UTF-8') | |
def writer = new File('out.txt').newWriter('UTF-8') | |
reader.eachLine{ | |
println it | |
writer.writeLine(it) | |
} | |
writer.close() |
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 readPassword << { | |
// Get password from user input. | |
def console = System.console() | |
console.writer().write "\n" | |
def password = console.readPassword('%s: ', 'Please enter the password') | |
println password | |
} |
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' | |
task mkdirs << { | |
sourceSets.all { | |
it.groovy.srcDirs.each { it.mkdirs() } | |
it.resources.srcDirs.each { it.mkdirs() } | |
} | |
} |
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' | |
dependencies { compile 'commons-lang:commons-lang:2.6' } | |
repositories { | |
// Maven central repository | |
mavenCentral() | |
// local repository |
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' | |
configurations { taskdef } | |
repositories { mavenCentral() } | |
dependencies { taskdef 'java2html:j2h:1.3.1' } |
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 'dbsetting' | |
def envList = ['dev', 'qa', 'prod'] | |
if (!hasProperty('env')) { | |
ext.env = System.env['GRADLE_ENV'] ?: envList[0] | |
} | |
if(!envList.find{it == ext.env}){ | |
throw new Exception("There is no environment named '$ext.env'") |
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: 'maven' | |
// If archivesBaseName is not specified, the project name is used for name | |
archivesBaseName = 'myapp' | |
group = 'com.mycompany.app' | |
version ='0.1' | |
uploadArchives { | |
repositories { |
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 (type: GreetingTask){ | |
} | |
task hi (type: GreetingTask){ | |
greeting = 'Hi' | |
} | |
class GreetingTask extends DefaultTask { | |
def greeting = 'Hello' | |
@TaskAction |
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) { | |
target.task('greet', type: GreetingTask) | |
} | |
} | |
class GreetingTask extends DefaultTask { | |
def greeting = 'Hello' | |
@TaskAction | |
def greet() { |
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.Plugin | |
import org.gradle.api.Project | |
class Greeting implements Plugin<Project> { | |
void apply(Project target) { | |
target.task('greet', type: GreetingTask) | |
} | |
} |
OlderNewer