How to set global gradle settings (gradle vm options) in intellij idea programmatically?

I’ve met with the fact, that setting with encoding options for my project for gradle in build.gradle, gradle.properties, gradlew, gradlew.bat does nothing in Intellij Idea. When I run task from command line such

gradlew name_of_the_task

it runs ok and the encoding settings that I’ve set in gradlew.bat are implemented. But when I run build for the same task in Intellij Idea it seems that this setting is not set.

I’ve tried many variants to set the jvm property, and the only 3 ways helps me:

  1. the idea64.vmoptions file where i specified the -Dfile.encoding=utf8 or
  2. The help - edit custom vm options… with the same specification or
  3. File - settings - global gradle settings - gradle vm options.

In any of this cases project runs as it meant to run. Without that there is decoding problem. How can I set this param directly in project?

In gradle.properties

org.gradle.jvmargs=-Dfile.encoding=UTF-8

Thank you for reply, BUT I’ve got even 2 values inside gradle.properties

org.gradle.jvmargs=-Dfile.encoding=UTF-8
systemProp.file.encoding=UTF-8

and it doesn’t work. The chinese symbols are written in mojibake

There’s no reason to do it twice. You only need the one I showed you.

Make sure you are not overriding those properties in IDEA. If you specify VM options in IDEA, they will replace anything you have in gradle.properties.

Ok, I just deleted the second line and started clean and build for task. And, as expected, my chinese characters are ?? shown.
If I left only this line the
gradlew task_name
from command prompt is running properly. In idea the same param does nothing.
Could you please be so kind to tell me in what places I should search for another VM options in Idea? I suppose that there is no options but default. And I want to override any possible settings by mine, but with the ability to send this properties to git.

Stefan ? I cannot find where it overrides properties, tried almost everywhere. BTW there is spring boot in project if it helps somehow

p.s.
Well, got it.
System.setProperty(“file.encoding”, “UTF-8”);
Field cs = Charset.class.getDeclaredField(“defaultCharset”);
cs.setAccessible(true);
cs.set(null, null);
This one works fine, don’t know why(

ps2
well, additional research comes to the fact, that we need to CREATE a separatre gradle.properties for our task and put the options with UTF-8 in it.
That’s all , folks!