Android Multi-Project Setup: Can't resolve dependencies from a maven repo hosted on S3 when manually pushing the artifacts to the s3 repo


(Shubham Goyal) #1

I have a android library project A that is used by another library project B as a dependency. When I am deploying the .aar artifact of A to a s3 repo using the below script, its working fine i.e. I am able to resolve dependency in B.

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 'ArtooAPI-Android'
                packaging 'aar'
            }
        }
    }
}

However If I deploy the A artifacts to a local maven repo by specifying the local maven repo in the above code and then push the artifacts manually from the local maven repo to my s3 bucket, I am getting a 403: forbidden status from the server while resolving dependencies in A. Here is the exact error -

FAILURE: Build failed with an exception.
  * What went wrong:
A problem occurred configuring root project 'B'.
> Could not resolve all dependencies for configuration ':_debugCompile'.
   > Could not resolve com.example:A:1.2-SNAPSHOT.
     Required by:
         com.example.data:B:1.0-SNAPSHOT
      > Unable to load Maven meta-data from http://my-mvn-repo.s3.amazonaws.com/snapshots/com/example/A/1.2-SNAPSHOT/maven-metadata.xml.
         > Could not GET 'http://my-mvn-repo.s3.amazonaws.com/snapshots/com/example/A/1.2-SNAPSHOT/maven-metadata.xml'. Received status code 403 from server: Forbidden

Is there something I can do to make it work!


(Shubham Goyal) #2

I figured out what was the problem. When deployed using the task uploadArchives directly to s3, the permissions for my artifacts get set to read by everyone by default while if I first deploy it to a local maven repo and then manually push the local artifacts to s3, no permissions get set by default due to which I was getting a 403: Forbidden status while accessing them.

Now my question is can I specify the permissions I want to give to the artifacts in my uploadArchives task ?