Why am I getting an authorization error when uploading/publishing an artifact to a remote Maven repository?



file contains the following (irrelevant lines removed):

configurations {



dependencies {

deployerJars “org.apache.maven.wagon:wagon-http-lightweight:1.0-beta-7+”


uploadArchives {

repositories.mavenDeployer {

configuration = configurations.deployerJars

repository(url: “https://hostname/path/to/repo”) {


userName: “some_name”,

password: “some_password”





where the




values were copied from my Maven



Publishing to the remove Maven repository results in an authorization error:

~/java/sruth: gradle -q uploadArchives

Uploading: path/to/jar/file to repository remote at https://hostname/path/to/repo

Transferring 435K from remote

FAILURE: Build failed with an exception.

  • What went wrong:

Execution failed for task ‘:uploadArchives’.

Could not publish configuration ‘:archives’.

Error deploying artifact ‘group_id:package_name:jar’: Error deploying artifact: Failed to transfer file: https://hostname/path/to/repo/path/to/jar/file. Return code is: 401

I’ve read the User’s Guide. Any ideas?

Your first step would be to run Gradle with ‘–info --stacktrace’ so you get more details. If that doesn’t help, running with ‘–debug’ will give you a lot more information.

Without more details, it’s pretty hard to tell what’s going wrong. From first glance it looks like you could have the wrong user/password.

Here’s the exception that caused the problem:

Caused by: org.apache.maven.wagon.TransferFailedException: Failed to transfer file: https://artifacts.unidata.ucar.edu/content/repositories/unidata-snapshots/edu/ucar/unidata/sruth/1.0-SNAPSHOT/sruth-1.0-20120628.231243-32.jar. Return code is: 401
 at org.apache.maven.wagon.providers.http.LightweightHttpWagon.finishPutTransfer(LightweightHttpWagon.java:205)

I’m afraid it doesn’t shed much light.

I would suspect the username or password except that they were explicitly copied from my settings.xml file and the Maven deployment works. That leaves me with either a bug in LightweightHttpWagon or something wrong with my build.gradle file (which is why I presented it).

I found the problem: I was using Maven’s hash of the password for the Gradle password rather than the password itself, so copying the “password” from the Maven settings.xml file didn’t do what I thought. My mistake.