Rickwan's Blog

Android之JitPack快速发布开源库

为之于未有,治之于未乱。

JitPack
JitPack Documentation

Publish an Android library

In order 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.

Gradle

To enable building on JitPack you need to add the android-maven plugin.
If using Gradle 3.0 or later:

  • In your root build.gradle:

    1
    2
    3
    dependencies {
    classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
    }
  • In your library/build.gradle add:

    1
    2
    apply plugin: 'com.github.dcendents.android-maven'
    group='com.github.YourUsername'
  • Create a GitHub release or add a git tag.

    Remark:

    • Publish the project to Github and release it to the public repository

      release.png

    • Get the JitPack repository address

      look up.png

Installing

  • Users of your library will need add the jitpack.io repository:

    1
    2
    3
    4
    5
    6
    allprojects {
    repositories {
    jcenter()
    maven { url "https://jitpack.io" }
    }
    }
  • And

    1
    2
    3
    dependencies {
    compile 'com.github.jitpack:android-example:1.0.1'
    }

Note: do not add the jitpack.io repository under build script

Demo