Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean-up #144

Merged
merged 3 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ jobs:

steps:
- name: Checkout the repo
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Java
uses: actions/setup-java@v3.13.0
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11

- name: Build
uses: gradle/gradle-build-action@v2.9.0
uses: gradle/gradle-build-action@v2
with:
arguments: build --scan --full-stacktrace

Expand All @@ -50,7 +50,7 @@ jobs:
timeout-minutes: 10

steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -77,7 +77,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ jobs:

steps:
- name: Checkout the repo
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Java
uses: actions/setup-java@v3.13.0
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11

- name: Build
uses: gradle/gradle-build-action@v2.9.0
uses: gradle/gradle-build-action@v2
with:
arguments: build --scan --full-stacktrace

Expand Down
68 changes: 26 additions & 42 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,41 +1,28 @@
import kotlinx.knit.KnitPluginExtension
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

buildscript {
dependencies {
classpath("org.jetbrains.kotlinx:kotlinx-knit:0.4.0")
}
}

@Suppress("DSL_SCOPE_VIOLATION")
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.arrowGradleConfig.kotlin)
alias(libs.plugins.arrowGradleConfig.nexus)
alias(libs.plugins.arrowGradleConfig.publish)
alias(libs.plugins.dokka)
alias(libs.plugins.spotless)
alias(libs.plugins.knit)
}

apply(plugin = "kotlinx-knit")

allprojects {
repositories {
maven("https://oss.sonatype.org/content/repositories/snapshots/")
mavenCentral()
}
group = property("projects.group").toString()
version = property("projects.version").toString()
extra.set("dokka.outputDirectory", rootDir.resolve("docs"))
repositories {
mavenCentral()
}

group = "io.github.nomisrev"

dependencies {
api(libs.kotlin.stdlib)
api(libs.kotlinx.coroutines.core)
api(libs.kotlinx.coroutines.jdk8)
api(libs.kafka.clients)
implementation(libs.slf4j.api)

testImplementation(libs.bundles.kotest)
testImplementation(libs.testcontainers.kafka)
testImplementation(libs.slf4j.simple)
Expand All @@ -45,6 +32,12 @@ configure<KnitPluginExtension> {
siteRoot = "https://nomisrev.github.io/kotlin-kafka/"
}

configure<JavaPluginExtension> {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}

tasks {
withType<DokkaTask>().configureEach {
outputDirectory.set(rootDir.resolve("docs"))
Expand All @@ -64,29 +57,20 @@ tasks {
}
}
}

getByName("knitPrepare").dependsOn(getTasksByName("dokka", true))

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

withType<KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = "1.8"
}

register<Delete>("cleanDocs") {
val folder = file("docs").also { it.mkdir() }
val docsContent = folder.listFiles().filter { it != folder }
delete(docsContent)
}
}

