Android快速发布项目到jcenter

Android快速发布项目到jcenter

1.新建Bintray帐号
注意:邮箱不能使用qq邮箱和163邮箱

2.新建Repositories, name:maven type:Maven

Markdown

3.local.properties中添加

 

1

2

 

bintray.user=andwong001 //bintray用户名

bintray.apikey=xxxxxxxxxxxxxxxx //apikey

 

apikey的获取 : edit profile -> api key
Markdown

4.项目根目录build.gradle中添加:

 

1

2

 

classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'

classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'

 

完整代码如下:

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

 

buildscript {

repositories {

jcenter()

}

dependencies {

classpath 'com.android.tools.build:gradle:2.2.2'

//添加,后期版本号可能会过期,注意修改

classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'

classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'

// 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

}

 

5.moudle目录下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

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

 

apply plugin: 'com.android.library'

android {

compileSdkVersion 23

buildToolsVersion "23.0.2"

resourcePrefix "badger" //这个随便填

defaultConfig {

minSdkVersion 14

targetSdkVersion 23

versionCode 1

versionName "1.0"

}

buildTypes {

release {

minifyEnabled false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

}

}

}

dependencies {

compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:appcompat-v7:23.2.0'

}

//添加如下代码

apply plugin: 'com.github.dcendents.android-maven'

apply plugin: 'com.jfrog.bintray'

version = "1.0.0" //版本号

def siteUrl = 'https://github.com/AndWong/BadgerHelper' // 项目的主页

def gitUrl = 'https://github.com/AndWong/BadgerHelper.git' // Git仓库的url

group = "com.tool.badger" //一般填你唯一的包名

install {

repositories.mavenInstaller {

// This generates POM.xml with proper parameters

pom {

project {

packaging 'aar'

// Add your description here

name 'Android Util For Badger' //项目描述

url siteUrl

// Set your license

licenses {

license {

name 'The Apache Software License, Version 2.0'

url 'http://www.apache.org/licenses/LICENSE-2.0.txt'

}

}

developers {

developer {

id 'wong' //填写的一些基本信息

name 'andwong001'

email 'wonglife@yahoo.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" //

name = "Badger" //发布到JCenter上的项目名字

websiteUrl = siteUrl

vcsUrl = gitUrl

licenses = ["Apache-2.0"]

publish = true

}

}

 

6.Rebuild项目
并在项目根目录下执行:

 

1

2

 

$./gradlew install

$./gradlew bintrayUpload

 

7.完成后到Bintray网站的该项目点击 add to jCenter,等待审核
选择上传的项目
Markdown
打开后,会有一个 [Add to Jcenter]按钮,点击提交等待审核(一般1~2天就行)
下图是审核过的项目
Markdown

项目地址 : https://github.com/AndWong/BadgerHelper
请多多指教,多多start!

原文地址 : https://andwong.github.io/2017/03/18/Android%E5%BF%AB%E9%80%9F%E5%8F%91%E5%B8%83%E9%A1%B9%E7%9B%AE%E5%88%B0jcenter/

转载于:https://my.oschina.net/dwightwong/blog/861906

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值