Skip to content

Commit

Permalink
Continuous development (#20)
Browse files Browse the repository at this point in the history
* add vararg stream for StreamsBuilder

* fix stream-table join so it's not recursive, and the lambda param is last

* use expression bodies

* new `stream.to()` extension - for better generic support

* add test for StreamsBuilder.stream(...)

* use gradle task config avoidance configureEach

* fix kotlinx ser version in buildSrc

* try implementing Maven Central publishing... (signing still doesn't work)

* try implementing Maven Central publishing... (signing still doesn't work)

* split up StreamsBuilder.stream() so vararg works a bit better

* bump to Kotlin 1.7, add java-platform subproject

* - improve KStream.to()
- fixes after Kotlin 1.7 update

* try to fix jitpack

* only sign javadoc jar if publishing to sonatype

* kotest bump, Gradle bump, and a bit of build config tweaking

* bump Gradle & Kotlin

* rm sonatype snapshots from maven repos

* rm commented out buildSrc config

* disable signing plugin
  • Loading branch information
aSemy authored Jul 17, 2022
1 parent bfe3789 commit 70185af
Show file tree
Hide file tree
Showing 23 changed files with 491 additions and 84 deletions.
6 changes: 4 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
kotka.convention.`kotlin-jvm`

kotka.convention.`maven-publish`
id("me.qoomon.git-versioning")
me.qoomon.`git-versioning`

`project-report`
`build-dashboard`
Expand All @@ -21,12 +21,14 @@ gitVersioning.apply {
}

dependencies {
implementation(platform(projects.modules.versionsPlatform))

api(projects.modules.kotkaStreamsExtensions)
api(projects.modules.kotkaStreamsFramework)
api(projects.modules.kotkaStreamsKotlinxSerialization)
}

tasks.wrapper {
gradleVersion = "7.4.2"
gradleVersion = "7.5"
distributionType = Wrapper.DistributionType.ALL
}
12 changes: 3 additions & 9 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,13 @@ plugins {

dependencies {

val kotlinVersion = libs.versions.kotlin.get()
implementation(enforcedPlatform("org.jetbrains.kotlin:kotlin-bom:$kotlinVersion"))
implementation(enforcedPlatform(libs.kotlin.bom))
implementation("org.jetbrains.kotlin:kotlin-serialization")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")

val kotlinXSerializationVersion = "1.3.2"
implementation(enforcedPlatform("org.jetbrains.kotlinx:kotlinx-serialization-bom:$kotlinXSerializationVersion"))
implementation(libs.kotlin.gradlePlugin)

val gitVersioningPluginVersion = "5.2.0"
implementation("me.qoomon:gradle-git-versioning-plugin:$gitVersioningPluginVersion")
implementation(libs.gitVersioningPlugin)
}

val gradleJvmTarget = "1.8"
Expand All @@ -36,8 +32,6 @@ tasks.withType<KotlinCompile>().configureEach {
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=kotlin.ExperimentalStdlibApi",
"-opt-in=kotlin.time.ExperimentalTime",
// "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
// "-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
)
}

Expand Down
1 change: 1 addition & 0 deletions buildSrc/repositories.settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencyResolutionManagement {

}


fun RepositoryHandler.jitpack() {
maven("https://jitpack.io")
}
2 changes: 2 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
rootProject.name = "buildSrc"

apply(from = "./repositories.settings.gradle.kts")

dependencyResolutionManagement {
Expand Down
20 changes: 10 additions & 10 deletions buildSrc/src/main/kotlin/kotka/convention/kotlin-jvm.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,35 @@ plugins {
kotlin("jvm")
`java-library`
}
dependencies {

implementation(platform("org.jetbrains.kotlin:kotlin-bom"))

val junitVersion = "5.8.2"
testImplementation(platform("org.junit:junit-bom:$junitVersion"))
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher") {
because("Only needed to run tests in a version of IntelliJ IDEA that bundles older versions")
}

val kotestVersion = "5.2.3"
testImplementation(platform("io.kotest:kotest-bom:$kotestVersion"))
testImplementation("io.kotest:kotest-runner-junit5")
testImplementation("io.kotest:kotest-assertions-core")
testImplementation("io.kotest:kotest-property")
testImplementation("io.kotest:kotest-assertions-json")

testImplementation("io.mockk:mockk:1.12.3")

testImplementation("io.mockk:mockk")
}


val projectJvmTarget = "1.8"
val projectJvmVersion = "8"
val projectKotlinTarget = "1.6"


kotlin {
jvmToolchain {
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(projectJvmVersion))
languageVersion.set(JavaLanguageVersion.of(projectJvmVersion))
}
}


tasks.withType<KotlinCompile>().configureEach {

kotlinOptions {
Expand All @@ -56,14 +53,17 @@ tasks.withType<KotlinCompile>().configureEach {
)
}


tasks.compileTestKotlin {
kotlinOptions.freeCompilerArgs += "-opt-in=io.kotest.common.ExperimentalKotest"
}

tasks.withType<Test> {

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


java {
withJavadocJar()
withSourcesJar()
Expand Down
130 changes: 111 additions & 19 deletions buildSrc/src/main/kotlin/kotka/convention/maven-publish.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,30 +1,122 @@
package kotka.convention

import kotka.ext.createKotkaStreamsPom
import kotka.ext.credentialsAction
import kotka.ext.publishing
import kotka.ext.signing


plugins {
`maven-publish`
// signing
}

plugins.withType(JavaPlugin::class.java) {
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/adamko-dev/kotka-streams")
credentials(PasswordCredentials::class)
}
}

val sonatypeRepositoryCredentials: Provider<Action<PasswordCredentials>> =
providers.credentialsAction("sonatypeRepository")

val gitHubPackagesCredentials: Provider<Action<PasswordCredentials>> =
providers.credentialsAction("GitHubPackages")


val sonatypeRepositoryReleaseUrl: Provider<String> = provider {
if (version.toString().endsWith("SNAPSHOT")) {
"https://s01.oss.sonatype.org/content/repositories/snapshots/"
} else {
"https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
}
}


val signingKeyId: Provider<String> =
providers.gradleProperty("signing.keyId")
val signingKey: Provider<String> =
providers.gradleProperty("signing.key")
val signingPassword: Provider<String> =
providers.gradleProperty("signing.password")
val signingSecretKeyRingFile: Provider<String> =
providers.gradleProperty("signing.secretKeyRingFile")


tasks.withType<AbstractPublishToMaven>().configureEach {
// Gradle warns about some signing tasks using publishing task outputs without explicit
// dependencies. I'm not going to go through them all and fix them, so here's a quick fix.
dependsOn(tasks.withType<Sign>())

doLast {
logger.lifecycle("[${this.name}] ${project.group}:${project.name}:${project.version}")
}
}

tasks
.matching { it.name in listOf("publish", "publishToMavenLocal") }
.configureEach {
doLast {
logger.lifecycle("[${this.name}] ${project.group}:${project.name}:${project.version}")

//signing {
// if (sonatypeRepositoryCredentials.isPresent) {
// if (signingKeyId.isPresent && signingKey.isPresent && signingPassword.isPresent) {
// useInMemoryPgpKeys(signingKeyId.get(), signingKey.get(), signingPassword.get())
// } else {
// useGpgCmd()
// }
//
// // sign all publications
// sign(publishing.publications)
// }
//}


publishing {
repositories {
// publish to local dir, for testing
maven(rootProject.layout.buildDirectory.dir("maven-internal")) {
name = "maven-internal"
}

// if (sonatypeRepositoryCredentials.isPresent) {
// maven(sonatypeRepositoryReleaseUrl) {
// name = "sonatype"
// credentials(sonatypeRepositoryCredentials.get())
// }
// }
//
// if (gitHubPackagesCredentials.isPresent) {
// maven("https://maven.pkg.github.com/adamko-dev/kotka-streams") {
// name = "GitHubPackages"
// credentials(gitHubPackagesCredentials.get())
// }
// }
}

publications.withType<MavenPublication>().configureEach {
createKotkaStreamsPom()
}
}


plugins.withType<JavaPlugin>().configureEach {
publishing.publications.create<MavenPublication>("mavenJava") {
from(components["java"])
// artifact(tasks["sourcesJar"])
}
}


plugins.withType<JavaPlatformPlugin>().configureEach {

val javadocJarStub by tasks.registering(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Stub javadoc.jar artifact (required by Maven Central)"
archiveClassifier.set("javadoc")
}

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

// if (sonatypeRepositoryCredentials.isPresent) {
// signing.sign(javadocJarStub.get())
// }

publishing.publications.create<MavenPublication>("mavenJavaPlatform") {
from(components["javaPlatform"])
artifact(javadocJarStub)
}
}
20 changes: 20 additions & 0 deletions buildSrc/src/main/kotlin/kotka/ext/gradle.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package kotka.ext

import org.gradle.api.Action
import org.gradle.api.artifacts.repositories.PasswordCredentials
import org.gradle.api.provider.Provider
import org.gradle.api.provider.ProviderFactory


// https://github.com/gradle/gradle/issues/20925
fun ProviderFactory.credentialsAction(
repositoryName: String
): Provider<Action<PasswordCredentials>> = zip(
gradleProperty("${repositoryName}Username"),
gradleProperty("${repositoryName}Password"),
) { user, pass ->
Action<PasswordCredentials> {
username = user
password = pass
}
}
55 changes: 55 additions & 0 deletions buildSrc/src/main/kotlin/kotka/ext/publishing.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package kotka.ext

import org.gradle.api.Project
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.getByType
import org.gradle.plugins.signing.SigningExtension


fun MavenPublication.createKotkaStreamsPom(): Unit = pom {
name.set("Kotka Streams - Kotlin for Kafka Streams")
description.set("Using Kotka means a more pleasant experience while using Kafka Streams")
url.set("https://github.com/adamko-dev/kotka-streams")

licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}

developers {
developer {
email.set("adam@adamko.dev")
}
}

scm {
connection.set("scm:git:git://github.com/adamko-dev/kotka-streams.git")
developerConnection.set("scm:git:ssh://github.com:adamko-dev/kotka-streams.git")
url.set("https://github.com/adamko-dev/kotka-streams")
}
}


// hacks because IntelliJ still doesn't properly load DSL accessors for buildSrc


/** Configure [PublishingExtension] */
fun Project.publishing(configure: PublishingExtension.() -> Unit): Unit =
extensions.configure(configure)


val Project.publishing: PublishingExtension
get() = extensions.getByType()


/** Configure [SigningExtension] */
fun Project.signing(configure: SigningExtension.() -> Unit): Unit =
extensions.configure(configure)


val Project.signing: SigningExtension
get() = extensions.getByType()
Loading

0 comments on commit 70185af

Please sign in to comment.