forked from gzu-liyujiang/AndroidPicker
-
Notifications
You must be signed in to change notification settings - Fork 22
/
build.gradle
222 lines (191 loc) · 9.01 KB
/
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
//参考:https://raw.github.com/dm77/barcodescanner/master/build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:${GRADLE_BUILD_VERSION}"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:${GRADLE_BINTRAY_VERSION}"
}
}
allprojects {
group = PROJ_GROUP
version = PROJ_VERSION
repositories {
jcenter() //bintray的maven库
mavenCentral() //sonatype的maven库
flatDir {
dirs 'libs' //本地.aar文件
}
}
ext {
isLibrary = false
pomGroup = PROJ_GROUP
pomArtifactId = "library"
pomVersion = PROJ_VERSION
pomDescription = 'This is library description'
}
}
subprojects {
afterEvaluate { Project project ->
ext.pluginContainer = project.getPlugins()
def hasAppPlugin = ext.pluginContainer.hasPlugin("com.android.application")
def hasLibPlugin = ext.pluginContainer.hasPlugin("com.android.library")
if (hasAppPlugin || hasLibPlugin) {
android {
compileSdkVersion COMPILE_SDK_VERSION as int
buildToolsVersion BUILD_TOOL_VERSION
defaultConfig {
minSdkVersion MIN_SDK_VERSION as int
targetSdkVersion COMPILE_SDK_VERSION as int
versionCode VERSION_CODE as int
versionName VERSION_NAME
}
buildTypes {
release {
debuggable false
minifyEnabled false
proguardFile getDefaultProguardFile('proguard-android.txt')
}
debug {
debuggable true
minifyEnabled false
}
}
lintOptions {
abortOnError false
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/ASL2.0'
}
}
dependencies {
compile "com.android.support:support-v4:${BUILD_TOOL_VERSION}"
compile "com.android.support:support-annotations:${BUILD_TOOL_VERSION}"
}
}
if (project.isLibrary) {
configure(project) {
// 这个脚本是用来发布库项目到jcenter
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'
version = project.pomVersion //版本号
group = PROJ_GROUP // 包名
project.archivesBaseName = project.pomArtifactId
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += configurations.compile
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
exclude '**/BuildConfig.java'
exclude '**/R.java'
failOnError = false
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
javadoc {
options {
encoding "UTF-8"
charSet 'UTF-8'
author true
version true
links "http://docs.oracle.com/javase/7/docs/api"
title project.pomArtifactId
}
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId project.pomArtifactId
artifact "${buildDir}/outputs/aar/${project.name}-release.aar"
artifact javadocJar
artifact sourcesJar
pom.withXml {
Node root = asNode()
root.appendNode('name', project.pomArtifactId)
root.appendNode('description', project.pomDescription)
root.appendNode('url', PROJ_WEBSITE_URL)
def issues = root.appendNode('issueManagement')
issues.appendNode('system', 'github')
issues.appendNode('url', PROJ_ISSUE_URL)
def scm = root.appendNode('scm')
scm.appendNode('url', PROJ_GIT_URL)
scm.appendNode('connection', "scm:git:${PROJ_GIT_URL}")
scm.appendNode('developerConnection', "scm:git:${PROJ_GIT_URL}")
def license = root.appendNode('licenses').appendNode('license')
license.appendNode('name', "The Apache Software License, Version 2.0")
license.appendNode('url', "http://www.apache.org/licenses/LICENSE-2.0.txt")
license.appendNode('distribution', "repo")
def developer = root.appendNode('developers').appendNode('developer')
developer.appendNode('id', DEVELOPER_ID)
developer.appendNode('name', DEVELOPER_NAME)
developer.appendNode('email', DEVELOPER_EMAIL)
def dependenciesNode = root.appendNode('dependencies')
configurations.compile.allDependencies.each {
if (it.group && it.name && it.version) {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
}
afterEvaluate {
publishing.publications.mavenJava.artifact(bundleRelease)
}
bintray {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
publications = ['mavenJava']
publish = true //是否发布
pkg {
repo = "maven" //上传的中央仓库名称
name = project.pomArtifactId //发布到中央仓库上的项目名字
desc = project.pomDescription
websiteUrl = PROJ_WEBSITE_URL //项目主页
issueTrackerUrl = PROJ_ISSUE_URL //项目讨论页
vcsUrl = PROJ_GIT_URL //项目GIT仓库
licenses = ["Apache-2.0"]
publicDownloadNumbers = true
version {
name = project.pomVersion
desc = project.pomDescription
gpg {
sign = true //是否GPG签名,可使用Gpg4win创建密钥文件
passphrase = properties.getProperty("bintray.gpg.password")
//GPG签名所用密钥
}
mavenCentralSync {
sync = false //是否同步到Maven Central
user = properties.getProperty("sonatype.user") //sonatype用户名
password = properties.getProperty("sonatype.password")
//sonatype密码
close = '1'
}
}
}
}
}
}
}
}