I have done this using github packages, i was not able to access it until i provide a token, so i think this makes it private.
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/USERNAME/REPOSITORY")
credentials {
username = "USERNAME"
password = "TOKEN"
}
}
}
publications {
aar(MavenPublication) {
groupId 'com'
artifactId 'test'
version '1.0.0'
artifact("set your aar file location")
}
}
}
USERNAME = your user name for github account
REPOSITORY = name of you repo
TOKEN = this token is generated, you can do this from your account
aar file= this file appears when you build your project under the library build files.
then you can run publish either by a command line $gradle publish

------ Adding the dependency to a project
into you project gradle add this
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/USERNAME/REPOSITORY")
credentials {
/** Create github.properties in root project folder file with
** gpr.usr=GITHUB_USER_ID & gpr.key=PERSONAL_ACCESS_TOKEN
** Or set env variable GPR_USER & GPR_API_KEY if not adding a properties file**/
username = "USERNAME"
password = "TOEKN"
}
}
into you module gradle add this
implementation com:test:1.0.0