11import com.android.build.gradle.BaseExtension
2+ import com.jfrog.bintray.gradle.Artifact
23import com.jfrog.bintray.gradle.BintrayExtension
4+ import com.jfrog.bintray.gradle.BintrayUploadTask
35import com.jfrog.bintray.gradle.RecordingCopyTask
46import org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention
57import org.jfrog.gradle.plugin.artifactory.dsl.DoubleDelegateWrapper
@@ -47,9 +49,7 @@ allprojects {
4749 configureQuality()
4850
4951 if (Config .submodules.contains(name) || isLibrary) {
50- // TODO: Re-enable this in the future
51- // setupPublishing()
52- setupTasks()
52+ setupPublishing()
5353 }
5454 }
5555}
@@ -65,7 +65,7 @@ val Project.isLibrary get() = name == "library"
6565/* *
6666 * Returns the maven artifact name for a Project.
6767 */
68- val Project .artifactName get() = if (isLibrary) " firebase-ui" else " firebase-ui-${ this . name} "
68+ val Project .artifactName get() = if (isLibrary) " firebase-ui" else " firebase-ui-$name "
6969
7070/* *
7171 * Returns the name for a Project's maven publication.
@@ -129,7 +129,33 @@ fun Project.configureQuality() {
129129 }
130130}
131131
132- fun Project.setupTasks () {
132+ fun Project.setupPublishing () {
133+ val sourcesJar = task<Jar >(" sourcesJar" ) {
134+ classifier = " sources"
135+ from(project.the<BaseExtension >().sourceSets[" main" ].java.srcDirs)
136+ }
137+
138+ val javadoc = task<Javadoc >(" javadoc" ) {
139+ setSource(project.the<BaseExtension >().sourceSets[" main" ].java.srcDirs)
140+ classpath + = configurations[" compile" ]
141+ classpath + = project.files(project.the<BaseExtension >().bootClasspath)
142+ }
143+
144+ val javadocJar = task<Jar >(" javadocJar" ) {
145+ dependsOn(javadoc)
146+ classifier = " javadoc"
147+ from(javadoc.destinationDir)
148+ }
149+
150+ artifacts.add(" archives" , javadocJar)
151+ artifacts.add(" archives" , sourcesJar)
152+
153+ tasks.whenTaskAdded {
154+ if (name.contains(" publish" ) && name.contains(" publication" , true )) {
155+ dependsOn(" assembleRelease" )
156+ }
157+ }
158+
133159 afterEvaluate {
134160 if (isLibrary) {
135161 task(" testAll" ) {
@@ -139,7 +165,7 @@ fun Project.setupTasks() {
139165 }
140166
141167 task(" prepareArtifacts" ) {
142- dependsOn(" javadocJar" , " sourcesJar" , " assembleRelease" )
168+ dependsOn(javadocJar, sourcesJar, " assembleRelease" )
143169 dependsOn(" generatePomFileForMonolithLibraryPublication" )
144170 dependsOn(* Config .submodules.map {
145171 " :$it :prepareArtifacts"
@@ -169,43 +195,16 @@ fun Project.setupTasks() {
169195 } else {
170196 val pomTask = " generatePomFileFor${project.name.capitalize()} LibraryPublication"
171197 task(" prepareArtifacts" ) {
172- dependsOn(" javadocJar" , " sourcesJar" , " assembleRelease" , pomTask)
198+ dependsOn(javadocJar, sourcesJar, " assembleRelease" , pomTask)
173199 }
174200 }
175- }
176- }
177-
178- fun Project.setupPublishing () {
179- println (" Configuring publishing for ${this } " )
180-
181- val sourcesJar = task<Jar >(" sourcesJar" ) {
182- classifier = " sources"
183- from(project.the<BaseExtension >().sourceSets[" main" ].java.srcDirs)
184- }
185-
186- val javadoc = task<Javadoc >(" javadoc" ) {
187- setSource(project.the<BaseExtension >().sourceSets[" main" ].java.srcDirs)
188- classpath + = configurations[" compile" ]
189- classpath + = project.files(project.the<BaseExtension >().bootClasspath)
190- }
191-
192- val javadocJar = task<Jar >(" javadocJar" ) {
193- dependsOn(javadoc)
194- classifier = " javadoc"
195- from(javadoc.destinationDir)
196- }
197-
198- artifacts.add(" archives" , javadocJar)
199- artifacts.add(" archives" , sourcesJar)
200201
201- tasks.whenTaskAdded {
202- if (name.toLowerCase().contains(" publish" ) && name.contains(" publication" , true )) {
203- dependsOn(" assembleRelease" )
204- }
202+ tasks[" bintrayUpload" ].dependsOn(" prepareArtifacts" )
205203 }
206204
207205 apply (plugin = " maven-publish" )
208206 apply (plugin = " com.jfrog.artifactory" )
207+ apply (plugin = " com.jfrog.bintray" )
209208
210209 configure<PublishingExtension > {
211210 repositories {
@@ -226,7 +225,6 @@ fun Project.setupPublishing() {
226225 // We need to override the variables 'group' and 'version' on the 'Project' object in order
227226 // to prevent the bintray plugin from creating 'unspecified' artifacts.
228227 val groupName = " com.firebaseui"
229- val projectName = name
230228 group = groupName
231229 version = Config .version
232230
@@ -236,18 +234,20 @@ fun Project.setupPublishing() {
236234 artifactId = artifactName
237235 version = Config .version
238236
239- val releaseAar = " $buildDir /outputs/aar/${projectName} -release.aar"
237+ val releaseAar = " $buildDir /outputs/aar/${project.name} -release.aar"
238+
239+ logger.info("""
240+ |Creating maven publication '$publicationName '
241+ | Group: $groupName
242+ | Artifact: $artifactName
243+ | Version: $version
244+ | Aar: $releaseAar
245+ """ .trimMargin())
240246
241247 artifact(releaseAar)
242248 artifact(javadocJar)
243249 artifact(sourcesJar)
244250
245- println (" Creating maven publication $publicationName " )
246- println (" \t group: $groupName " )
247- println (" \t artifact: $artifactName " )
248- println (" \t version: $version " )
249- println (" \t aar: $releaseAar " )
250-
251251 pom {
252252 withXml {
253253 asNode().appendNode(" dependencies" ).apply {
@@ -323,8 +323,10 @@ fun Project.setupPublishing() {
323323 }
324324 }
325325
326- val bintrayUsername = System .getProperty(" BINTRAY_USER" ) ? : System .getenv(" BINTRAY_USER" )
327- val bintrayKey = System .getProperty(" BINTRAY_KEY" ) ? : System .getenv(" BINTRAY_KEY" )
326+ val bintrayUsername = properties[" bintrayUser" ] as String?
327+ ? : System .getProperty(" BINTRAY_USER" ) ? : System .getenv(" BINTRAY_USER" )
328+ val bintrayKey = properties[" bintrayKey" ] as String?
329+ ? : System .getProperty(" BINTRAY_KEY" ) ? : System .getenv(" BINTRAY_KEY" )
328330
329331 configure<ArtifactoryPluginConvention > {
330332 setContextUrl(" https://oss.jfrog.org" )
@@ -339,56 +341,64 @@ fun Project.setupPublishing() {
339341
340342 tasks.withType<ArtifactoryTask > { publications(publicationName) }
341343
342- apply (plugin = " com.jfrog.bintray" )
343-
344344 configure<BintrayExtension > {
345-
346345 user = bintrayUsername
347346 key = bintrayKey
348347 setPublications(publicationName)
349- setConfigurations(" archives" )
350348
351- println ( " Bintray configuration for ${publicationName} " )
352- println ( " \t artifact: ${artifactName} " )
353- publications.forEach { pubName ->
354- println ( " \t pub: $pubName " )
349+ // When uploading, move and rename the generated POM
350+ val pomSrc = " $buildDir /publications/ $publicationName /pom-default.xml "
351+ val pomDest = " com/firebaseui/ $artifactName / ${ Config .version} / "
352+ val pomName = " $artifactName - ${ Config .version} .pom "
355353
356- val publ = project.extensions
354+ val pubLog: (String ) -> String = { name ->
355+ val publishing = project.extensions
357356 .getByType(PublishingExtension ::class .java)
358- .publications.findByName(pubName) as MavenPublication
359-
360- publ.artifacts.forEach { art ->
361- println (" \t\t pub_artifact: $art " )
362- }
357+ .publications[name] as MavenPublication
358+ " '$name ': ${publishing.artifacts} "
363359 }
364- configurations.forEach { config ->
365- println (" \t config: $config " )
366-
367- project.configurations.findByName(config)?.allArtifacts?.forEach { art ->
368- println (" \t\t config_artifact: $art " )
360+ logger.info("""
361+ |Bintray configuration for '$publicationName '
362+ | Artifact name: $artifactName
363+ | Artifacts: ${publications.joinToString(transform = pubLog)}
364+ """ .trimMargin())
365+ logger.info("""
366+ |POM transformation
367+ | Src: $pomSrc
368+ | Dest: $pomDest
369+ | Name: $pomName
370+ """ .trimMargin())
371+ tasks.withType<BintrayUploadTask > {
372+ doLast {
373+ fun Any.prettyString () = " [" + javaClass.declaredFields.mapNotNull {
374+ it.isAccessible = true
375+
376+ if (it.name.contains(" $" ) || it.name == " metaClass" ) {
377+ null
378+ } else {
379+ " ${it.name} =${it.get(this )} "
380+ }
381+ }.joinToString() + " ]"
382+
383+ logger.info("""
384+ |Upload task config
385+ | publications: ${publicationUploads?.joinToString { it.prettyString() }}
386+ | configurations: ${configurationUploads?.joinToString { it.prettyString() }}
387+ | fileUploads: ${fileUploads?.joinToString { it.prettyString() }}
388+ """ .trimMargin())
369389 }
370390 }
371391
372- // When uploading, move and rename the generated POM
373- val pomSrc = " $buildDir /publications/$publicationName /pom-default.xml"
374- val pomDst = " com/firebaseui/$artifactName /${Config .version} /"
375- val pomName = " $artifactName -${Config .version} .pom"
376-
377- println (" POM Transformation" )
378- println (" \t src: ${pomSrc} " )
379- println (" \t dst: ${pomDst} " )
380- println (" \t name: ${pomName} " )
381-
382392 filesSpec(closureOf<RecordingCopyTask > {
383393 from(pomSrc)
384- into(pomDst )
394+ into(pomDest )
385395 rename(KotlinClosure1 <String , String >({ pomName }))
386396 })
387397
388398 pkg(closureOf<BintrayExtension .PackageConfig > {
389399 repo = " firebase-ui"
390400 name = artifactName
391- userOrg = " firebaseui "
401+ user = " supercilex "
392402 setLicenses(" Apache-2.0" )
393403 vcsUrl = " https://github.com/firebase/FirebaseUI-Android.git"
394404
@@ -398,6 +408,3 @@ fun Project.setupPublishing() {
398408 })
399409 }
400410}
401-
402- // TODO: Remove this
403- apply (from = " publishing.gradle" )
0 commit comments