@@ -18,7 +18,6 @@ import groovy.util.*
1818import org.gradle.api.publish.maven.internal.artifact.*
1919import org.jetbrains.kotlin.gradle.dsl.*
2020import org.jetbrains.kotlin.gradle.plugin.mpp.*
21- import org.jfrog.gradle.plugin.artifactory.dsl.*
2221
2322buildscript {
2423 repositories {
@@ -33,14 +32,8 @@ buildscript {
3332
3433plugins {
3534 alias(libs.plugins.versionUpdates)
36- alias(libs.plugins.jfrog.artifactory) apply false // needed to add classpath to script
3735}
3836
39- // on macos it will return all publications supported by rsocket, as linux and mingw can be crosscompiled there for publication
40- // on linux and mac it will not contain mac targets
41- val Project .publicationNames: Array <String >
42- get() = extensions.getByType<PublishingExtension >().publications.names.toTypedArray()
43-
4437subprojects {
4538 tasks.whenTaskAdded {
4639 if (name.endsWith(" test" , ignoreCase = true )) onlyIf { ! rootProject.hasProperty(" skipTests" ) }
@@ -194,233 +187,3 @@ subprojects {
194187 }
195188 }
196189}
197-
198- fun publishPlatformArtifactsInRootModule (
199- platformPublication : MavenPublication ,
200- kotlinMultiplatformPublication : MavenPublication
201- ) {
202- lateinit var platformXml: XmlProvider
203-
204- platformPublication.pom.withXml { platformXml = this }
205-
206- kotlinMultiplatformPublication.apply {
207- pom.withXml {
208- val root = asNode()
209- // Remove the original content and add the content from the platform POM:
210- root.children().toList().forEach { root.remove(it as Node ) }
211- platformXml.asNode().children()
212- .forEach { root.append(it as Node ) }
213-
214- // Adjust the self artifact ID, as it should match the root module's coordinates:
215- ((root.get(" artifactId" ) as NodeList )[0 ] as Node ).setValue(artifactId)
216-
217- // Set packaging to POM to indicate that there's no artifact:
218- root.appendNode(" packaging" , " pom" )
219-
220- // Remove the original platform dependencies and add a single dependency on the platform module:
221- val dependencies = (root.get(" dependencies" ) as NodeList )[0 ] as Node
222- dependencies.children().toList()
223- .forEach { dependencies.remove(it as Node ) }
224- val singleDependency = dependencies.appendNode(" dependency" )
225- singleDependency.appendNode(
226- " groupId" ,
227- platformPublication.groupId
228- )
229- singleDependency.appendNode(
230- " artifactId" ,
231- platformPublication.artifactId
232- )
233- singleDependency.appendNode(
234- " version" ,
235- platformPublication.version
236- )
237- singleDependency.appendNode(" scope" , " compile" )
238- }
239- }
240-
241- tasks.matching { it.name == " generatePomFileForKotlinMultiplatformPublication" }
242- .configureEach {
243- dependsOn(tasks[" generatePomFileFor${platformPublication.name.capitalize()} Publication" ])
244- }
245-
246- }
247-
248- // publication
249- subprojects {
250- afterEvaluate {
251-
252- val versionSuffix: String? by project
253- if (versionSuffix != null ) {
254- project.version = project.version.toString() + versionSuffix
255- }
256-
257- task<Jar >(" javadocJar" ) {
258- archiveClassifier.set(" javadoc" )
259- }
260-
261- tasks.withType<Sign > {
262- dependsOn(" javadocJar" )
263- }
264-
265- plugins.withId(" org.jetbrains.kotlin.multiplatform" ) {
266- extensions.configure<KotlinMultiplatformExtension > {
267- targets.all {
268- mavenPublication {
269- pom {
270- name.set(project.name)
271- description.set(project.description)
272- url.set(" http://rsocket.io" )
273-
274- licenses {
275- license {
276- name.set(" The Apache Software License, Version 2.0" )
277- url.set(" https://www.apache.org/licenses/LICENSE-2.0.txt" )
278- distribution.set(" repo" )
279- }
280- }
281- developers {
282- developer {
283- id.set(" whyoleg" )
284- name.set(" Oleg Yukhnevich" )
285- 286- }
287- developer {
288- id.set(" OlegDokuka" )
289- name.set(" Oleh Dokuka" )
290- 291- }
292- }
293- scm {
294- connection.set(" https://github.com/rsocket/rsocket-kotlin.git" )
295- developerConnection.set(" https://github.com/rsocket/rsocket-kotlin.git" )
296- url.set(" https://github.com/rsocket/rsocket-kotlin" )
297- }
298- }
299- }
300- }
301- }
302- }
303-
304- tasks.withType<PublishToMavenRepository > {
305- dependsOn(tasks.withType<Sign >())
306- }
307-
308- tasks.matching { it.name == " generatePomFileForKotlinMultiplatformPublication" }.configureEach {
309- tasks.findByName(" generatePomFileForJvmPublication" )?.let { dependsOn(it) }
310- }
311- }
312- }
313-
314- val bintrayUser: String? by project
315- val bintrayKey: String? by project
316- if (bintrayUser != null && bintrayKey != null ) {
317-
318- // configure artifactory
319- subprojects {
320- plugins.withId(" com.jfrog.artifactory" ) {
321- configure<ArtifactoryPluginConvention > {
322- setContextUrl(" https://oss.jfrog.org" )
323-
324- publish(delegateClosureOf<PublisherConfig > {
325- repository(delegateClosureOf<DoubleDelegateWrapper > {
326- setProperty(" repoKey" , " oss-snapshot-local" )
327- setProperty(" username" , bintrayUser)
328- setProperty(" password" , bintrayKey)
329- setProperty(" maven" , true )
330- })
331- println (" Artifactory: ${publicationNames.contentToString()} " )
332- defaults(delegateClosureOf< groovy.lang.GroovyObject > {
333- invokeMethod(" publications" , publicationNames)
334- })
335- })
336-
337- val buildNumber: String? by project
338-
339- if (buildNumber != null ) {
340- clientConfig.info.buildNumber = buildNumber
341- }
342- }
343- }
344- }
345- }
346-
347- // configure bintray / maven central
348- val sonatypeUsername: String? by project
349- val sonatypePassword: String? by project
350- if (sonatypeUsername != null && sonatypePassword != null ) {
351- subprojects {
352- afterEvaluate {
353- plugins.withId(" maven-publish" ) {
354- plugins.withId(" signing" ) {
355- extensions.configure<SigningExtension > {
356- // requiring signature if there is a publish task that is not to MavenLocal
357- // TODO
358- // isRequired = gradle.taskGraph.allTasks.any {
359- // it.name.toLowerCase()
360- // .contains("publish") && !it.name.contains("MavenLocal")
361- // }
362-
363- val signingKey: String? by project
364- val signingPassword: String? by project
365-
366- useInMemoryPgpKeys(signingKey, signingPassword)
367- val names = publicationNames
368- val publishing: PublishingExtension by project.extensions
369- beforeEvaluate {
370- publishing.publications
371- .filterIsInstance<MavenPublication >()
372- .filter { it.name in names }
373- .forEach { publication ->
374- val moduleFile =
375- buildDir.resolve(" publications/${publication.name} /module.json" )
376- if (moduleFile.exists()) {
377- publication.artifact(object :
378- FileBasedMavenArtifact (moduleFile) {
379- override fun getDefaultExtension () = " module"
380- })
381- }
382- }
383- }
384- afterEvaluate {
385- sign(* publishing.publications.toTypedArray())
386- }
387- }
388-
389- extensions.configure<PublishingExtension > {
390- repositories {
391- maven {
392- name = " sonatype"
393- url = uri(" https://oss.sonatype.org/service/local/staging/deploy/maven2" )
394- credentials {
395- username = sonatypeUsername
396- password = sonatypePassword
397- }
398- }
399- }
400-
401- publications.filterIsInstance<MavenPublication >().forEach {
402- // add empty javadocs
403- if (name != " kotlinMultiplatform" ) {
404- it.artifact(tasks[" javadocJar" ])
405- }
406-
407- val type = it.name
408- when (type) {
409- " kotlinMultiplatform" -> {
410- // With Kotlin 1.4 & HMPP, the root module should have no suffix in the ID, but for compatibility with
411- // the consumers who can't read Gradle module metadata, we publish the JVM artifacts in it, too
412- it.artifactId = project.name
413- publishPlatformArtifactsInRootModule(
414- publications[" jvm" ] as MavenPublication ,
415- it
416- )
417- }
418- else -> it.artifactId = " ${project.name} -$type "
419- }
420- }
421- }
422- }
423- }
424- }
425- }
426- }
0 commit comments