nexusPublishing {
repositories {
named("sonatype") {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
testLogging {
exceptionFormat = TestExceptionFormat.FULL
events = setOf(
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.FAILED,
TestLogEvent.STANDARD_OUT,
TestLogEvent.STANDARD_ERROR
)
}
}
}
32 changes: 16 additions & 16 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ kotlin.code.style=official

# Package definitions
projects.group=io.github.nomisrev
projects.version=0.3.1

# Project definitions
pom.name=kotlin-kafka
SONATYPE_HOST=S01
RELEASE_SIGNING_ENABLED=true

# Publication
RELEASE_REPOSITORY=https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/
SNAPSHOT_REPOSITORY=https://s01.oss.sonatype.org/content/repositories/snapshots/
POM_NAME=kotlin-kafka
POM_DESCRIPTION=Kafka integration with Kotlin, KotlinX Coroutines & Ktor.
POM_URL=https://github.com/nomisrev/kafka-kotlin/

# Pomfile definitions
pom.description=Kafka integration with Kotlin & KotlinX Coroutines
pom.url=https://github.com/nomisrev/kafka-kotlin
pom.license.name=The Apache Software License, Version 2.0
pom.license.url=https://www.apache.org/licenses/LICENSE-2.0.txt
pom.developer.id=nomisRev
pom.developer.name=Simon Vergauwen
pom.smc.url=https://github.com/nomisrev/kotlin-kafka
pom.smc.connection=scm:git:git://github.com/nomisrev/kotlin-kafka
pom.smc.developerConnection=scm:git:ssh://git@github.com/nomisrev/kotlin-kafka.git
POM_LICENSE_NAME=The Apache Software License, Version 2.0
POM_LICENSE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENSE_DIST=repo

POM_SCM_URL=https://github.com/nomisrev/kafka-kotlin/
POM_SCM_CONNECTION=scm:git:git://github.com/nomisRev/kafka-kotlin.git
POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/nomisRev/kafka-kotlin.git

POM_DEVELOPER_ID=nomisRev
POM_DEVELOPER_NAME=Simon Vergauwen
POM_DEVELOPER_URL=https://github.com/nomisRev/
12 changes: 5 additions & 7 deletions libs.versions.toml → gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[versions]
arrowGradleConfig = "0.12.0-rc.6"
kotest = "5.7.2"
kafka = "3.6.0"
kotlin = "1.9.10"
Expand All @@ -9,6 +8,8 @@ knit = "0.4.0"
kover = "0.7.3"
testcontainers-kafka = "1.19.1"
slf4j = "2.0.9"
spotless="6.22.0"
publish="0.25.3"

[libraries]
kotest-assertions = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" }
Expand Down Expand Up @@ -36,11 +37,8 @@ kotest = [

[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
arrowGradleConfig-kotlin = { id = "io.arrow-kt.arrow-gradle-config-kotlin", version.ref = "arrowGradleConfig" }
arrowGradleConfig-formatter = { id = "io.arrow-kt.arrow-gradle-config-formatter", version.ref = "arrowGradleConfig" }
arrowGradleConfig-nexus = { id = "io.arrow-kt.arrow-gradle-config-nexus", version.ref = "arrowGradleConfig" }
arrowGradleConfig-publish = { id = "io.arrow-kt.arrow-gradle-config-publish", version.ref = "arrowGradleConfig" }
arrowGradleConfig-versioning = { id = "io.arrow-kt.arrow-gradle-config-versioning", version.ref = "arrowGradleConfig" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
knit = { id = "org.jetbrains.kotlinx:kotlinx-knit", version.ref = "knit" }
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
publish = { id = "com.vanniktech.maven.publish", version.ref="publish" }
knit = { id = "org.jetbrains.kotlinx.knit", version.ref="knit" }
6 changes: 0 additions & 6 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
rootProject.name = "kotlin-kafka"

dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("libs.versions.toml"))
}
}

repositories {
mavenCentral()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import kotlin.time.Duration
* interval constraint. If so happens, time-to-next-chunk gets reset to the interval value.
*/
@ExperimentalCoroutinesApi
@Deprecated("Will no longer be part of kotlin-kafka.")
public fun <T> Flow<T>.chunked(
size: Int,
duration: Duration,
Expand All @@ -56,14 +57,14 @@ public fun <T> Flow<T>.chunked(
}
emitNowAndMaybeContinue.send(false)
}

whileSelect {
emitNowAndMaybeContinue.onReceive { shouldContinue ->
val chunk = elements.drain(maxElements = size)
if (chunk.isNotEmpty()) downstream.emit(chunk)
shouldContinue
}

onTimeout(duration) {
val chunk: List<T> = elements.drain(maxElements = size)
if (chunk.isNotEmpty()) downstream.emit(chunk)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import kotlin.time.Duration
* - Every `n` acknowledged records **or** every `interval` duration, whichever comes first.
*/
public sealed interface CommitStrategy {

/** Commit **all** [Offset.acknowledge] messages to kafka every [interval]. */
@JvmInline
public value class ByTime(public val interval: Duration) : CommitStrategy {
Expand All @@ -21,7 +21,7 @@ public sealed interface CommitStrategy {
}
}
}

/** Commit messages to kafka every [size] acknowledged message. */
@JvmInline
public value class BySize(public val size: Int) : CommitStrategy {
Expand All @@ -31,7 +31,7 @@ public sealed interface CommitStrategy {
}
}
}

/**
* Commit messages to kafka every [size] acknowledged message, or every [interval].
* Whichever condition is reached first.
Expand Down
Loading