参考 :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,但是需要jdk1.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库的地址即可
网友评论