在project的build.gralde中添加classpath
1
| classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
|
注意:如果没有加google(),必须加上这个,并且buildscript和allprojects都得加上。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.1.2' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() } }
|
在library的build.gradle中添加
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| apply plugin: 'com.github.dcendents.android-maven' //{github用户名}改为自己github的用户名 group='com.github.{github用户名}' //... //添加下面这些才会有文档注释。 // build a jar with source files task sourcesJar(type: Jar) { from android.sourceSets.main.java.srcDirs classifier = 'sources' } task javadoc(type: Javadoc) { failOnError false source = android.sourceSets.main.java.sourceFiles classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) classpath += configurations.compile } // build a jar with javadoc task javadocJar(type: Jar, dependsOn: javadoc) { classifier = 'javadoc' from javadoc.destinationDir } artifacts { archives sourcesJar archives javadocJar }
|
提交代码到github
在github项目页面release一个新版本
访问jitpack官网查看
https://jitpack.io
搜索框输入github项目地址
如: https://github.com/zhouzhuo810/Magpie
点击最新版的get
按钮,即开始编译,编译成功即可使用。
使用方法该页面下方有。
更多可参考官方demo
https://github.com/jitpack/android-example