android studio maven 仓库的使用
转自:http://www.cnblogs.com/sihaixuan/p/4852974.html
原文:How to distribute your own Android library through jCenter and Maven Central from Android Studio
转自:翻译 http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/0623/3097.html
博客:http://blog.csdn.net/jinyp/article/details/55095310
首先在maven上添加一个jcenter库。
如果你想在Android Studio中引入一个library到你的项目,你只需添加如下的一行代码到模块的build.gradle文件中。
这样就可以使用maven库上的library了。
1.我们需要把本地的library上传到jcenter服务器上,才可以使用maven.
2,开始上传首先我们在build.gradle上面添加两行代码:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0' // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
// 添加下面两行代码即可。
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
}
}
3.配置library里面的build.gradle
apply plugin: 'com.android.library'
// 这里添加下面两行代码。
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
// 项目引用的版本号,比如compile 'com.yanzhenjie:andserver:1.0.1'中的1.0.1就是这里配置的。
version = "1.1.1" // 定义两个链接,下面会用到。
def siteUrl = 'https://gitee.com/lixiangyang8080/zxing_lxy_module' // 项目主页。
def gitUrl = 'https://gitee.com/lixiangyang8080/zxing_lxy_module.git' // Git仓库的url。
// 唯一包名,比如compile 'com.yanzhenjie:andserver:1.0.1'中的com.yanzhenjie就是这里配置的。
group = "com.example.lenovo.zxing_lxy"
android {
compileSdkVersion 26
buildToolsVersion "26.0.1" defaultConfig {
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" }
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
} dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
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:26.+'
testCompile 'junit:junit:4.12'
compile files('libs/zxing-core-3.3.0.jar') }
install {
repositories.mavenInstaller {
// 生成pom.xml和参数
pom {
project {
packaging 'aar'
// 项目描述,复制我的话,这里需要修改。
name 'zxing For Android'// 可选,项目名称。
description 'The Android build the framework of the Http server.'// 可选,项目描述。
url siteUrl // 项目主页,这里是引用上面定义好。 // 软件开源协议,现在一般都是Apache License2.0吧,复制我的,这里不需要修改。
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
} //填写开发者基本信息,复制我的,这里需要修改。
developers {
developer {
id '278918014' // 开发者的id。
name '巷阳' // 开发者名字。
email '[lixiangyang8080@gmail.com]' // 开发者邮箱。
}
} // SCM,复制我的,这里不需要修改。
scm {
connection gitUrl // Git仓库地址。
developerConnection gitUrl // Git仓库地址。
url siteUrl // 项目主页。
}
}
}
}
}
// 生成jar包的task,不需要修改。
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
// 生成jarDoc的task,不需要修改。
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
// destinationDir = file("../javadoc/")
failOnError false // 忽略注释语法错误,如果用jdk1.8你的注释写的不规范就编译不过。
}
// 生成javaDoc的jar,不需要修改。
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
} // 这里是读取Bintray相关的信息,我们上传项目到github上的时候会把gradle文件传上去,所以不要把帐号密码的信息直接写在这里,写在local.properties中,这里动态读取。
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
bintray {
user = properties.getProperty("bintray.user") // Bintray的用户名。
key = properties.getProperty("bintray.apikey") // Bintray刚才保存的ApiKey。 configurations = ['archives']
pkg {
repo = "lxy-like" // 上传到maven库。(这里要特别注意,如果写了maven报404错误,请在bintray创建一个仓库,这里填改成你创建的仓库的名字,如何创建请看下图。)
name = "zxing-lxy" // 发布到Bintray上的项目名字,这里的名字不是compile 'com.yanzhenjie:andserver:1.0.1'中的andserver。
userOrg = '278918014' // Bintray的用户名,2016年11月更新。
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ["Apache-2.0"]
publish = true // 是否是公开项目。
}
}
4.配置local.properties
5.配置,上传。
6.在bintray的网页上检查一下你的package。你会发现在版本区域的变化。
7.点击进去,进入Files选项卡,你会看见那里有我们所上传的library文件。
恭喜,你的library终于放在了互联网上,任何人都可以使用了!
不过也别高兴过头,library现在仍然只是在你自己的Maven仓库,而不是在jcenter上。如果有人想使用你的library,他必须定义仓库的url,如下:
8.同步bintray用户仓库到jcenter
9.什么也不做直接点击Send。
现在我们所能做的就是等待bintray团队审核我们的请求,大概2-3个小时。一旦同步的请求审核通过,你会收到一封确认此更改的邮件。现在我们去网页上确认,你会在 Linked To 部分看到一些变化。
10.搞定。
android studio maven 仓库的使用的更多相关文章
- Android studio Maven仓库使用
原文:How to distribute your own Android library through jCenter and Maven Central from Android Studio ...
- 推荐几款实用的Android Studio 插件
推荐几款实用的Android Studio 插件 泡在网上的日子 发表于 2015-10-09 10:47 第 17453 次阅读 插件,Android Studio 10 编辑推荐:稀土掘金,这是一 ...
- Android Studio美化之优雅的logcat
博客: 安卓之家 微博: 追风917 CSDN: 蒋朋的家 简书: 追风917 博客园: 追风917 先来个图,图样吐sexy: 很简单,跟我走吧,两步: 1. 引入Logger库 首先,这个sexy ...
- Android Studio开发快速创建MVP框架插件AndroidMVP
转载:https://www.jianshu.com/p/60cd98bbc358 Android开发中,我们为了代码的解耦以及后期的维护方便,都会采用一些开发框架,常用的有MVC.MVP.MVVM. ...
- 拥抱 Android Studio 之四:Maven 仓库使用与私有仓库搭建
使用.创造和分享 笔者曾经不思量力的思考过『是什么推动了互联网技术的快速发展?』这种伟大的命题.结论是,除了摩尔定律之外,技术经验的快速积累和广泛分享,也是重要的原因. 有人戏称,『写 Java,首先 ...
- android studio发布公共类库到服务器maven仓库
在上一篇中提到了怎么创建私有maven库,这篇主要结合android studio的使用,直接进入正题,看以下步骤 1.创建android项目 创建Project,然后加一个library的modul ...
- Android Studio使用阿里云Aliyun Maven仓库
如下所示,在build.gradle中添加Aliyun Maven仓库 // Top-level build file where you can add configuration options ...
- 【转】如何使用Android Studio把自己的Android library分发到jCenter和Maven Central
转自:http://www.devtf.cn/?p=760&utm_source=tuicool 如何使用Android Studio把自己的Android library分发到jCenter ...
- 如何通过Android Studio发布library到jCenter和Maven Central
http://www.jianshu.com/p/3c63ae866e52# 在Android Studio里,如果你想引入任何library到自己的项目中,只需要很简单的在module的build. ...
随机推荐
- Mysql 函数使用记录(三)——UNIX_TIMESTAMP() 、UNIX_TIMESTAMP(date)
参考资料:https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_unix-timestamp UN ...
- zipkin启动报错(Caused by: java.lang.ClassNotFoundException: zipkin.Component)的解决方法
使用ziplin依赖: <dependency> <groupId>org.springframework.cloud</groupId> <artifact ...
- 读书笔记《Spring Boot实战 —— Java EE 开发的颠覆者》
Spring框架是轻量级的企业级开发一站式解决方案 Spring使用简单的POJO Plain Old Java Object 无限制的普通Java对象 Spring Framework Runtim ...
- 【转】VC 利用DLL共享区间在进程间共享数据及进程间广播消息
1.http://blog.csdn.net/morewindows/article/details/6702342 在进程间共享数据有很多种方法,剪贴板,映射文件等都可以实现,这里介绍用DLL的共享 ...
- include
1. 自己写的文件都用:include "....." 2. 如果A类include了B,那么在主函数中,只用include A类,就可以使用B类了,但是此时不能再include ...
- Django - Python3 配置 MySQL
在使用 PyMySQL 之前,我们需要确保 PyMySQL 已安装 具体安装使用方法,可参考 Python3 - MySQL适配器 PyMySQL Django 如何链接 MySQL 数据库, 需要在 ...
- Unity--- 纹理设置属性 alphaIsTransparency
官方的解释: 意思就是没什么实际效果,只是用做显示用. 参考:https://docs.unity3d.com/ScriptReference/Texture2D-alphaIsTransparenc ...
- 日常英语---十二、MapleStory/Monsters/Level 1-10(Horny Mushroom)
日常英语---十二.MapleStory/Monsters/Level 1-10(Horny Mushroom) 一.总结 一句话总结: horny-['hɔːnɪ]-adj.角的 Another m ...
- Linux 各种软件的安装-mediawiki + wordpress篇
php apache mysql 三剑客安装好后,可以愉快地安装一些成熟的web应用啦,比如wordpress可以当做自己的笔记本,mediawiki整理知识库. 首先是mediawiki,网上说不错 ...
- Python 编程快速上手 第六章总结
第六章 字符串操作 前言 这一章节讲了关于 Python 中字符串类型的知识.与字符串有关的操作符,方法等等. 处理字符串:字符串的写入.打印.访问的知识 原始字符串 格式:r'string'作用:在 ...