Skip to content

Commit

Permalink
Moving stuff to afterEvaluate
Browse files Browse the repository at this point in the history
  • Loading branch information
gabfssilva committed Jan 24, 2024
1 parent 9e25f3d commit b8b3567
Showing 1 changed file with 96 additions and 96 deletions.
192 changes: 96 additions & 96 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -52,6 +52,22 @@ subprojects {
version = rootProject.libs.versions.river.get()
group = "com.river-kt"

repositories {
mavenCentral()
google()
}

tasks.withType<Test>().configureEach {
useJUnitPlatform()
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class) {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict", "-Xcontext-receivers")
jvmTarget = "17"
}
}

kotlin {
jvmToolchain(17)

Expand Down Expand Up @@ -105,132 +121,118 @@ subprojects {
}

pluginManager.withPlugin("com.android.library") {
extensions.configure<AndroidExtension> {
extensions.configure<LibraryExtension> {
namespace = "com.river"
compileSdk = rootProject.libs.versions.android.compile.sdk.get().toInt()
}
}

repositories {
mavenCentral()
google()
}

tasks.withType<Test>().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("[email protected]")
developers {
developer {
id.set("gabfssilva")
name.set("Gabriel Francisco")
email.set("[email protected]")
}
}
}
}
}
}

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<Sign>().configureEach {
skipExamples()
tasks.withType<Sign>().configureEach {
skipExamples()

onlyIf {
signingKeyId != null && signingPassword != null && signingSecretKey != null
onlyIf {
signingKeyId != null && signingPassword != null && signingSecretKey != null
}
}
}

val signAllPublications by tasks.registering {
dependsOn(tasks.withType<Sign>())
}
val signAllPublications by tasks.registering {
dependsOn(tasks.withType<Sign>())
}

signing {
useInMemoryPgpKeys(signingKeyId, signingSecretKey, signingPassword)
sign(publishing.publications)
}
signing {
useInMemoryPgpKeys(signingKeyId, signingSecretKey, signingPassword)
sign(publishing.publications)
}

tasks.withType<AbstractPublishToMaven>().configureEach {
skipExamples()
dependsOn(signAllPublications)
}
tasks.withType<AbstractPublishToMaven>().configureEach {
skipExamples()
dependsOn(signAllPublications)
}

tasks.withType<AbstractDokkaTask>().configureEach {
val task = this.path.split(":").last()
tasks.withType<AbstractDokkaTask>().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()
}
)
}
}
}

Expand All @@ -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) {
Expand Down

0 comments on commit b8b3567

Please sign in to comment.