@@ -47,9 +47,7 @@ allprojects {
47
47
configureQuality()
48
48
49
49
if (Config .submodules.contains(name) || isLibrary) {
50
- // TODO: Re-enable this in the future
51
- // setupPublishing()
52
- setupTasks()
50
+ setupPublishing()
53
51
}
54
52
}
55
53
}
@@ -65,7 +63,7 @@ val Project.isLibrary get() = name == "library"
65
63
/* *
66
64
* Returns the maven artifact name for a Project.
67
65
*/
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 "
69
67
70
68
/* *
71
69
* Returns the name for a Project's maven publication.
@@ -129,7 +127,33 @@ fun Project.configureQuality() {
129
127
}
130
128
}
131
129
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
+
133
157
afterEvaluate {
134
158
if (isLibrary) {
135
159
task(" testAll" ) {
@@ -139,7 +163,7 @@ fun Project.setupTasks() {
139
163
}
140
164
141
165
task(" prepareArtifacts" ) {
142
- dependsOn(" javadocJar" , " sourcesJar" , " assembleRelease" )
166
+ dependsOn(javadocJar, sourcesJar, " assembleRelease" )
143
167
dependsOn(" generatePomFileForMonolithLibraryPublication" )
144
168
dependsOn(* Config .submodules.map {
145
169
" :$it :prepareArtifacts"
@@ -169,43 +193,16 @@ fun Project.setupTasks() {
169
193
} else {
170
194
val pomTask = " generatePomFileFor${project.name.capitalize()} LibraryPublication"
171
195
task(" prepareArtifacts" ) {
172
- dependsOn(" javadocJar" , " sourcesJar" , " assembleRelease" , pomTask)
196
+ dependsOn(javadocJar, sourcesJar, " assembleRelease" , pomTask)
173
197
}
174
198
}
175
- }
176
- }
177
-
178
- fun Project.setupPublishing () {
179
- println (" Configuring publishing for ${this } " )
180
199
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" )
205
201
}
206
202
207
203
apply (plugin = " maven-publish" )
208
204
apply (plugin = " com.jfrog.artifactory" )
205
+ apply (plugin = " com.jfrog.bintray" )
209
206
210
207
configure<PublishingExtension > {
211
208
repositories {
@@ -226,7 +223,6 @@ fun Project.setupPublishing() {
226
223
// We need to override the variables 'group' and 'version' on the 'Project' object in order
227
224
// to prevent the bintray plugin from creating 'unspecified' artifacts.
228
225
val groupName = " com.firebaseui"
229
- val projectName = name
230
226
group = groupName
231
227
version = Config .version
232
228
@@ -236,18 +232,20 @@ fun Project.setupPublishing() {
236
232
artifactId = artifactName
237
233
version = Config .version
238
234
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())
240
244
241
245
artifact(releaseAar)
242
246
artifact(javadocJar)
243
247
artifact(sourcesJar)
244
248
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
249
pom {
252
250
withXml {
253
251
asNode().appendNode(" dependencies" ).apply {
@@ -323,8 +321,10 @@ fun Project.setupPublishing() {
323
321
}
324
322
}
325
323
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" )
328
328
329
329
configure<ArtifactoryPluginConvention > {
330
330
setContextUrl(" https://oss.jfrog.org" )
@@ -339,49 +339,37 @@ fun Project.setupPublishing() {
339
339
340
340
tasks.withType<ArtifactoryTask > { publications(publicationName) }
341
341
342
- apply (plugin = " com.jfrog.bintray" )
343
-
344
342
configure<BintrayExtension > {
345
-
346
343
user = bintrayUsername
347
344
key = bintrayKey
348
345
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
- }
371
346
372
347
// When uploading, move and rename the generated POM
373
348
val pomSrc = " $buildDir /publications/$publicationName /pom-default.xml"
374
- val pomDst = " com/firebaseui/$artifactName /${Config .version} /"
349
+ val pomDest = " com/firebaseui/$artifactName /${Config .version} /"
375
350
val pomName = " $artifactName -${Config .version} .pom"
376
351
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())
381
369
382
370
filesSpec(closureOf<RecordingCopyTask > {
383
371
from(pomSrc)
384
- into(pomDst )
372
+ into(pomDest )
385
373
rename(KotlinClosure1 <String , String >({ pomName }))
386
374
})
387
375
@@ -398,6 +386,3 @@ fun Project.setupPublishing() {
398
386
})
399
387
}
400
388
}
401
-
402
- // TODO: Remove this
403
- apply (from = " publishing.gradle" )
0 commit comments