To publish your Android library on JitPack you just need a working build file in your Git repository.
Android SDK is available in the build environment and ANDROID_HOME variable is already set when the build starts. Builds are run with Java 8 by default but can be configured using a jitpack.yml file.
To build and publish your library on JitPack you need the maven-publish
plugin as explained in the Android documentation.
plugins {
id 'maven-publish'
}
publishing {
publications {
release(MavenPublication) {
groupId = 'io.jitpack'
artifactId = 'library'
version = '1.0'
afterEvaluate {
from components.release
}
}
}
}
Check that your library can be installed to mavenLocal ($HOME/.m2/repository
):
./gradlew publishToMavenLocal
// or if you named your publication "release"
./gradlew publishReleasePublicationToMavenLocal
If everything went well in the previous step, your library is ready to be released! Create a GitHub release or add a git tag and you’re done!
Users of your library will need to add the jitpack.io repository to settings.gradle file:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
and:
dependencies {
implementation 'com.github.jitpack:android-example:1.0.1'
}
Note: do not add the jitpack.io repository under buildscript
If you add a sample app to the same repo then your app needs to depend on the library. To do this in your app/build.gradle add a dependency in the form:
dependencies {
implementation project(':library')
}
where ’library’ is the name of your library module.
(c) 2022 JitPack.io