@@ -32,30 +32,44 @@ allprojects {
3232 mavenLocal()
3333 }
3434
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-
4535 if ((group as String ).isNotEmpty() && name != " lint" && name != " internal" ) {
4636 configureAndroid()
4737 configureQuality()
4838
49- val isLibrary = name == " library"
5039 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" )
5251 }
5352 }
5453}
5554
5655val Project .configDir get() = " $rootDir /library/quality"
5756val Project .reportsDir get() = " $buildDir /reports"
5857
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+
5973fun Project.configureAndroid () {
6074 if (name == " app" || name == " proguard-tests" ) {
6175 apply (plugin = " com.android.application" )
@@ -113,9 +127,8 @@ fun Project.configureQuality() {
113127 }
114128}
115129
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 } " )
119132
120133 val sourcesJar = task<Jar >(" sourcesJar" ) {
121134 classifier = " sources"
@@ -138,7 +151,7 @@ fun Project.setupPublishing(isLibrary: Boolean) {
138151 artifacts.add(" archives" , sourcesJar)
139152
140153 tasks.whenTaskAdded {
141- if (name.contains(" publish" ) && name.contains(" publication" , true )) {
154+ if (name.toLowerCase(). contains(" publish" ) && name.contains(" publication" , true )) {
142155 dependsOn(" assembleRelease" )
143156 }
144157 }
@@ -189,7 +202,6 @@ fun Project.setupPublishing(isLibrary: Boolean) {
189202
190203 apply (plugin = " maven-publish" )
191204 apply (plugin = " com.jfrog.artifactory" )
192- apply (plugin = " com.jfrog.bintray" )
193205
194206 configure<PublishingExtension > {
195207 repositories {
@@ -210,6 +222,7 @@ fun Project.setupPublishing(isLibrary: Boolean) {
210222 // We need to override the variables 'group' and 'version' on the 'Project' object in order
211223 // to prevent the bintray plugin from creating 'unspecified' artifacts.
212224 val groupName = " com.firebaseui"
225+ val projectName = name
213226 group = groupName
214227 version = Config .version
215228
@@ -219,55 +232,19 @@ fun Project.setupPublishing(isLibrary: Boolean) {
219232 artifactId = artifactName
220233 version = Config .version
221234
222- artifact(" $buildDir /outputs/aar/${project.name} -release.aar" )
235+ val releaseAar = " $buildDir /outputs/aar/${projectName} -release.aar"
236+
237+ artifact(releaseAar)
223238 artifact(javadocJar)
224239 artifact(sourcesJar)
225240
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:git@github.com/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- email.set(" samstern@google.com" )
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- email.set(" saveau.alexandre@gmail.com" )
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 " )
270246
247+ pom {
271248 withXml {
272249 asNode().appendNode(" dependencies" ).apply {
273250 fun Dependency.write (scope : String ) = appendNode(" dependency" ).apply {
@@ -288,6 +265,54 @@ fun Project.setupPublishing(isLibrary: Boolean) {
288265 dependency.write(" runtime" )
289266 }
290267 }
268+
269+ // Common values
270+ val repoUrl = " https://github.com/firebase/FirebaseUI-Android"
271+ val scmUrl = " scm:git:git@github.com/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" , " samstern@google.com" )
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+ }
291316 }
292317 }
293318 }
@@ -310,20 +335,50 @@ fun Project.setupPublishing(isLibrary: Boolean) {
310335
311336 tasks.withType<ArtifactoryTask > { publications(publicationName) }
312337
338+ apply (plugin = " com.jfrog.bintray" )
339+
313340 configure<BintrayExtension > {
341+
314342 user = bintrayUsername
315343 key = bintrayKey
316344 setPublications(publicationName)
317345 setConfigurations(" archives" )
318346
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+
319378 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 }))
327382 })
328383
329384 pkg(closureOf<BintrayExtension .PackageConfig > {
0 commit comments