Gradle 2.x no longer supports embedding username and password in maven url

Gradle’s maven syntax used to support embedding the username and password in the url. For example,

maven {
     url "https://${GITHUB_USERNAME}:${GITHUB_PASSWORD}@raw.githubusercontent.com/foobar/repo/master/releases"
}

Doing it this way, while ugly, is a necessary workaround when dealing with certain kinds of private maven repos (see GRADLE-3091). It worked well enough in 1.x, but now in 2.x it seems to be silently dropping this information, breaking support for these private maven repos.

I want to emphasize that this workaround is gross-- fixing GRADLE-3091 is a much better way to go about it. However, GRADLE-3091 has been open for 9 months and has still not been addressed. And now in 2.x we can’t even use the workaround.

What about using $HOME/.gradle/gradle.properties to store username and password pairs?

myrepoUserName=thad
myrepoPassword=foobarbaz
ftpUserName=thad
ftpPassword=eneymeanie

Then:

uploadArchives {
    repositories {
      mavenDeployer {
        repository(url: project.ext.myrepoInternal) {
          authentication(userName: myrepoUserName, password: myrepoPassword)
        }
        pom.version = version
        pom.groupId = project.parent.name
        pom.artifactId = project.name
      }
    }
  }

or

task ftp << {
    ant {
      taskdef(name: 'ftp',
              classname: 'org.apache.tools.ant.taskdefs.optional.net.FTP',
              classpath: configurations.ftpAntTask.asPath)
      ftp(server: "ftp.apache.org", userid: ftpUserName, password: ftpPassword) {
          fileset(dir: "htdocs/manual")
      }
    }
  }