Gradle apply: with http auth

We store gradle files on http server with HTTP Auth. I thought I can apply these files by

apply from: "https://username:password@host.com/file.gradle

but it still returns 401. Looks like java.net.URL doesn’t support it out of box

How can I specify username/password for apply scripts?