I try to publish a library to a private S3 maven repository. The upload is guarded by a password, but for download the library is open for public. The aar file uploads without issues (along with pom/md5/sha1) and I can see it in my S3 bucket, download it and even manually add this aar as dependency to my project. However when I load this dependency like this:
allprojects {
repositories {
google()
jcenter()
maven { url "http://myrepo.com" }
}
//in the project's build.gradle
implementation 'com.mylib:mylib:0.1.1'
...there is an issue. Gradle sync finishes without a problem and it looks like the aar has been downloaded, but it never appears in the "External Libraries" section inside Android Studio, and the code is not available (Unresolved reference: MyLib
).
Of course I tried rebuilding, invalidating caches and applying it to a different project.
Any ideas how to make it work?
This is how the maven-publish code looks.
android.libraryVariants.all { variant ->
if (variant.buildType.name == "release" && variant.flavorName == "prod") {
variant.outputs.all { output ->
publishing.publications.create(variant.name, MavenPublication) {
artifact source: output.outputFile, classifier: output.name
pom.withXml {
def dependencies = asNode().appendNode('dependencies')
configurations.getByName(variant.name + "CompileClasspath").allDependencies
.findAll { it instanceof ExternalDependency }
.each {
def dependency = dependencies.appendNode('dependency')
dependency.appendNode('groupId', it.group)
dependency.appendNode('artifactId', it.name)
dependency.appendNode('version', it.version)
}
}
}
}
}
}
tasks.all { task ->
if (task instanceof AbstractPublishToMaven) {
task.dependsOn assemble
}
}
publishing {
Properties properties = new Properties()
properties.load(file('maven.properties').newDataInputStream())
def user = properties.getProperty("maven.user")
def password = properties.getProperty("maven.password")
repositories {
maven {
url "s3://myrepo.com/"
credentials(AwsCredentials) {
accessKey user
secretKey password
}
}
}
}
maven { url "http://myrepo.com" }
and clean build. (to sanity check / make sure it is doing something) You should get a not found error, meaning the DL works – Underclothing