@@ -32,30 +32,44 @@ allprojects {
32
32
mavenLocal()
33
33
}
34
34
35
- // Skip Javadoc generation for Java 1.8 as it breaks build
36
- if (JavaVersion .current().isJava8Compatible) {
37
- tasks.withType<Javadoc > {
38
- options {
39
- this as StandardJavadocDocletOptions
40
- addStringOption(" Xdoclint:none" , " -quiet" )
41
- }
42
- }
43
- }
44
-
45
35
if ((group as String ).isNotEmpty() && name != " lint" && name != " internal" ) {
46
36
configureAndroid()
47
37
configureQuality()
48
38
49
- val isLibrary = name == " library"
50
39
if (Config .submodules.contains(name) || isLibrary) {
51
- setupPublishing(isLibrary)
40
+ setupPublishing()
41
+ }
42
+ }
43
+ }
44
+
45
+ // Skip Javadoc generation for Java 1.8 as it breaks build
46
+ if (JavaVersion .current().isJava8Compatible) {
47
+ tasks.withType<Javadoc > {
48
+ options {
49
+ this as StandardJavadocDocletOptions
50
+ addStringOption(" Xdoclint:none" , " -quiet" )
52
51
}
53
52
}
54
53
}
55
54
56
55
val Project .configDir get() = " $rootDir /library/quality"
57
56
val Project .reportsDir get() = " $buildDir /reports"
58
57
58
+ /* *
59
+ * Determines if a Project is the 'library' module
60
+ */
61
+ val Project .isLibrary get() = name == " library"
62
+
63
+ /* *
64
+ * Returns the maven artifact name for a Project.
65
+ */
66
+ val Project .artifactName get() = if (isLibrary) " firebase-ui" else " firebase-ui-${this .name} "
67
+
68
+ /* *
69
+ * Returns the name for a Project's maven publication.
70
+ */
71
+ val Project .publicationName get() = if (isLibrary) " monolithLibrary" else " ${name} Library"
72
+
59
73
fun Project.configureAndroid () {
60
74
if (name == " app" || name == " proguard-tests" ) {
61
75
apply (plugin = " com.android.application" )
@@ -113,9 +127,8 @@ fun Project.configureQuality() {
113
127
}
114
128
}
115
129
116
- fun Project.setupPublishing (isLibrary : Boolean ) {
117
- val publicationName = if (isLibrary) " monolithLibrary" else " ${name} Library"
118
- val artifactName = if (isLibrary) " firebase-ui" else " firebase-ui-${project.name} "
130
+ fun Project.setupPublishing () {
131
+ println (" Configuring publishing for ${this } " )
119
132
120
133
val sourcesJar = task<Jar >(" sourcesJar" ) {
121
134
classifier = " sources"
@@ -138,7 +151,7 @@ fun Project.setupPublishing(isLibrary: Boolean) {
138
151
artifacts.add(" archives" , sourcesJar)
139
152
140
153
tasks.whenTaskAdded {
141
- if (name.contains(" publish" ) && name.contains(" publication" , true )) {
154
+ if (name.toLowerCase(). contains(" publish" ) && name.contains(" publication" , true )) {
142
155
dependsOn(" assembleRelease" )
143
156
}
144
157
}
@@ -189,7 +202,6 @@ fun Project.setupPublishing(isLibrary: Boolean) {
189
202
190
203
apply (plugin = " maven-publish" )
191
204
apply (plugin = " com.jfrog.artifactory" )
192
- apply (plugin = " com.jfrog.bintray" )
193
205
194
206
configure<PublishingExtension > {
195
207
repositories {
@@ -210,6 +222,7 @@ fun Project.setupPublishing(isLibrary: Boolean) {
210
222
// We need to override the variables 'group' and 'version' on the 'Project' object in order
211
223
// to prevent the bintray plugin from creating 'unspecified' artifacts.
212
224
val groupName = " com.firebaseui"
225
+ val projectName = name
213
226
group = groupName
214
227
version = Config .version
215
228
@@ -219,55 +232,19 @@ fun Project.setupPublishing(isLibrary: Boolean) {
219
232
artifactId = artifactName
220
233
version = Config .version
221
234
222
- artifact(" $buildDir /outputs/aar/${project.name} -release.aar" )
235
+ val releaseAar = " $buildDir /outputs/aar/${projectName} -release.aar"
236
+
237
+ artifact(releaseAar)
223
238
artifact(javadocJar)
224
239
artifact(sourcesJar)
225
240
226
- pom {
227
- name.set(" FirebaseUI ${project.name.capitalize()} " )
228
- description.set(" Firebase UI for Android" )
229
- url.set(" https://github.com/firebase/FirebaseUI-Android" )
230
-
231
- organization {
232
- name.set(" Firebase" )
233
- url.set(" https://github.com/firebase" )
234
- }
235
-
236
- scm {
237
- val scmUrl
= " scm:git:[email protected] /firebase/firebaseui-android.git"
238
- connection.set(scmUrl)
239
- developerConnection.set(scmUrl)
240
- url.set(this @pom.url)
241
- tag.set(" HEAD" )
242
- }
243
-
244
- developers {
245
- developer {
246
- id.set(" samtstern" )
247
- name.set(" Sam Stern" )
248
-
249
- organization.set(" Firebase" )
250
- organizationUrl.set(" https://firebase.google.com" )
251
- roles.set(listOf (" Project-Administrator" , " Developer" ))
252
- timezone.set(" -8" )
253
- }
254
-
255
- developer {
256
- id.set(" SUPERCILEX" )
257
- name.set(" Alex Saveau" )
258
-
259
- roles.set(listOf (" Developer" ))
260
- timezone.set(" -8" )
261
- }
262
- }
263
-
264
- licenses {
265
- license {
266
- name.set(" The Apache License, Version 2.0" )
267
- url.set(" https://www.apache.org/licenses/LICENSE-2.0.txt" )
268
- }
269
- }
241
+ println (" Creating maven publication $publicationName " )
242
+ println (" \t group: $groupName " )
243
+ println (" \t artifact: $artifactName " )
244
+ println (" \t version: $version " )
245
+ println (" \t aar: $releaseAar " )
270
246
247
+ pom {
271
248
withXml {
272
249
asNode().appendNode(" dependencies" ).apply {
273
250
fun Dependency.write (scope : String ) = appendNode(" dependency" ).apply {
@@ -288,6 +265,54 @@ fun Project.setupPublishing(isLibrary: Boolean) {
288
265
dependency.write(" runtime" )
289
266
}
290
267
}
268
+
269
+ // Common values
270
+ val repoUrl = " https://github.com/firebase/FirebaseUI-Android"
271
+ val scmUrl
= " scm:git:[email protected] /firebase/firebaseui-android.git"
272
+
273
+ // Name
274
+ asNode().appendNode(" name" , artifactId)
275
+
276
+ // Description
277
+ asNode().appendNode(" description" , " Firebase UI for Android" )
278
+
279
+ // Organization
280
+ asNode().appendNode(" organization" ).apply {
281
+ appendNode(" name" , " FirebaseUI" )
282
+ appendNode(" url" , repoUrl)
283
+ }
284
+
285
+ // URL
286
+ asNode().appendNode(" url" , repoUrl)
287
+
288
+ // SCM
289
+ asNode().appendNode(" scm" ).apply {
290
+ appendNode(" connection" , scmUrl)
291
+ appendNode(" developerConnection" , scmUrl)
292
+ appendNode(" url" , repoUrl)
293
+ appendNode(" tag" , " HEAD" )
294
+ }
295
+
296
+ // Developers
297
+ asNode().appendNode(" developers" ).appendNode(" developer" ).apply {
298
+ appendNode(" id" , " samtstern" )
299
+ appendNode(
" email" ,
" [email protected] " )
300
+ appendNode(" organization" , " Firebase" )
301
+ appendNode(" organizationUrl" , " https://firebase.google.com" )
302
+
303
+ appendNode(" roles" ).apply {
304
+ appendNode(" role" , " Project-Administrator" )
305
+ appendNode(" role" , " Developer" )
306
+ }
307
+
308
+ appendNode(" timezone" , " -8" )
309
+ }
310
+
311
+ // Licenses
312
+ asNode().appendNode(" licenses" ).appendNode(" license" ).apply {
313
+ appendNode(" name" , " The Apache License, Version 2.0" )
314
+ appendNode(" url" , " http://www.apache.org/licenses/LICENSE-2.0.txt" )
315
+ }
291
316
}
292
317
}
293
318
}
@@ -310,20 +335,50 @@ fun Project.setupPublishing(isLibrary: Boolean) {
310
335
311
336
tasks.withType<ArtifactoryTask > { publications(publicationName) }
312
337
338
+ apply (plugin = " com.jfrog.bintray" )
339
+
313
340
configure<BintrayExtension > {
341
+
314
342
user = bintrayUsername
315
343
key = bintrayKey
316
344
setPublications(publicationName)
317
345
setConfigurations(" archives" )
318
346
347
+ println (" Bintray configuration for ${publicationName} " )
348
+ println (" \t artifact: ${artifactName} " )
349
+ publications.forEach { pubName ->
350
+ println (" \t pub: $pubName " )
351
+
352
+ val publ = project.extensions
353
+ .getByType(PublishingExtension ::class .java)
354
+ .publications.findByName(pubName) as MavenPublication
355
+
356
+ publ.artifacts.forEach { art ->
357
+ println (" \t\t pub_artifact: $art " )
358
+ }
359
+ }
360
+ configurations.forEach { config ->
361
+ println (" \t config: $config " )
362
+
363
+ project.configurations.findByName(config)?.allArtifacts?.forEach { art ->
364
+ println (" \t\t config_artifact: $art " )
365
+ }
366
+ }
367
+
368
+ // When uploading, move and rename the generated POM
369
+ val pomSrc = " $buildDir /publications/$publicationName /pom-default.xml"
370
+ val pomDst = " com/firebaseui/$artifactName /${Config .version} /"
371
+ val pomName = " $artifactName -${Config .version} .pom"
372
+
373
+ println (" POM Transformation" )
374
+ println (" \t src: ${pomSrc} " )
375
+ println (" \t dst: ${pomDst} " )
376
+ println (" \t name: ${pomName} " )
377
+
319
378
filesSpec(closureOf<RecordingCopyTask > {
320
- from(if (isLibrary) {
321
- " $buildDir /publications/monolithLibrary/pom-default.xml"
322
- } else {
323
- " $buildDir /publications/${project.name} Library/pom-default.xml"
324
- })
325
- into(" com/firebaseui/$artifactName /${Config .version} /" )
326
- rename(KotlinClosure1 <String , String >({ " $artifactName -${Config .version} .pom" }))
379
+ from(pomSrc)
380
+ into(pomDst)
381
+ rename(KotlinClosure1 <String , String >({ pomName }))
327
382
})
328
383
329
384
pkg(closureOf<BintrayExtension .PackageConfig > {
0 commit comments