Unable to deploy to a maven repository from behind a http proxy with authentication

I am trying to deploy to a maven repository (artifactory) from behind a proxy with basic auth. It fails with error 407. Direct connection works.

I’ve set -Dhttp.proxyUser= -Dhttp.proxyPassword= in GRADLE_OPTS and i tried proxy(host: ‘…’, userName: ‘xx’, password: ‘xxx’) in the build file. I also tried setting all the properties specifically for https.

uploadArchives {
    repositories.mavenDeployer {
        repository(url: "https://xxx.xxx.xxx/xxx/libs-snapshots-local") {
            proxy(host: proxyHost, port: proxyPort, userName: proxyUser, password: proxyPassword, type: 'http')
            authentication(userName: "deployer", password: deployerPassword)

What am i doing wrong?

On a side note:

I think the documentation for the maven plugin is slightly out of date. The links to the maven javadoc are broken and proxy seems to be an attribute of remoterepository and not of MavenDeployer.