@@ -47,9 +47,7 @@ allprojects {
4747 configureQuality()
4848
4949 if (Config .submodules.contains(name) || isLibrary) {
50- // TODO: Re-enable this in the future
51- // setupPublishing()
52- setupTasks()
50+ setupPublishing()
5351 }
5452 }
5553}
@@ -65,7 +63,7 @@ val Project.isLibrary get() = name == "library"
6563/* *
6664 * Returns the maven artifact name for a Project.
6765 */
68- val Project .artifactName get() = if (isLibrary) " firebase-ui" else " firebase-ui-${ this . name} "
66+ val Project .artifactName get() = if (isLibrary) " firebase-ui" else " firebase-ui-$name "
6967
7068/* *
7169 * Returns the name for a Project's maven publication.
@@ -129,7 +127,33 @@ fun Project.configureQuality() {
129127 }
130128}
131129
132- fun Project.setupTasks () {
130+ fun Project.setupPublishing () {
131+ val sourcesJar = task<Jar >(" sourcesJar" ) {
132+ classifier = " sources"
133+ from(project.the<BaseExtension >().sourceSets[" main" ].java.srcDirs)
134+ }
135+
136+ val javadoc = task<Javadoc >(" javadoc" ) {
137+ setSource(project.the<BaseExtension >().sourceSets[" main" ].java.srcDirs)
138+ classpath + = configurations[" compile" ]
139+ classpath + = project.files(project.the<BaseExtension >().bootClasspath)
140+ }
141+
142+ val javadocJar = task<Jar >(" javadocJar" ) {
143+ dependsOn(javadoc)
144+ classifier = " javadoc"
145+ from(javadoc.destinationDir)
146+ }
147+
148+ artifacts.add(" archives" , javadocJar)
149+ artifacts.add(" archives" , sourcesJar)
150+
151+ tasks.whenTaskAdded {
152+ if (name.contains(" publish" ) && name.contains(" publication" , true )) {
153+ dependsOn(" assembleRelease" )
154+ }
155+ }
156+
133157 afterEvaluate {
134158 if (isLibrary) {
135159 task(" testAll" ) {
@@ -139,7 +163,7 @@ fun Project.setupTasks() {
139163 }
140164
141165 task(" prepareArtifacts" ) {
142- dependsOn(" javadocJar" , " sourcesJar" , " assembleRelease" )
166+ dependsOn(javadocJar, sourcesJar, " assembleRelease" )
143167 dependsOn(" generatePomFileForMonolithLibraryPublication" )
144168 dependsOn(* Config .submodules.map {
145169 " :$it :prepareArtifacts"
@@ -169,43 +193,16 @@ fun Project.setupTasks() {
169193 } else {
170194 val pomTask = " generatePomFileFor${project.name.capitalize()} LibraryPublication"
171195 task(" prepareArtifacts" ) {
172- dependsOn(" javadocJar" , " sourcesJar" , " assembleRelease" , pomTask)
196+ dependsOn(javadocJar, sourcesJar, " assembleRelease" , pomTask)
173197 }
174198 }
175- }
176- }
177-
178- fun Project.setupPublishing () {
179- println (" Configuring publishing for ${this } " )
180199
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)
200-
201- tasks.whenTaskAdded {
202- if (name.toLowerCase().contains(" publish" ) && name.contains(" publication" , true )) {
203- dependsOn(" assembleRelease" )
204- }
200+ tasks[" bintrayUpload" ].dependsOn(" prepareArtifacts" )
205201 }
206202
207203 apply (plugin = " maven-publish" )
208204 apply (plugin = " com.jfrog.artifactory" )
205+ apply (plugin = " com.jfrog.bintray" )
209206
210207 configure<PublishingExtension > {
211208 repositories {
@@ -226,7 +223,6 @@ fun Project.setupPublishing() {
226223 // We need to override the variables 'group' and 'version' on the 'Project' object in order
227224 // to prevent the bintray plugin from creating 'unspecified' artifacts.
228225 val groupName = " com.firebaseui"
229- val projectName = name
230226 group = groupName
231227 version = Config .version
232228
@@ -236,18 +232,20 @@ fun Project.setupPublishing() {
236232 artifactId = artifactName
237233 version = Config .version
238234
239- val releaseAar = " $buildDir /outputs/aar/${projectName} -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())
240244
241245 artifact(releaseAar)
242246 artifact(javadocJar)
243247 artifact(sourcesJar)
244248
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-
251249 pom {
252250 withXml {
253251 asNode().appendNode(" dependencies" ).apply {
@@ -323,8 +321,10 @@ fun Project.setupPublishing() {
323321 }
324322 }
325323
326- val bintrayUsername = System .getProperty(" BINTRAY_USER" ) ? : System .getenv(" BINTRAY_USER" )
327- 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" )
328328
329329 configure<ArtifactoryPluginConvention > {
330330 setContextUrl(" https://oss.jfrog.org" )
@@ -339,49 +339,37 @@ fun Project.setupPublishing() {
339339
340340 tasks.withType<ArtifactoryTask > { publications(publicationName) }
341341
342- apply (plugin = " com.jfrog.bintray" )
343-
344342 configure<BintrayExtension > {
345-
346343 user = bintrayUsername
347344 key = bintrayKey
348345 setPublications(publicationName)
349- setConfigurations(" archives" )
350-
351- println (" Bintray configuration for ${publicationName} " )
352- println (" \t artifact: ${artifactName} " )
353- publications.forEach { pubName ->
354- println (" \t pub: $pubName " )
355-
356- val publ = project.extensions
357- .getByType(PublishingExtension ::class .java)
358- .publications.findByName(pubName) as MavenPublication
359-
360- publ.artifacts.forEach { art ->
361- println (" \t\t pub_artifact: $art " )
362- }
363- }
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 " )
369- }
370- }
371346
372347 // When uploading, move and rename the generated POM
373348 val pomSrc = " $buildDir /publications/$publicationName /pom-default.xml"
374- val pomDst = " com/firebaseui/$artifactName /${Config .version} /"
349+ val pomDest = " com/firebaseui/$artifactName /${Config .version} /"
375350 val pomName = " $artifactName -${Config .version} .pom"
376351
377- println (" POM Transformation" )
378- println (" \t src: ${pomSrc} " )
379- println (" \t dst: ${pomDst} " )
380- println (" \t name: ${pomName} " )
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())
381369
382370 filesSpec(closureOf<RecordingCopyTask > {
383371 from(pomSrc)
384- into(pomDst )
372+ into(pomDest )
385373 rename(KotlinClosure1 <String , String >({ pomName }))
386374 })
387375
@@ -398,6 +386,3 @@ fun Project.setupPublishing() {
398386 })
399387 }
400388}
401-
402- // TODO: Remove this
403- apply (from = " publishing.gradle" )
0 commit comments