Skip to content

Commit 1eb9cd9

Browse files
committed
Initial attempts
Change-Id: Idd487131a5b6a279ab1df5077258548d5b5b7073
1 parent 3ab8b08 commit 1eb9cd9

File tree

3 files changed

+79
-28
lines changed

3 files changed

+79
-28
lines changed

build.gradle.kts

Lines changed: 76 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -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

5655
val Project.configDir get() = "$rootDir/library/quality"
5756
val Project.reportsDir get() = "$buildDir/reports"
5857

58+
/**
59+
* Extension property to determine if a Project is the 'library' module
60+
*/
61+
val Project.isLibrary get() = name == "library"
62+
63+
/**
64+
* Extension property to get 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+
* Extension property to get the name for a Project's maven publication.
70+
*/
71+
val Project.publicationName get() = if (isLibrary) "monolithLibrary" else "${name}Library"
72+
5973
fun 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,10 +232,18 @@ 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

241+
println("Creating maven publication $publicationName")
242+
println("\tgroup: $groupName")
243+
println("\tartifact: $artifactName")
244+
println("\tversion: $version")
245+
println("\taar: $releaseAar")
246+
226247
pom {
227248
name.set("FirebaseUI ${project.name.capitalize()}")
228249
description.set("Firebase UI for Android")
@@ -310,20 +331,50 @@ fun Project.setupPublishing(isLibrary: Boolean) {
310331

311332
tasks.withType<ArtifactoryTask> { publications(publicationName) }
312333

334+
apply(plugin = "com.jfrog.bintray")
335+
313336
configure<BintrayExtension> {
337+
314338
user = bintrayUsername
315339
key = bintrayKey
316340
setPublications(publicationName)
317341
setConfigurations("archives")
318342

343+
println("Bintray configuration for ${publicationName}")
344+
println("\tartifact: ${artifactName}")
345+
publications.forEach { pubName ->
346+
println("\tpub: $pubName")
347+
348+
val publ = project.extensions
349+
.getByType(PublishingExtension::class.java)
350+
.publications.findByName(pubName) as MavenPublication
351+
352+
publ.artifacts.forEach { art ->
353+
println("\t\tpub_artifact: $art")
354+
}
355+
}
356+
configurations.forEach { config ->
357+
println("\tconfig: $config")
358+
359+
project.configurations.findByName(config)?.allArtifacts?.forEach { art ->
360+
println("\t\tconfig_artifact: $art")
361+
}
362+
}
363+
364+
// When uploading, move and rename the generated POM
365+
val pomSrc = "$buildDir/publications/$publicationName/pom-default.xml"
366+
val pomDst = "com/firebaseui/$artifactName/${Config.version}/"
367+
val pomName = "$artifactName-${Config.version}.pom"
368+
369+
println("POM Transformation")
370+
println("\tsrc: ${pomSrc}")
371+
println("\tdst: ${pomDst}")
372+
println("\tname: ${pomName}")
373+
319374
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" }))
375+
from(pomSrc)
376+
into(pomDst)
377+
rename(KotlinClosure1<String, String>({ pomName }))
327378
})
328379

329380
pkg(closureOf<BintrayExtension.PackageConfig> {

buildSrc/src/main/kotlin/Config.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
object Config {
2-
const val version = "4.0.1-SNAPSHOT"
2+
const val version = "4.0.1"
33
val submodules = listOf("auth", "common", "firestore", "database", "storage")
44

55
private const val kotlinVersion = "1.2.41"
@@ -15,7 +15,7 @@ object Config {
1515
const val kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
1616
const val google = "com.google.gms:google-services:4.0.1"
1717

18-
const val bintray = "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3"
18+
const val bintray = "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0"
1919
const val buildInfo = "org.jfrog.buildinfo:build-info-extractor-gradle:4.7.3"
2020
}
2121

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-rc-1-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-rc-3-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)