From b8b356769e36aca947a724f8c5b2a2b84eb728e0 Mon Sep 17 00:00:00 2001 From: gabfssilva Date: Wed, 24 Jan 2024 16:54:32 -0300 Subject: [PATCH] Moving stuff to afterEvaluate --- build.gradle.kts | 192 +++++++++++++++++++++++------------------------ 1 file changed, 96 insertions(+), 96 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 798f4189..5adab955 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,9 +1,9 @@ @file:OptIn(ExperimentalKotlinGradlePluginApi::class) +import com.android.build.gradle.LibraryExtension import org.jetbrains.dokka.gradle.AbstractDokkaTask import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.JvmTarget -import com.android.build.gradle.LibraryExtension as AndroidExtension plugins { alias(libs.plugins.setup.android.sdk) @@ -52,6 +52,22 @@ subprojects { version = rootProject.libs.versions.river.get() group = "com.river-kt" + repositories { + mavenCentral() + google() + } + + tasks.withType().configureEach { + useJUnitPlatform() + } + + tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class) { + kotlinOptions { + freeCompilerArgs = listOf("-Xjsr305=strict", "-Xcontext-receivers") + jvmTarget = "17" + } + } + kotlin { jvmToolchain(17) @@ -105,132 +121,118 @@ subprojects { } pluginManager.withPlugin("com.android.library") { - extensions.configure { + extensions.configure { namespace = "com.river" compileSdk = rootProject.libs.versions.android.compile.sdk.get().toInt() } } - repositories { - mavenCentral() - google() - } - - tasks.withType().configureEach { - useJUnitPlatform() - } - - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class) { - kotlinOptions { - freeCompilerArgs = listOf("-Xjsr305=strict", "-Xcontext-receivers") - jvmTarget = "17" - } - } - - tasks.dokkaHtml.configure { - skipExamples() + afterEvaluate { + tasks.dokkaHtml.configure { + skipExamples() - dokkaSourceSets { - configureEach { - samples.from("src/sample/kotlin") + dokkaSourceSets { + configureEach { + samples.from("src/sample/kotlin") + } } } - } - val javadocJar by tasks.registering(Jar::class) { - archiveClassifier.set("javadoc") - from(tasks.dokkaHtml) - dependsOn("dokkaHtml") - skipExamples() - } + val javadocJar by tasks.registering(Jar::class) { + archiveClassifier.set("javadoc") + from(tasks.dokkaHtml) + dependsOn("dokkaHtml") + skipExamples() + } - publishing { - repositories { - maven { - name = "OSSRH" - url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") - credentials { - username = System.getenv("RELEASER_NEXUS2_USERNAME") - password = System.getenv("RELEASER_NEXUS2_PASSWORD") + publishing { + repositories { + maven { + name = "OSSRH" + url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") + credentials { + username = System.getenv("RELEASER_NEXUS2_USERNAME") + password = System.getenv("RELEASER_NEXUS2_PASSWORD") + } } } - } - publications.forEach { publication -> - if (publication !is MavenPublication) { - return@forEach - } + publications.forEach { publication -> + if (publication !is MavenPublication) { + return@forEach + } - publication.artifact(tasks["javadocJar"]) { - classifier = "javadoc" - } + publication.artifact(tasks["javadocJar"]) { + classifier = "javadoc" + } - publication.pom { - name.set(project.name) - description.set("Extensions & Enterprise Integrations for Kotlin flows.") + publication.pom { + name.set(project.name) + description.set("Extensions & Enterprise Integrations for Kotlin flows.") - url.set("https://river-kt.com") + url.set("https://river-kt.com") - scm { - connection.set("scm:git:git:github.com/River-Kt/river.git") - developerConnection.set("scm:git:ssh://github.com/River-Kt/river.git") - url.set("https://github.com/River-Kt/river") - } + scm { + connection.set("scm:git:git:github.com/River-Kt/river.git") + developerConnection.set("scm:git:ssh://github.com/River-Kt/river.git") + url.set("https://github.com/River-Kt/river") + } - licenses { - license { - name.set("The MIT License") - url.set("https://opensource.org/license/mit/") + licenses { + license { + name.set("The MIT License") + url.set("https://opensource.org/license/mit/") + } } - } - developers { - developer { - id.set("gabfssilva") - name.set("Gabriel Francisco") - email.set("gabfssilva@gmail.com") + developers { + developer { + id.set("gabfssilva") + name.set("Gabriel Francisco") + email.set("gabfssilva@gmail.com") + } } } } } - } - val signingKeyId by lazy { System.getenv("SIGNING_KEY_ID") } - val signingPassword by lazy { System.getenv("SIGNING_PASSWORD") } - val signingSecretKey by lazy { System.getenv("SIGNING_SECRET_FILE") } + val signingKeyId by lazy { System.getenv("SIGNING_KEY_ID") } + val signingPassword by lazy { System.getenv("SIGNING_PASSWORD") } + val signingSecretKey by lazy { System.getenv("SIGNING_SECRET_FILE") } - tasks.withType().configureEach { - skipExamples() + tasks.withType().configureEach { + skipExamples() - onlyIf { - signingKeyId != null && signingPassword != null && signingSecretKey != null + onlyIf { + signingKeyId != null && signingPassword != null && signingSecretKey != null + } } - } - val signAllPublications by tasks.registering { - dependsOn(tasks.withType()) - } + val signAllPublications by tasks.registering { + dependsOn(tasks.withType()) + } - signing { - useInMemoryPgpKeys(signingKeyId, signingSecretKey, signingPassword) - sign(publishing.publications) - } + signing { + useInMemoryPgpKeys(signingKeyId, signingSecretKey, signingPassword) + sign(publishing.publications) + } - tasks.withType().configureEach { - skipExamples() - dependsOn(signAllPublications) - } + tasks.withType().configureEach { + skipExamples() + dependsOn(signAllPublications) + } - tasks.withType().configureEach { - val task = this.path.split(":").last() + tasks.withType().configureEach { + val task = this.path.split(":").last() - skipExamples() + skipExamples() - dependsOn( - subprojects.mapNotNull { - runCatching { tasks.getByPath("${it.path}:$task") }.getOrNull() - } - ) + dependsOn( + subprojects.mapNotNull { + runCatching { tasks.getByPath("${it.path}:$task") }.getOrNull() + } + ) + } } } @@ -239,9 +241,7 @@ fun Task.skipExamples() { } fun Project.onAndroidEnabled(block: () -> Unit) { - afterEvaluate { - if (pluginManager.hasPlugin("com.android.library")) block() - } + if (pluginManager.hasPlugin("com.android.library")) block() } fun Project.onWindows(block: () -> Unit) {