@@ -46,16 +46,30 @@ allprojects {
46
46
configureAndroid()
47
47
configureQuality()
48
48
49
- val isLibrary = name == " library"
50
49
if (Config .submodules.contains(name) || isLibrary) {
51
- setupPublishing(isLibrary )
50
+ setupPublishing()
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-$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,10 +127,7 @@ 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} "
119
-
130
+ fun Project.setupPublishing () {
120
131
val sourcesJar = task<Jar >(" sourcesJar" ) {
121
132
classifier = " sources"
122
133
from(project.the<BaseExtension >().sourceSets[" main" ].java.srcDirs)
@@ -185,6 +196,8 @@ fun Project.setupPublishing(isLibrary: Boolean) {
185
196
dependsOn(javadocJar, sourcesJar, " assembleRelease" , pomTask)
186
197
}
187
198
}
199
+
200
+ tasks[" bintrayUpload" ].dependsOn(" prepareArtifacts" )
188
201
}
189
202
190
203
apply (plugin = " maven-publish" )
@@ -219,55 +232,21 @@ 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/${project.name} -release.aar"
236
+
237
+ logger.info("""
238
+ |Creating maven publication '$publicationName '
239
+ | Group: $groupName
240
+ | Artifact: $artifactName
241
+ | Version: $version
242
+ | Aar: $releaseAar
243
+ """ .trimMargin())
244
+
245
+ artifact(releaseAar)
223
246
artifact(javadocJar)
224
247
artifact(sourcesJar)
225
248
226
249
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
- }
270
-
271
250
withXml {
272
251
asNode().appendNode(" dependencies" ).apply {
273
252
fun Dependency.write (scope : String ) = appendNode(" dependency" ).apply {
@@ -288,14 +267,64 @@ fun Project.setupPublishing(isLibrary: Boolean) {
288
267
dependency.write(" runtime" )
289
268
}
290
269
}
270
+
271
+ // Common values
272
+ val repoUrl = " https://github.com/firebase/FirebaseUI-Android"
273
+ val scmUrl
= " scm:git:[email protected] /firebase/firebaseui-android.git"
274
+
275
+ // Name
276
+ asNode().appendNode(" name" , artifactId)
277
+
278
+ // Description
279
+ asNode().appendNode(" description" , " Firebase UI for Android" )
280
+
281
+ // Organization
282
+ asNode().appendNode(" organization" ).apply {
283
+ appendNode(" name" , " FirebaseUI" )
284
+ appendNode(" url" , repoUrl)
285
+ }
286
+
287
+ // URL
288
+ asNode().appendNode(" url" , repoUrl)
289
+
290
+ // SCM
291
+ asNode().appendNode(" scm" ).apply {
292
+ appendNode(" connection" , scmUrl)
293
+ appendNode(" developerConnection" , scmUrl)
294
+ appendNode(" url" , repoUrl)
295
+ appendNode(" tag" , " HEAD" )
296
+ }
297
+
298
+ // Developers
299
+ asNode().appendNode(" developers" ).appendNode(" developer" ).apply {
300
+ appendNode(" id" , " samtstern" )
301
+ appendNode(
" email" ,
" [email protected] " )
302
+ appendNode(" organization" , " Firebase" )
303
+ appendNode(" organizationUrl" , " https://firebase.google.com" )
304
+
305
+ appendNode(" roles" ).apply {
306
+ appendNode(" role" , " Project-Administrator" )
307
+ appendNode(" role" , " Developer" )
308
+ }
309
+
310
+ appendNode(" timezone" , " -8" )
311
+ }
312
+
313
+ // Licenses
314
+ asNode().appendNode(" licenses" ).appendNode(" license" ).apply {
315
+ appendNode(" name" , " The Apache License, Version 2.0" )
316
+ appendNode(" url" , " http://www.apache.org/licenses/LICENSE-2.0.txt" )
317
+ }
291
318
}
292
319
}
293
320
}
294
321
}
295
322
}
296
323
297
- val bintrayUsername = System .getProperty(" BINTRAY_USER" ) ? : System .getenv(" BINTRAY_USER" )
298
- val bintrayKey = System .getProperty(" BINTRAY_KEY" ) ? : System .getenv(" BINTRAY_KEY" )
324
+ val bintrayUsername = properties[" bintrayUser" ] as String?
325
+ ? : System .getProperty(" BINTRAY_USER" ) ? : System .getenv(" BINTRAY_USER" )
326
+ val bintrayKey = properties[" bintrayKey" ] as String?
327
+ ? : System .getProperty(" BINTRAY_KEY" ) ? : System .getenv(" BINTRAY_KEY" )
299
328
300
329
configure<ArtifactoryPluginConvention > {
301
330
setContextUrl(" https://oss.jfrog.org" )
@@ -314,16 +343,34 @@ fun Project.setupPublishing(isLibrary: Boolean) {
314
343
user = bintrayUsername
315
344
key = bintrayKey
316
345
setPublications(publicationName)
317
- setConfigurations(" archives" )
346
+
347
+ // When uploading, move and rename the generated POM
348
+ val pomSrc = " $buildDir /publications/$publicationName /pom-default.xml"
349
+ val pomDest = " com/firebaseui/$artifactName /${Config .version} /"
350
+ val pomName = " $artifactName -${Config .version} .pom"
351
+
352
+ val pubLog: (String ) -> String = { name ->
353
+ val publishing = project.extensions
354
+ .getByType(PublishingExtension ::class .java)
355
+ .publications[name] as MavenPublication
356
+ " '$name ': ${publishing.artifacts} "
357
+ }
358
+ logger.info("""
359
+ |Bintray configuration for '$publicationName '
360
+ | Artifact name: $artifactName
361
+ | Artifacts: ${publications.joinToString(transform = pubLog)}
362
+ """ .trimMargin())
363
+ logger.info("""
364
+ |POM transformation
365
+ | Src: $pomSrc
366
+ | Dest: $pomDest
367
+ | Name: $pomName
368
+ """ .trimMargin())
318
369
319
370
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" }))
371
+ from(pomSrc)
372
+ into(pomDest)
373
+ rename(KotlinClosure1 <String , String >({ pomName }))
327
374
})
328
375
329
376
pkg(closureOf<BintrayExtension .PackageConfig > {
0 commit comments