Showing posts with label gradle. Show all posts
Showing posts with label gradle. Show all posts

Dec 7, 2009

How to Specify Character Encoding for Gradle

We, programmers living in the multi-bytes world, need knowledge of specifying character encoding.

For Gradle, it is the following:
usePlugin 'groovy'

repositories {
    mavenCentral()
}
dependencies {
    groovy group:'org.codehaus.groovy', name:'groovy', version:'1.7-beta-2'
}

def defaultEncoding = 'UTF-8'
compileJava {
    options.encoding = defaultEncoding  // affects *.java under src/main/java
                                        // alternative: "file.encoding" property
compileTestJava {
    options.encoding = defaultEncoding  // affects *.java under src/test/java
                                        // alternative: "file.encoding" property
}
compileGroovy {
    groovyOptions.encoding = defaultEncoding  // affects *.groovy under src/main/groovy
    options.encoding = defaultEncoding        // affects *.java under src/main/groovy
}
compileTestGroovy {
    groovyOptions.encoding = defaultEncoding  // affects *.groovy under src/test/groovy
    options.encoding = defaultEncoding        // affects *.java under src/test/groovy
}