Skip to content

Instantly share code, notes, and snippets.

@prasad79
Last active November 15, 2019 09:30
Show Gist options
  • Save prasad79/7eef45dfcb6333f5c530cd1324152c61 to your computer and use it in GitHub Desktop.
Save prasad79/7eef45dfcb6333f5c530cd1324152c61 to your computer and use it in GitHub Desktop.
Fetching Android Library from Github Package Registry - Github Authentication code
def githubProperties = new Properties() githubProperties.load(new FileInputStream(rootProject.file(“github.properties”)))
repositories {
maven {
name = "GitHubPackages"
/* Configure path to the library hosted on GitHub Packages Registry
* Replace UserID with package owner userID and REPOSITORY with the repository name
* e.g. "https://maven.pkg.github.com/enefce/AndroidLibraryForGitHubPackagesDemo"*/
url = uri("https://maven.pkg.github.com/UserID/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 = githubProperties['gpr.usr'] ?: System.getenv("GPR_USER")
password = githubProperties['gpr.key'] ?: System.getenv("GPR_API_KEY")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment