I've created an Android library called Library
and I want to publish it to a private maven repository and then consume it in an app called App
.
I am encountering an issue however which is making the usage of the library untenable for App
. The issue is that one of the dependencies of Library
is hosted in a "non standard" maven repository, and is forcing the consuming App
to add this repository to it's repositories
block.
To explain this further; Library
has lots of dependencies, most of which are pulled from google
and mavenCentral
repositories (both of which the consuming App
has in the repositories
block because all Android apps will include these repositories). However, one of the dependencies, Quikkly
, is hosted in a "non standard" maven repository (i.e. one with a non standard URL), which also requires a github personal access token to access. So in my Library
repositories
block, I have to add this maven repo in order to pull this specific dependency:
maven {
url 'https://maven.pkg.github.com/quikkly/quikkly-android-sdk'
credentials {
username = <github_username>
password = <github_access_token>
}
}
All well and good; I can build Library
just fine, and the Quikkly
dependency is pulled successfully from this repository.
The issue arises when I use Library
in App
. I published Library
to mavenLocal
(or my own private maven repository depending on when I'm ready to actually push a release). When I pull Library
into App
and then build, the build fails because Quikkly
could not be resolved.
The errors show that the locations searched were just the repositories defined in App
and not those defined in Library
. I can make the build succeed if I add the Quikkly
custom maven repo (and github access token) to App
but I don't want to force App
developers to need to add custom repos just to use my library - surely my library should be responsible for properly packaging it's own dependencies such that consumers just need to use my library via a one line gradle import.
I've done some research on this, and I think the solution involves adding the custom maven repository URL to a <server>
element in my libraries .pom
file, however the repository also requires a github username and personal access token in order to pull the library from it... my research shows that I need to add these details to "somewhere" (but not in the .pom
file as this would be insecure and/or wouldn't even work).
I'm now getting pressured to release something working, but I'm pretty stuck with this. Can anyone help?