Proxy for gradle runner

I need to use proxy as a system property while running a specific task with gradle runner.

GradleRunner runner = GradleRunner.create()
.withPluginClasspath()
.withArguments(“-Dhttps.proxyHost=myproxy.com”,
-Dhttps.proxyPort=8080", “test”)
.build();

I want all https requests in this task to go through a proxy. But it doesn’t work as expected. The request doesn’t even go through proxy.

Thanks in advance.