1
1
import com.android.build.gradle.BaseExtension
2
+ import com.jfrog.bintray.gradle.Artifact
2
3
import com.jfrog.bintray.gradle.BintrayExtension
4
+ import com.jfrog.bintray.gradle.BintrayUploadTask
3
5
import com.jfrog.bintray.gradle.RecordingCopyTask
4
6
import org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention
5
7
import org.jfrog.gradle.plugin.artifactory.dsl.DoubleDelegateWrapper
@@ -47,9 +49,7 @@ allprojects {
47
49
configureQuality()
48
50
49
51
if (Config .submodules.contains(name) || isLibrary) {
50
- // TODO: Re-enable this in the future
51
- // setupPublishing()
52
- setupTasks()
52
+ setupPublishing()
53
53
}
54
54
}
55
55
}
@@ -65,7 +65,7 @@ val Project.isLibrary get() = name == "library"
65
65
/* *
66
66
* Returns the maven artifact name for a Project.
67
67
*/
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 "
69
69
70
70
/* *
71
71
* Returns the name for a Project's maven publication.
@@ -129,7 +129,33 @@ fun Project.configureQuality() {
129
129
}
130
130
}
131
131
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
+
133
159
afterEvaluate {
134
160
if (isLibrary) {
135
161
task(" testAll" ) {
@@ -139,7 +165,7 @@ fun Project.setupTasks() {
139
165
}
140
166
141
167
task(" prepareArtifacts" ) {
142
- dependsOn(" javadocJar" , " sourcesJar" , " assembleRelease" )
168
+ dependsOn(javadocJar, sourcesJar, " assembleRelease" )
143
169
dependsOn(" generatePomFileForMonolithLibraryPublication" )
144
170
dependsOn(* Config .submodules.map {
145
171
" :$it :prepareArtifacts"
@@ -169,43 +195,16 @@ fun Project.setupTasks() {
169
195
} else {
170
196
val pomTask = " generatePomFileFor${project.name.capitalize()} LibraryPublication"
171
197
task(" prepareArtifacts" ) {
172
- dependsOn(" javadocJar" , " sourcesJar" , " assembleRelease" , pomTask)
198
+ dependsOn(javadocJar, sourcesJar, " assembleRelease" , pomTask)
173
199
}
174
200
}
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)
200
201
201
- tasks.whenTaskAdded {
202
- if (name.toLowerCase().contains(" publish" ) && name.contains(" publication" , true )) {
203
- dependsOn(" assembleRelease" )
204
- }
202
+ tasks[" bintrayUpload" ].dependsOn(" prepareArtifacts" )
205
203
}
206
204
207
205
apply (plugin = " maven-publish" )
208
206
apply (plugin = " com.jfrog.artifactory" )
207
+ apply (plugin = " com.jfrog.bintray" )
209
208
210
209
configure<PublishingExtension > {
211
210
repositories {
@@ -226,7 +225,6 @@ fun Project.setupPublishing() {
226
225
// We need to override the variables 'group' and 'version' on the 'Project' object in order
227
226
// to prevent the bintray plugin from creating 'unspecified' artifacts.
228
227
val groupName = " com.firebaseui"
229
- val projectName = name
230
228
group = groupName
231
229
version = Config .version
232
230
@@ -236,18 +234,20 @@ fun Project.setupPublishing() {
236
234
artifactId = artifactName
237
235
version = Config .version
238
236
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())
240
246
241
247
artifact(releaseAar)
242
248
artifact(javadocJar)
243
249
artifact(sourcesJar)
244
250
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
-
251
251
pom {
252
252
withXml {
253
253
asNode().appendNode(" dependencies" ).apply {
@@ -323,8 +323,10 @@ fun Project.setupPublishing() {
323
323
}
324
324
}
325
325
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" )
328
330
329
331
configure<ArtifactoryPluginConvention > {
330
332
setContextUrl(" https://oss.jfrog.org" )
@@ -339,56 +341,64 @@ fun Project.setupPublishing() {
339
341
340
342
tasks.withType<ArtifactoryTask > { publications(publicationName) }
341
343
342
- apply (plugin = " com.jfrog.bintray" )
343
-
344
344
configure<BintrayExtension > {
345
-
346
345
user = bintrayUsername
347
346
key = bintrayKey
348
347
setPublications(publicationName)
349
- setConfigurations(" archives" )
350
348
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 "
355
353
356
- val publ = project.extensions
354
+ val pubLog: (String ) -> String = { name ->
355
+ val publishing = project.extensions
357
356
.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} "
363
359
}
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())
369
389
}
370
390
}
371
391
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
-
382
392
filesSpec(closureOf<RecordingCopyTask > {
383
393
from(pomSrc)
384
- into(pomDst )
394
+ into(pomDest )
385
395
rename(KotlinClosure1 <String , String >({ pomName }))
386
396
})
387
397
388
398
pkg(closureOf<BintrayExtension .PackageConfig > {
389
399
repo = " firebase-ui"
390
400
name = artifactName
391
- userOrg = " firebaseui "
401
+ user = " supercilex "
392
402
setLicenses(" Apache-2.0" )
393
403
vcsUrl = " https://github.com/firebase/FirebaseUI-Android.git"
394
404
@@ -398,6 +408,3 @@ fun Project.setupPublishing() {
398
408
})
399
409
}
400
410
}
401
-
402
- // TODO: Remove this
403
- apply (from = " publishing.gradle" )
0 commit comments