8种机械键盘轴体对比
本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选?
第一次发布项目到jcenter,虽然网上有很多教程了,但是过程还是比较曲折。不过最终还是找到简单的方式,使用com.novoda.bintray-release实现发布。
认识jcenter
我们经常在android studio项目中看到:1
2
3
4
5allprojects {
repositories {
jcenter()
}
}
那么jcenter到底是什么呢?
我们可以将jcenter理解为代码仓库。如果我们在builde.gradle文件中设置例如:1compile 'com.google.code.gson:gson:2.3.1'
这时,Android Studio或者说Gradle会自动从jcenter下载 gson的jar包(实际上Maven packages,但是我们主要关心是jar或者aar),这样我们就可以在项目中使用gson了。不需要手动下载jar包然后导入到项目中了。
我们在文件夹下面(.gradle/caches/modules-2/files-2.1,这个路径我电脑下的)找到这些由gradle下载的文件,像这样:
不过我们一般不用关心这些,只要项目能自动导入依赖就好了。
如果你想关心这些文件在哪里也没关系。
(走偏了,回来。。)
所以,我们就能大致明白了这个jcenter是干什么的。那么来确定一下吧:
主要就是说:JCenter is the place to find and share popular Apache Maven packages for use by Maven, Gradle, Ivy, SBT, etc.
提供Maven, Gradle, Ivy, SBT等查找和分享Apache Maven packages的地方
Bintray, your platform for automated software distribution
当然jcenter只是bintray下的一个maven packages repository
bintray不只支持maven packages 还支持其他类型:
了解完jcenter我们就开始吧!
账号注册要把项目发布到jcenter我们需要先注册bintray的账号,https://bintray.com,我是通过GitHub账号注册的。(这一步基本没什么问题)
然后获取API key (图)
记下API key 发布的时候使用
添加package
其中,name :包名字
例如:1'com.android.tools.build:gradle:1.5.0'
gradle 就是名字。
配置项目1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.novoda:bintray-release:0.3.4'
}
}
allprojects {
repositories {
jcenter()
}
}
ext {
userOrg = 'qinglinyi'
groupId = 'com.qinglinyi.arg'
description = 'fragment arg'
publishVersion = '1.0.0'
website = 'https://github.com/qinglinyi/FragmentArg'
dryRun = 'false'
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16apply plugin: 'java'
apply plugin: 'com.novoda.bintray-release'
publish {
artifactId = 'arg-api' // library的名字
userOrg = rootProject.userOrg //用户所在组织
groupId = rootProject.groupId // 包名
publishVersion = rootProject.publishVersion // 版本
description = rootProject.description // 描述
website = rootProject.website
bintrayUser = rootProject.bintrayUser // 账户名
bintrayKey = rootProject.bintrayKey // 就是API key
dryRun = rootProject.dryRun
}
运行发布
点击Gradle的命令工具
如果成功会在网站上看到:
证明发布成功了
这样我们就能够使用了,但是这个只是在我们自己的仓库中,还没到jcenter。1
2
3
4
5
6
7
8
9allprojects {
repositories {
maven {
url 'https://dl.bintray.com/qinglinyi/maven'
}
jcenter()
}
}
这个地址你可以在网站上复制一下或者使用这个地址的中名字改成自己的就可以了。
复制在这里:
添加到jcenter
最后我们将包添加到jcenter中,添加成功时候我们就不需要添加自己的maven地址了。
通过可能需要一些时间,注册查看通知。
成功之后,是这样的
大功告成!!
补充
发布jcenter之后如果需要上传到Maven Center的话,需要修改maven仓库首页的GPG
然后才能在这里同步到maven center
同时,提交到maven的时候bintray-release 插件有一个问题
如果发布成功可以在这里检查:
参考