• Stars
    star
    149
  • Rank 248,619 (Top 5 %)
  • Language
  • Created almost 10 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Gradle scripts to publish aar.

gradle-publish

Introduction

This project includes some gradle scripts that can publish gradle project to JCenter.

bintray.gradle: A script to publish an android gradle project to JCenter.

build.gradle: A demo about how to use it.

gradle.properties: The properties that will be used in bintray.gradle. You are needed to copy this file into your library project and configure the values of these properties.

How To Use

1. Save bintray user and API Key infos

First, you should have one bintray account,(bintray.com) and need save the account user name and API Key info to your .gradle folder. If you havent change the GRADLE_USER_HOME position, it will be under your User folder. In this folder, add the follow infos to gradle.properties file, create it if it doesn`t exist.

BINTRAY_USER=bintray account name
BINTRAY_KEY=bintray API Key

If your OS is Windows, then, the path will be C:\Documents and Settings\YourName\.gradle for XP, and C:\Users\YourName\.gradle for WIN7+.

2. modify build.gradle in your library module

Add the dependencies section into build.gradle in your library if it doesn't already exist:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
    }
}

Note: The Gradle version I use is 2.14.1. For the other version, you may need to upgrade or downgrade the android-maven-gradle-plugin or gradle-bintray-plugin version.

Then you need download the bintray.gradle into your library project, and add the following to the bottom of your build.gradle file:

apply from: './bintray.gradle'

3. setup gradle.properties in your library module

Copy the gradle.properties(which is in this project, not the one we modified in step 1) file to your library module, Click Here to copy it. Then setup it as your needed. Follow is an example,

PROJ_GROUP=com.philcalvin
PROJ_VERSION=1.1.0
PROJ_NAME=iconbutton
PROJ_WEBSITEURL=https://github.com/pnc/IconButton
PROJ_ISSUETRACKERURL=
[email protected]:pnc/IconButton.git
PROJ_DESCRIPTION=android icon button
PROJ_ARTIFACTID=com-phillipcalvin-iconbutton

DEVELOPER_ID=pnc
DEVELOPER_NAME=Phil Calvin
[email protected]

The final useage for this example in Android Studio will be:

dependencies {
    compile 'com.philcalvin:com-phillipcalvin-iconbutton:1.1.0'
}

You can see, the format will be PROJ_GROUP:PROJ_ARTIFACTID:PROJ_VERSION.

4. run publish command

Execute gradle bintrayUpload to publish artifacts to bintray.com.

gradle bintrayUpload

Execute gradle artifactoryPublish to publish SNAPSHOT version to oss.jfrog.org.

gradle artifactoryPublish

5. add library to Jcenter

Send a request to bintray.com about adding the library to Jcenter, after the request be approved, others can use your library by one line code in their build.gradle files.

Contributors

Special thanks to:


介绍

本项目包含一些Gradle脚本及属性文件,用于使用Gradle发布项目.

bintray.gradle: 用于发布到JCenter的脚本。

build.gradle: 怎么使用它的Demo.

gradle.properties: 在bintray.gradle中要用到的属性,需要拷贝到你的项目中并进行配置。

如何使用

1. 保存bintray账号信息

首先注册bintray账号,地址:https://bintray.com/ ,账号生成后会自动为你分配一个API Key,账号名以及API Key是我们能够上传库到bintray的钥匙。 我们需要将这些信息存到本地,也就是你的系统.gradle目录,这里要注意,我们保存在系统下,而不是你的project下的.gradle目录,如果你没有配置过GRADLE_USER_HOME的环境变量,则是在你的用户目录下,编辑gradle.properties(如果没有则创建),加入配置:

BINTRAY_USER=bintray account name
BINTRAY_KEY=bintray API Key

并且你的OS是Windows, 并且是XP,那么一般是在 C:\Documents and Settings\用户名\.gradle,而如果是win7以上,那么是在c:\Users\用户名\.gradle

2. 修改library目录下的build.gradle文件

首先在你的library项目中创建bintray.gradle文件,把本项目中的bintray.gradle文件内容拷贝进入,然后在你的library项目的build.gradle添加以下的构建脚本依赖:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
    }
}

接着在这个build.gradle底部添加以下代码:

apply from: './bintray.gradle'

3. 配置library目录下的gradle.properties

复制本项目下的 gradle.properties文件(注意不是第二步中修改的那个文件)到你的library目录下, 点 Here 直接复制。 接下来对内容进行配置,下面是一个例子:

PROJ_GROUP=com.philcalvin
PROJ_VERSION=1.1.0
PROJ_NAME=iconbutton
PROJ_WEBSITEURL=https://github.com/pnc/IconButton
PROJ_ISSUETRACKERURL=
[email protected]:pnc/IconButton.git
PROJ_DESCRIPTION=android icon button
PROJ_ARTIFACTID=com-phillipcalvin-iconbutton

DEVELOPER_ID=pnc
DEVELOPER_NAME=Phil Calvin
[email protected]

上面的例子最终在Android Studio中的引用形式为:

dependencies {
    compile 'com.philcalvin:com-phillipcalvin-iconbutton:1.1.0'
}

可以发现,它的格式是 PROJ_GROUP:PROJ_ARTIFACTID:PROJ_VERSION组成。

4. 执行发布命令

执行 gradle bintrayUpload 将库发布到 bintray.com.

gradle bintrayUpload

执行 gradle artifactoryPublish 可以发布版本到 oss.jfrog.org.

gradle artifactoryPublish

5. 将库加入Jcenter

最后一步,需要登录bintray.com,将我们刚刚发布的库申请加入到jcenter,这样别人才能直接引用到。

特别鸣谢

More Repositories

1

status-bar-compat

A compatible library for setting status bar color. Support MIUI, Flyme, EMUI3.1. 一行代码调用,布局零入侵。兼容小米,魅族,华为……
Java
995
star
2

android-crash

[DEPRECATED] android程序崩溃异常处理框架
Java
201
star
3

gradledoc

Gradle 中文文档
193
star
4

androidkit

【已停止维护,请勿fork】android开发框架,可以帮助你大量提高android应用开发效率。
Java
163
star
5

android-proguard-cn

Android混淆规则
IDL
125
star
6

IconTabPageIndicator

带图标文字的ViewPager导航指示器
Java
86
star
7

clip-image

ClipImageView liks wechat avatar cropper
Java
85
star
8

group-recycler-adapter

A RecyclerView adapter to show grouped data
Java
75
star
9

StepView

StepView for android
Java
49
star
10

rank-github-china

Github 中国区排名
Kotlin
39
star
11

AndroidSnippet

Android code snippets
Java
35
star
12

androiddoc

[DEPRECATED]加速打开Android文档的项目。
JavaScript
27
star
13

AndroidPNClient

Base on Androidpn. A android push notification framework based broadcast.
Java
13
star
14

fir-publisher

Gradle plugin for publish apk to fir.im
Groovy
13
star
15

hi-loadmore

Android通用上拉加载布局。
Java
11
star
16

scripts

Some scripts.
Shell
10
star
17

behavior-master

自定义Behavior集合
Java
10
star
18

gradle-doc-apk

Gradle UserGuide apk.
Java
9
star
19

apkUtil

a util to get application info from a apk file
Java
8
star
20

badge-drawable

Kotlin
8
star
21

dinny

Dinny is a library to implement the idea of protocol Activity jumps
Java
7
star
22

kotlin-guides-cn

https://github.com/android/kotlin-guides 的中文翻译
CSS
7
star
23

ActionSheet

ActionSheet for Android.
Java
7
star
24

DrawableWidget

可以在XML中定义drawableLeft, drawableRight等的大小的控件
Java
7
star
25

gradle-translation

Gradle 文档的中文翻译OmegaT项目。
HTML
5
star
26

sophix-patch-tool

3
star
27

hi-chart

Java
3
star
28

dockerfile

Shell
3
star
29

360-jiagu

360加固打包
Shell
2
star
30

tencent-library

1
star
31

SuperLog

A log util for android.
Java
1
star
32

angle

Fork from ANGLE -r86
Java
1
star
33

MetaCOS

MetaCOS
Java
1
star
34

RefreshListView

带下拉刷新,上拉加载,自动加载等功能的ListView。改自寒枫的RefreshListView
Java
1
star