-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
olme04
authored
Jan 12, 2022
1 parent
af8a5b8
commit 55b5e1b
Showing
13 changed files
with
119 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,6 @@ import groovy.util.* | |
import org.gradle.api.publish.maven.internal.artifact.* | ||
import org.jetbrains.kotlin.gradle.dsl.* | ||
import org.jetbrains.kotlin.gradle.plugin.mpp.* | ||
import org.jfrog.gradle.plugin.artifactory.dsl.* | ||
|
||
buildscript { | ||
repositories { | ||
|
@@ -33,14 +32,8 @@ buildscript { | |
|
||
plugins { | ||
alias(libs.plugins.versionUpdates) | ||
alias(libs.plugins.jfrog.artifactory) apply false //needed to add classpath to script | ||
} | ||
|
||
//on macos it will return all publications supported by rsocket, as linux and mingw can be crosscompiled there for publication | ||
//on linux and mac it will not contain mac targets | ||
val Project.publicationNames: Array<String> | ||
get() = extensions.getByType<PublishingExtension>().publications.names.toTypedArray() | ||
|
||
subprojects { | ||
tasks.whenTaskAdded { | ||
if (name.endsWith("test", ignoreCase = true)) onlyIf { !rootProject.hasProperty("skipTests") } | ||
|
@@ -194,233 +187,3 @@ subprojects { | |
} | ||
} | ||
} | ||
|
||
fun publishPlatformArtifactsInRootModule( | ||
platformPublication: MavenPublication, | ||
kotlinMultiplatformPublication: MavenPublication | ||
) { | ||
lateinit var platformXml: XmlProvider | ||
|
||
platformPublication.pom.withXml { platformXml = this } | ||
|
||
kotlinMultiplatformPublication.apply { | ||
pom.withXml { | ||
val root = asNode() | ||
// Remove the original content and add the content from the platform POM: | ||
root.children().toList().forEach { root.remove(it as Node) } | ||
platformXml.asNode().children() | ||
.forEach { root.append(it as Node) } | ||
|
||
// Adjust the self artifact ID, as it should match the root module's coordinates: | ||
((root.get("artifactId") as NodeList)[0] as Node).setValue(artifactId) | ||
|
||
// Set packaging to POM to indicate that there's no artifact: | ||
root.appendNode("packaging", "pom") | ||
|
||
// Remove the original platform dependencies and add a single dependency on the platform module: | ||
val dependencies = (root.get("dependencies") as NodeList)[0] as Node | ||
dependencies.children().toList() | ||
.forEach { dependencies.remove(it as Node) } | ||
val singleDependency = dependencies.appendNode("dependency") | ||
singleDependency.appendNode( | ||
"groupId", | ||
platformPublication.groupId | ||
) | ||
singleDependency.appendNode( | ||
"artifactId", | ||
platformPublication.artifactId | ||
) | ||
singleDependency.appendNode( | ||
"version", | ||
platformPublication.version | ||
) | ||
singleDependency.appendNode("scope", "compile") | ||
} | ||
} | ||
|
||
tasks.matching { it.name == "generatePomFileForKotlinMultiplatformPublication" } | ||
.configureEach { | ||
dependsOn(tasks["generatePomFileFor${platformPublication.name.capitalize()}Publication"]) | ||
} | ||
|
||
} | ||
|
||
//publication | ||
subprojects { | ||
afterEvaluate { | ||
|
||
val versionSuffix: String? by project | ||
if (versionSuffix != null) { | ||
project.version = project.version.toString() + versionSuffix | ||
} | ||
|
||
task<Jar>("javadocJar") { | ||
archiveClassifier.set("javadoc") | ||
} | ||
|
||
tasks.withType<Sign> { | ||
dependsOn("javadocJar") | ||
} | ||
|
||
plugins.withId("org.jetbrains.kotlin.multiplatform") { | ||
extensions.configure<KotlinMultiplatformExtension> { | ||
targets.all { | ||
mavenPublication { | ||
pom { | ||
name.set(project.name) | ||
description.set(project.description) | ||
url.set("http://rsocket.io") | ||
|
||
licenses { | ||
license { | ||
name.set("The Apache Software License, Version 2.0") | ||
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") | ||
distribution.set("repo") | ||
} | ||
} | ||
developers { | ||
developer { | ||
id.set("whyoleg") | ||
name.set("Oleg Yukhnevich") | ||
email.set("[email protected]") | ||
} | ||
developer { | ||
id.set("OlegDokuka") | ||
name.set("Oleh Dokuka") | ||
email.set("[email protected]") | ||
} | ||
} | ||
scm { | ||
connection.set("https://github.com/rsocket/rsocket-kotlin.git") | ||
developerConnection.set("https://github.com/rsocket/rsocket-kotlin.git") | ||
url.set("https://github.com/rsocket/rsocket-kotlin") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
tasks.withType<PublishToMavenRepository> { | ||
dependsOn(tasks.withType<Sign>()) | ||
} | ||
|
||
tasks.matching { it.name == "generatePomFileForKotlinMultiplatformPublication" }.configureEach { | ||
tasks.findByName("generatePomFileForJvmPublication")?.let { dependsOn(it) } | ||
} | ||
} | ||
} | ||
|
||
val bintrayUser: String? by project | ||
val bintrayKey: String? by project | ||
if (bintrayUser != null && bintrayKey != null) { | ||
|
||
//configure artifactory | ||
subprojects { | ||
plugins.withId("com.jfrog.artifactory") { | ||
configure<ArtifactoryPluginConvention> { | ||
setContextUrl("https://oss.jfrog.org") | ||
|
||
publish(delegateClosureOf<PublisherConfig> { | ||
repository(delegateClosureOf<DoubleDelegateWrapper> { | ||
setProperty("repoKey", "oss-snapshot-local") | ||
setProperty("username", bintrayUser) | ||
setProperty("password", bintrayKey) | ||
setProperty("maven", true) | ||
}) | ||
println("Artifactory: ${publicationNames.contentToString()}") | ||
defaults(delegateClosureOf<groovy.lang.GroovyObject> { | ||
invokeMethod("publications", publicationNames) | ||
}) | ||
}) | ||
|
||
val buildNumber: String? by project | ||
|
||
if (buildNumber != null) { | ||
clientConfig.info.buildNumber = buildNumber | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
//configure bintray / maven central | ||
val sonatypeUsername: String? by project | ||
val sonatypePassword: String? by project | ||
if (sonatypeUsername != null && sonatypePassword != null) { | ||
subprojects { | ||
afterEvaluate { | ||
plugins.withId("maven-publish") { | ||
plugins.withId("signing") { | ||
extensions.configure<SigningExtension> { | ||
//requiring signature if there is a publish task that is not to MavenLocal | ||
//TODO | ||
// isRequired = gradle.taskGraph.allTasks.any { | ||
// it.name.toLowerCase() | ||
// .contains("publish") && !it.name.contains("MavenLocal") | ||
// } | ||
|
||
val signingKey: String? by project | ||
val signingPassword: String? by project | ||
|
||
useInMemoryPgpKeys(signingKey, signingPassword) | ||
val names = publicationNames | ||
val publishing: PublishingExtension by project.extensions | ||
beforeEvaluate { | ||
publishing.publications | ||
.filterIsInstance<MavenPublication>() | ||
.filter { it.name in names } | ||
.forEach { publication -> | ||
val moduleFile = | ||
buildDir.resolve("publications/${publication.name}/module.json") | ||
if (moduleFile.exists()) { | ||
publication.artifact(object : | ||
FileBasedMavenArtifact(moduleFile) { | ||
override fun getDefaultExtension() = "module" | ||
}) | ||
} | ||
} | ||
} | ||
afterEvaluate { | ||
sign(*publishing.publications.toTypedArray()) | ||
} | ||
} | ||
|
||
extensions.configure<PublishingExtension> { | ||
repositories { | ||
maven { | ||
name = "sonatype" | ||
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2") | ||
credentials { | ||
username = sonatypeUsername | ||
password = sonatypePassword | ||
} | ||
} | ||
} | ||
|
||
publications.filterIsInstance<MavenPublication>().forEach { | ||
// add empty javadocs | ||
if (name != "kotlinMultiplatform") { | ||
it.artifact(tasks["javadocJar"]) | ||
} | ||
|
||
val type = it.name | ||
when (type) { | ||
"kotlinMultiplatform" -> { | ||
// With Kotlin 1.4 & HMPP, the root module should have no suffix in the ID, but for compatibility with | ||
// the consumers who can't read Gradle module metadata, we publish the JVM artifacts in it, too | ||
it.artifactId = project.name | ||
publishPlatformArtifactsInRootModule( | ||
publications["jvm"] as MavenPublication, | ||
it | ||
) | ||
} | ||
else -> it.artifactId = "${project.name}-$type" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
dependencies { | ||
implementation(buildLibs.build.kotlin) | ||
implementation(buildLibs.build.kotlinx.atomicfu) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
enableFeaturePreview("VERSION_CATALOGS") | ||
|
||
pluginManagement { | ||
repositories { | ||
gradlePluginPortal() | ||
mavenCentral() | ||
} | ||
} | ||
|
||
dependencyResolutionManagement { | ||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
versionCatalogs { | ||
create("buildLibs") { | ||
from(files("../gradle/libs.versions.toml")) | ||
} | ||
} | ||
} |
Oops, something went wrong.