Skip to content

Instantly share code, notes, and snippets.

@xconnecting
xconnecting / HeaderSpec.groovy
Created February 6, 2014 05:00
[Spock] Pancoc characterization test 1
import spock.lang.Specification
class HeaderSpec extends Specification {
def "header characterization test"() {
when:
def proc = "pandoc header.md -o header.html".execute()
proc.waitFor()
then:
def result = new File("header.html").getText('UTF-8')
"" == result
@xconnecting
xconnecting / HeaderSpec.groovy
Created February 6, 2014 05:01
[Spock] Pancoc characterization test 2
import spock.lang.Specification
class HeaderSpec extends Specification {
def "header characterization test"() {
when:
def proc = "pandoc header.md -o header.html".execute()
proc.waitFor()
then:
def result = new File("header.html").getText('UTF-8')
"""<h1 id="header-test">Header Test</h1>
@xconnecting
xconnecting / HeaderSpec.groovy
Created February 6, 2014 05:01
[Spock] Pancoc characterization test 3
import spock.lang.Specification
class HeaderSpec extends Specification {
def "header characterization test"() {
when:
def proc = "pandoc header.md -o header.html".execute()
proc.waitFor()
then:
def result = new File("header.html").getText('UTF-8')
"""<h1 id="header-test">Header Test</h1>
@xconnecting
xconnecting / ReadWrite.groovy
Created September 18, 2012 04:54
Groovy: file read and write
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()
@xconnecting
xconnecting / build.gradle
Created October 17, 2012 07:55
Get password console during executing gradle task
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
}
@xconnecting
xconnecting / build.gradle
Created October 18, 2012 04:07
Gradle script for making directories for Groovy project
apply plugin: 'groovy'
apply plugin: 'eclipse'
task mkdirs << {
sourceSets.all {
it.groovy.srcDirs.each { it.mkdirs() }
it.resources.srcDirs.each { it.mkdirs() }
}
}
@xconnecting
xconnecting / build.gradle
Created October 25, 2012 01:20
dependencies and repositories in Gradle
apply plugin: 'java'
apply plugin: 'eclipse'
dependencies { compile 'commons-lang:commons-lang:2.6' }
repositories {
// Maven central repository
mavenCentral()
// local repository
@xconnecting
xconnecting / build.gradle
Created October 31, 2012 06:03
Gradle: Change setting using P option
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'")
@xconnecting
xconnecting / build.gradle
Created November 1, 2012 01:57
Gradle: Deploying to a Maven repository
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 {
@xconnecting
xconnecting / build.gradle
Created November 6, 2012 01:05
Sample: Gradle custom task in build.gradle
task hello (type: GreetingTask){
}
task hi (type: GreetingTask){
greeting = 'Hi'
}
class GreetingTask extends DefaultTask {
def greeting = 'Hello'
@TaskAction