Gradle发布项目到JCenter仓库
来源:互联网 发布:xy苹果助手mac版 编辑:程序博客网 时间:2024/05/16 15:48
简书地址:http://www.jianshu.com/p/fd2f2eca63b7
过程比较简单,记录一下发布的流程,方便后续查阅
1.注册登录就不多说了JCenter地址
2.新建一个项目GradlePro,同时新建一个module
3.编辑项目的根目录中的build.gradle文件
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.2' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }}allprojects { repositories { jcenter() }}task clean(type: Delete) { delete rootProject.buildDir}
4.编辑Module(对应此项目中的exlibrary)中的build.gralde文件
apply plugin: 'com.android.library'apply plugin: 'com.github.dcendents.android-maven'apply plugin: 'com.jfrog.bintray'//版本号version = "1.0.0"android { compileSdkVersion 25 buildToolsVersion "25.0.0" //资源前缀 resourcePrefix "exlibrary__" defaultConfig { minSdkVersion 14 targetSdkVersion 25 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } android { lintOptions { abortOnError false } }}dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:25.3.1' testCompile 'junit:junit:4.12'}//项目的主页def siteUrl = 'https://github.com/byhook/GradlePro'//Git仓库主页def gitUrl = 'https://github.com/byhook/GradlePro.git'//Maven Group IDgroup = "cn.byhook.exlibrary"install { repositories.mavenInstaller { pom { project { packaging 'aar' //项目描述 name 'Android ExLibrary' url siteUrl //设置授权信息 licenses { license { name 'The Apache Software License, Version 2.0' url 'http://www.apache.org/licenses/LICENSE-2.0.txt' } } //填写的一些基本信息 developers { developer { id 'byhook' name 'Andy' email 'byhook@163.com' } } scm { connection gitUrl developerConnection gitUrl url siteUrl } } } }}task sourcesJar(type: Jar) { from android.sourceSets.main.java.srcDirs classifier = 'sources'}task javadoc(type: Javadoc) { source = android.sourceSets.main.java.srcDirs classpath += project.files(android.getBootClasspath().join(File.pathSeparator))}task javadocJar(type: Jar, dependsOn: javadoc) { classifier = 'javadoc' from javadoc.destinationDir}artifacts { archives javadocJar archives sourcesJar}Properties properties = new Properties()properties.load(project.rootProject.file('local.properties').newDataInputStream())bintray { user = properties.getProperty("bintray.user") key = properties.getProperty("bintray.apikey") configurations = ['archives'] pkg { repo = "maven" //发布到JCenter上的项目名称 name = "ExLibrary" websiteUrl = siteUrl vcsUrl = gitUrl licenses = ["Apache-2.0"] publish = true }}
5.编辑local.properties新增配置
bintray.user=your_usernamebintray.apikey=your_apikey
6.上传到Bintray需要gradle-bintray-plugin的支持,在项目根目录的build.gradle中新增依赖
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.2' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }}allprojects { repositories { jcenter() }}task clean(type: Delete) { delete rootProject.buildDir}
7.在项目根目录执行命令
gradle cleangradle build --info
即可生成所需要的文件
8.开始发布项目,先登录JCenter,拷贝你自己的ApiKey,写进刚才的配置文件local.properties中去
在根目录输入命令开始上传
gradle bintrayUpload
9.进入JCenter后台配置
点击进入,可以看到我们发布的项目啦
10.进入详情,点击添加到JCenter中去
填写号相应的Comments信息,点击Send然后就等待审核完成了
小结:
1.Windows下的命令貌似是gradlew开头的
2.之前在根目录下配置build.gradle,
使用这个没有通过classpath 'com.github.dcendents:android-maven-plugin:1.2'改成这个就好了classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
参考:
https://www.virag.si/2015/01/publishing-gradle-android-library-to-jcenter/http://www.jcodecraeer.com/a/anzhuokaifa/Android_Studio/2015/0227/2502.html
阅读全文
0 0
- 使用Gradle发布项目到JCenter仓库
- 使用Gradle发布项目到JCenter仓库
- Gradle发布项目到JCenter仓库
- 使用Gradle发布项目到JCenter仓库
- 使用Gradle发布项目到JCenter仓库
- 使用Gradle发布项目到JCenter仓库
- Gradle发布项目到JCenter仓库
- 使用Gradle发布aar项目到JCenter仓库
- 使用Gradle发布aar项目到JCenter仓库
- Andriod Studio 使用Gradle发布项目到JCenter仓库
- 使用Gradle发布aar项目到JCenter仓库
- 使用Gradle发布aar项目到JCenter仓库
- 使用Gradle发布aar到Jcenter仓库
- 使用Gradle发布项目到JCenter
- 利用Gradle发布项目到JCenter、Maven
- 写开源项目用Gradle发布到jcenter
- Gradle项目快速发布到Jcenter(一)
- Gradle项目快速发布到Jcenter(二)
- git入门
- EJB3.0+WebLogic操作文档
- DonMin-2017-6-1-day06
- iOS UI学习之路01
- 多线程知识巩固(三)
- Gradle发布项目到JCenter仓库
- Android中View的相关知识(5)
- stm32f103zet6时钟
- Redmine的安装、总结和心得
- https原理
- 谈谈final, finally, finalize的区别
- 学习习近平总书记系列重要讲话精神
- uboot Makefile 分析
- c#连接mysql