Setting the parameter externally works: export GRADLE_OPTS="-Dfile.encoding=UTF-8" But we’re trying to contain this on a per-project basis so we tried adding this to gradle.properties systemProp.file.encoding=UTF-8 But our tests fail as it does not seem to get passed to the groovyc compiler to compile the source with UTF-8. I can see the property is being utilised just not passed to these processes. So debug with neither setting
12:01:29.924 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] setting 'file.encoding.pkg' to 'sun.io'
12:01:29.934 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] setting 'file.encoding' to 'MacRoman'
12:01:29.998 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] setting 'file.encoding.pkg' to 'sun.io'
12:01:30.011 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] setting 'file.encoding' to 'MacRoman'
12:01:30.708 [QUIET] [system.out] *************************** File Encoding=MacRoman
12:01:43.251 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] setting 'file.encoding.pkg' to 'sun.io'
12:01:43.253 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] setting 'file.encoding' to 'MacRoman'
Debug with gradle.properties set
12:02:48.476 [DEBUG] [org.gradle.initialization.ProjectPropertySettingBuildLoader] Adding project properties (if not overwritten by user properties): [systemProp.file.encoding]
12:02:48.721 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] setting 'file.encoding.pkg' to 'sun.io'
12:02:48.731 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] setting 'file.encoding' to 'UTF-8'
12:02:48.792 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] setting 'file.encoding.pkg' to 'sun.io'
12:02:48.806 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] setting 'file.encoding' to 'UTF-8'
12:02:49.561 [QUIET] [system.out] *************************** File Encoding=UTF-8
12:03:02.446 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] setting 'file.encoding.pkg' to 'sun.io'
12:03:02.447 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] setting 'file.encoding' to 'UTF-8'
Debug with exported env var and no gradle.properties
11:59:15.209 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] setting 'file.encoding.pkg' to 'sun.io'
11:59:15.218 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] setting 'file.encoding' to 'UTF-8'
11:59:15.274 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] setting 'file.encoding.pkg' to 'sun.io'
11:59:15.284 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] setting 'file.encoding' to 'UTF-8'
11:59:15.966 [QUIET] [system.out] *************************** File Encoding=UTF-8
11:59:29.256 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] setting 'file.encoding.pkg' to 'sun.io'
11:59:29.257 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] setting 'file.encoding' to 'UTF-8'
-Dfile.encoding=UTF-8
'-Dfile.encoding=UTF-8'
-Dfile.encoding=UTF-8
'-Dfile.encoding=UTF-8'
11:59:40.414 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] setting 'file.encoding.pkg' to 'sun.io'
11:59:40.415 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] setting 'file.encoding' to 'UTF-8'
You can see from the last one the -D parameters being applied to groovyc
I thought these 2 issues might resolve http://issues.gradle.org/browse/GRADLE-1618 - file.encoding System property (and GRADLE_OPTS) not passed to Daemon http://issues.gradle.org/browse/GRADLE-2099 - Impossible to set the default character encoding when using the daemon But obviously not and a slightly different issue? I tried this on m6, m9 and rc-1
Is this a bug, or is it meant to be this way and our only option in this case is to set the property externally. We want to avoid having to pass it on the command line and want to contain these per project as we run multiple projects in our workspaces.
Thanks Warren