Gradle uploadArchives task fail: Error retrieving previous build number for artifact from S3 repository

I am facing this problem while deploying my artifacts to a maven repo hosted on s3. I am getting this error -

:uploadArchives FAILED
  FAILURE: Build failed with an exception.
  * What went wrong:
Execution failed for task ':uploadArchives'.
> Could not publish configuration 'archives'
   > Error deploying artifact 'com.test:MyProject:aar': Error retrieving previous build number for artifact 'com.artoo:MyProject:aar': repository metadata for: 'snapshot com.test:MyProject:1.2-SNAPSHOT' could not be retrieved from repository: remote due to an error: Cannot write file to '/Users/Shubham/.m2/repository/com/test/MyProject/1.2-SNAPSHOT/maven-metadata-remote.xml.tmp

Here is my uploadArchives task -

uploadArchives {
    repositories {
        mavenDeployer { deployer ->
            configuration = configurations.deployerAars
            def repositoryUrl = 's3://my-mvn-repo/snapshots'
            repository(url: repositoryUrl) { authentication(userName: 's3AccessKey',
                    passphrase: 's3SecureKey')
            }
            pom.project {
                name 'MyProject'
                packaging 'aar'
            }
        }
    }
}

Am I doing something wrong ?

Note: I am successfully able to deploy if my s3 maven repo is empty i.e it don’t have any previous version.

I am also getting this error. I am using springsource’s aws-maven 5.0.0. Did you resolved your issue?