Show UTF-8 text properly in Gradle

后端 未结 5 1069
清酒与你
清酒与你 2020-12-01 07:36

I have a task:

task info<<{
    println \"Gradle — система автоматической сборки, построенная на принципах Apache Ant и Apache Maven, но предоставляюща         


        
相关标签:
5条回答
  • 2020-12-01 08:17

    I use next setting in build.gradle and it works fine for me:

    compileJava.options.encoding = 'UTF-8'
    
    tasks.withType(JavaCompile) {
        options.encoding = 'UTF-8'
    }
    
    0 讨论(0)
  • 2020-12-01 08:21

    The file.encoding system property needs to be set right when the JVM executing the Gradle build (e.g. the Gradle Daemon) starts up. One way to achieve this is with export GRADLE_OPTS="-Dfile.encoding=utf-8". Another way that might work is to add systemProp.file.encoding=utf-8 to gradle.properties. Of course this assumes that the build script files are actually using utf-8 encoding. To see what your platform's (and therefore Gradle's) default encoding is, print out the system property's value in a build script.

    0 讨论(0)
  • 2020-12-01 08:32

    In gradle.properties

    org.gradle.jvmargs='-Dfile.encoding=UTF-8'
    
    0 讨论(0)
  • 2020-12-01 08:35

    For my only works with this in build.gradle:

    apply plugin: 'java'
    tasks.withType(JavaCompile) {
        options.encoding = 'UTF-8'
    }
    repositories {
        mavenCentral()
    }
    ....
    test {
        systemProperty "file.encoding", "utf-8"
    }
    
    0 讨论(0)
  • 2020-12-01 08:39

    if you're using kotlin DSL, then:

    build.gradle.kts:

    tasks.withType<JavaCompile> {
        options.encoding = "UTF-8"
    }
    
    0 讨论(0)
提交回复
热议问题