Friday, 5 February 2016

How to set up repository authentication with Gradle

  • Setting up repository authentication with Gradle
In the previous post I showed you how to move a project from maven to Gradle. One of the issues I had was that authenticated repositories no longer worked (in Maven they were using the setting.xml file in the .m2 directory). I'm sure this is standard knowledge for any Gradle user but it took a little figuring out as a Maven user.

First create a file called and same it into the same directory as your build.gradle. It doesn't have to live there but it's a good place to start. See more here.

Add the following lines to the file:


Then in your build.gradle add the following:

repositories {
    maven {
        credentials {
            username repoUser
            password repoPassword
        url "http://nexus........."


  1. This doesn't handle the security issue of publishing and keeping secrets in a repository though?

  2. Moreover, one may opt for custom java development to target the customers. As it is independent of the platform, it stays versatile, saving resources, time and money.
    web design lessons