JitPackを使用してオープンソースプロジェクトをパブリッシュ

2206 ワード

参照先:https://jitpack.io/docs/ANDROID
プロジェクトを作成
  • あなたのroot build.gradle追加
  • buildscript { 
      dependencies {
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' // Add this line
      }
    }
    

    (こちらは1.3、公式サイトは1.5ですがjdk 1.8が必要です)
    私の場合:
    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.5.0'
            classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' // Add this line
        }
    }
    
    allprojects {
        repositories {
            jcenter()
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    
    
  • あなたのlibraryの下にあるbuild.gradle追加
  •  apply plugin: 'com.github.dcendents.android-maven'  
     group='com.github.YourUsername'
    

    私のように
    apply plugin: 'com.android.library'
    apply plugin: 'com.github.dcendents.android-maven'
    group='com.github.wangli0'
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"
    
        defaultConfig {
            minSdkVersion 8
            targetSdkVersion 23
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:23.4.0'
    }
    
    
  • pushあなたの倉庫はgithub倉庫を創立して、上のコードpushを倉庫の中に
  • git tag v1.0 
    git push origin v1.0 //   git push origin --tags
    

    使用方法
    ある人のプロジェクトにはroot buildだけが必要です.gradleで追加
    1. maven { url "https://jitpack.io" }
    2. compile 'com.github.yourName:yourLibrary:yourTags'
    

    次のようになります.
    allprojects {
     repositories {
        jcenter()
        maven { url "https://jitpack.io" }
     }
    }
    
    compile 'com.github.xxx:HelloJitpack:v5.0'
    

    compile'xxxx'は何が行くことができますhttps://jitpack.io/githubライブラリのアドレスを検索すればいいです