Last active
January 3, 2020 13:20
-
-
Save prasad79/4eb0cdcdbc66fefbc5b5a94b23b72a47 to your computer and use it in GitHub Desktop.
Publishing Android library to the GitHub Package Registry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'maven-publish' // Apply this plugin at the top of your library build.gradle | |
def githubProperties = new Properties() | |
githubProperties.load(new FileInputStream(rootProject.file("github.properties"))) //Set env variable GPR_USER & GPR_API_KEY if not adding a properties file | |
def getVersionName = { -> | |
return "1.0.2" // Replace with version Name | |
} | |
def getArtificatId = { -> | |
return "sampleAndroidLib" // Replace with library name ID | |
} | |
publishing { | |
publications { | |
bar(MavenPublication) { | |
groupId 'com.enefce.libraries' // Replace with group ID | |
artifactId getArtificatId() | |
version getVersionName() | |
artifact("$buildDir/outputs/aar/${getArtificatId()}-release.aar") | |
} | |
} | |
repositories { | |
maven { | |
name = "GitHubPackages" | |
/** Configure path of your package repository on Github | |
** Replace GITHUB_USERID with your/organisation Github userID | |
** and REPOSITORY with the repository name on GitHub | |
*/ | |
url = uri("https://maven.pkg.github.com/GITHUB_USERID/REPOSITORY") | |
credentials { | |
/** Create github.properties in root project folder file with | |
** gpr.usr=GITHUB_USER_ID & gpr.key=PERSONAL_ACCESS_TOKEN | |
** 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") | |
} | |
} | |
} | |
} |
Typo alert:
.
after'maven-publish'
Corrected. Thank you Shauvik.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Typo alert:
.
after'maven-publish'