forked from firebase/FirebaseUI-Android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
262 lines (212 loc) · 9.45 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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
buildscript {
apply from: 'constants.gradle'
repositories {
google()
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath 'com.google.gms:google-services:3.1.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
}
}
allprojects {
repositories {
google()
jcenter()
mavenLocal()
mavenCentral()
}
}
//Skip Javadoc generation for Java 1.8 as it breaks build
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
/**
* Configure common tasks on all the submodules
*/
allprojects { project ->
// Get constants, this is where we store things
// like the list of submodules or the version
project.apply from: "$rootDir/constants.gradle"
def isLibrary = 'library'.equals(project.name)
def isSubmodule = submodules.contains(project.name)
if (isLibrary || isSubmodule) {
tasks.whenTaskAdded { task ->
if (task.name.contains("publish") && task.name.toLowerCase().contains("publication")) {
task.dependsOn 'assemble'
}
}
// So that we can resolve 'android' variable
project.apply plugin: 'com.android.library'
android {
compileSdkVersion compileSdk
}
// Task to generate sources JAR
task sourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
// Task to generate javadoc
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += configurations.compile
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
// Task to generate javadoc JAR
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
// Define base name for archives
// Ex: firebase-ui-auth
archivesBaseName = isSubmodule ? "firebase-ui-${project.name}" : "firebase-ui"
// Use tasks above to define artifacts
artifacts {
archives javadocJar
archives sourcesJar
}
// So that we can define publication
project.apply plugin: 'maven-publish'
publishing {
// By passing -Pcustom_local=/some/path and running the
// publishLibraryPublicationToCustomLocalRepository task you can publish this library to a
// custom maven repository location on your machine.
repositories {
maven {
name 'CustomLocal'
url uri(project.hasProperty('custom_local') ? project.getProperty('custom_local') : '/tmp/')
}
}
repositories {
maven {
name 'BuildLocal'
url "$buildDir/repo"
}
}
}
// POM to meet maven specs
def publicationName = isLibrary ? 'monolithLibrary' : "${project.name}Library"
def archivesBaseName = isLibrary ? 'firebase-ui' : "firebase-ui-${project.name}"
publishing {
publications {
"${publicationName}"(MavenPublication) {
groupId group
artifactId archivesBaseName
version version
artifact "$buildDir/outputs/aar/$archivesBaseName-release.aar"
artifact javadocJar
artifact sourcesJar
pom.withXml {
// Dependencies
def dependenciesNode = asNode().getAt("dependencies")[0]
if (dependenciesNode == null) {
dependenciesNode = asNode().appendNode("dependencies")
}
configurations.api.dependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
if (submodules.contains(it.name)) {
dependencyNode.appendNode('artifactId', "firebase-ui-${it.name}")
} else {
dependencyNode.appendNode('artifactId', it.name)
}
dependencyNode.appendNode('version', it.version)
dependencyNode.appendNode('scope', 'compile')
}
configurations.implementation.dependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
if (submodules.contains(it.name)) {
dependencyNode.appendNode('artifactId', "firebase-ui-${it.name}")
} else {
dependencyNode.appendNode('artifactId', it.name)
}
dependencyNode.appendNode('version', it.version)
dependencyNode.appendNode('scope', 'runtime')
}
// Common values
def repoUrl = 'https://github.com/firebase/FirebaseUI-Android'
def scmUrl = 'scm:git:git@github.com/firebase/firebaseui-android.git'
// Name
asNode().appendNode('name', artifactId)
// Description
asNode().appendNode('description', 'Firebase UI for Android')
// Organization
def organization = asNode().appendNode('organization')
organization.appendNode('name', 'FirebaseUI')
organization.appendNode('url', repoUrl)
// URL
asNode().appendNode('url', repoUrl)
// SCM
def scm = asNode().appendNode('scm')
scm.appendNode('connection', scmUrl)
scm.appendNode('developerConnection', scmUrl)
scm.appendNode('url', repoUrl)
scm.appendNode('tag', 'HEAD')
// Developers
def developer = asNode().appendNode('developers').appendNode('developer')
developer.appendNode('id', 'samtstern')
developer.appendNode('email', 'samstern@google.com')
developer.appendNode('organization', 'Firebase')
developer.appendNode('organizationUrl', 'https://firebase.google.com')
def roles = developer.appendNode('roles')
roles.appendNode('role', 'Project-Administrator')
roles.appendNode('role', 'Developer')
developer.appendNode('timezone', '-8')
// Licenses
def license = asNode().appendNode('licenses').appendNode('license')
license.appendNode('name', 'The Apache License, Version 2.0')
license.appendNode('url', 'http://www.apache.org/licenses/LICENSE-2.0.txt')
}
}
}
}
// Bintray Configuration (applies to submodule and the monolith)
project.apply plugin: 'com.jfrog.bintray'
def pomLoc = isLibrary ? "$buildDir/publications/monolithLibrary/pom-default.xml" : "$buildDir/publications/${project.name}Library/pom-default.xml"
group = project.ext.group
version = project.ext.version
def versionName = project.ext.version
bintray {
user = hasProperty('BINTRAY_USER') ? getProperty('BINTRAY_USER') : System.getenv('BINTRAY_USER')
key = hasProperty('BINTRAY_KEY') ? getProperty('BINTRAY_KEY') : System.getenv('BINTRAY_KEY')
publications = [publicationName]
filesSpec {
from pomLoc
into "com/firebaseui/$archivesBaseName/$versionName/"
rename { String fileName ->
"${archivesBaseName}-${version}.pom"
}
}
configurations = ['archives']
pkg {
repo = 'firebase-ui'
name = archivesBaseName
userOrg = 'firebaseui'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/firebase/FirebaseUI-Android.git'
version {
name = versionName
}
}
}
}
}
allprojects {
afterEvaluate { project ->
def isSubmodule = submodules.contains(project.name)
if (isSubmodule) {
// Only applies to submodules, not the library module
def pomTask = "generatePomFileFor${project.name.capitalize()}LibraryPublication"
// Convenience task to prepare everything we need for releases
task prepareArtifacts(dependsOn: [javadocJar, sourcesJar, assembleRelease, pomTask]) {}
}
}
}