diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 591f1c8b..d5f7225d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,13 +34,13 @@ jobs: # Compile code - name: Compile code - run: ./gradlew assemble + run: ./gradlew assemble collectLicenses # Upload it to GitHub - name: Upload to GitHub - uses: AButler/upload-release-assets@v2.0 + uses: AButler/upload-release-assets@v2.0.2 with: - files: 'radar-commons*/build/libs/*' + files: 'radar-commons*/build/libs/*;radar-commons*/build/reports/*.tar.gz' repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Install gpg secret key diff --git a/.snyk b/.snyk new file mode 100644 index 00000000..38593053 --- /dev/null +++ b/.snyk @@ -0,0 +1,10 @@ +# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities. +version: v1.25.0 +# ignores vulnerabilities until expiry date; change duration by modifying expiry date +ignore: + SNYK-JAVA-ORGJETBRAINSKOTLIN-2393744: + - '*': + reason: Not using createTempDir in Kotlin + expires: 2024-12-02T10:06:59.964Z + created: 2023-07-03T10:06:59.968Z +patch: {} diff --git a/README.md b/README.md index 6ab1c972..118f8e21 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ repositories { } dependencies { - implementation("org.radarbase:radar-commons:1.0.0") + implementation("org.radarbase:radar-commons:1.0.1") } ``` @@ -62,7 +62,7 @@ repositories { } dependencies { - implementation("org.radarbase:radar-commons-server:1.0.0") + implementation("org.radarbase:radar-commons-server:1.0.1") } ``` @@ -75,7 +75,7 @@ repositories { } dependencies { - testImplementation("org.radarbase:radar-commons-testing:1.0.0") + testImplementation("org.radarbase:radar-commons-testing:1.0.1") } ``` @@ -102,7 +102,7 @@ configurations.all { } dependencies { - implementation("org.radarbase:radar-commons:1.0.1-SNAPSHOT") + implementation("org.radarbase:radar-commons:1.0.2-SNAPSHOT") } ``` diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 44592243..10e056f5 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -1,25 +1,27 @@ object Versions { - const val project = "1.0.0" + const val project = "1.0.1" object Plugins { - const val kotlin = "1.8.21" + const val kotlin = "1.8.22" const val kotlinSerialization = kotlin - const val avro = "1.7.0" + const val avro = "1.7.1" } const val java = 11 const val slf4j = "2.0.7" - const val confluent = "7.3.2" - const val kafka = "7.3.2-ce" + const val confluent = "7.4.0" + const val kafka = "7.4.0-ce" + const val snappy = "1.1.10.1" + const val guava = "32.1.1-jre" const val avro = "1.11.1" - const val jackson = "2.15.0" + const val jackson = "2.15.2" const val okhttp = "4.11.0" const val junit = "5.9.3" - const val mockito = "5.3.1" - const val mockitoKotlin = "4.1.0" + const val mockito = "5.4.0" + const val mockitoKotlin = "5.0.0" const val hamcrest = "2.2" - const val radarSchemas = "0.8.2" + const val radarSchemas = "0.8.4" const val opencsv = "5.7.1" - const val ktor = "2.3.0" - const val coroutines = "1.6.4" + const val ktor = "2.3.2" + const val coroutines = "1.7.2" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index c1962a79..033e24c4 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 37aef8d3..62f495df 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index aeb74cbb..fcb6fca1 100755 --- a/gradlew +++ b/gradlew @@ -130,10 +130,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. diff --git a/radar-commons-gradle/build.gradle.kts b/radar-commons-gradle/build.gradle.kts index 49e540e2..aaef4364 100644 --- a/radar-commons-gradle/build.gradle.kts +++ b/radar-commons-gradle/build.gradle.kts @@ -7,7 +7,7 @@ plugins { `maven-publish` } -version = "1.0.0" +version = "1.0.1" group = "org.radarbase" description = "RADAR common Gradle plugins" @@ -17,11 +17,12 @@ repositories { } dependencies { - implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10") - implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.8.10") - implementation("com.github.ben-manes:gradle-versions-plugin:0.46.0") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.22") + implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.8.20") + implementation("com.github.ben-manes:gradle-versions-plugin:0.47.0") implementation("io.github.gradle-nexus:publish-plugin:1.3.0") - implementation("org.jlleitschuh.gradle:ktlint-gradle:11.3.2") + implementation("org.jlleitschuh.gradle:ktlint-gradle:11.4.2") + implementation("com.github.jk1.dependency-license-report:com.github.jk1.dependency-license-report.gradle.plugin:2.5") } gradlePlugin { diff --git a/radar-commons-gradle/src/main/kotlin/org/radarbase/gradle/plugin/RadarDependencyManagementPlugin.kt b/radar-commons-gradle/src/main/kotlin/org/radarbase/gradle/plugin/RadarDependencyManagementPlugin.kt index 8baf32b6..f36993c2 100644 --- a/radar-commons-gradle/src/main/kotlin/org/radarbase/gradle/plugin/RadarDependencyManagementPlugin.kt +++ b/radar-commons-gradle/src/main/kotlin/org/radarbase/gradle/plugin/RadarDependencyManagementPlugin.kt @@ -22,7 +22,7 @@ interface RadarDependencyManagementExtension { class RadarDependencyManagementPlugin : Plugin { override fun apply(project: Project): Unit = with(project) { val extension = extensions.create("radarDependencies").apply { - regex.convention("(^[0-9,.v-]+(-r)?|RELEASE|FINAL|GA|-CE)$") + regex.convention("(^[0-9,.v-]+(-r)?|RELEASE|FINAL|GA|-CE|-JRE|-ANDROID)$") rejectMajorVersionUpdates.convention(false) } diff --git a/radar-commons-gradle/src/main/kotlin/org/radarbase/gradle/plugin/RadarKotlinPlugin.kt b/radar-commons-gradle/src/main/kotlin/org/radarbase/gradle/plugin/RadarKotlinPlugin.kt index eff4de65..7c408d4f 100644 --- a/radar-commons-gradle/src/main/kotlin/org/radarbase/gradle/plugin/RadarKotlinPlugin.kt +++ b/radar-commons-gradle/src/main/kotlin/org/radarbase/gradle/plugin/RadarKotlinPlugin.kt @@ -1,11 +1,14 @@ package org.radarbase.gradle.plugin +import com.github.jk1.license.LicenseReportPlugin import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.plugins.ApplicationPlugin import org.gradle.api.plugins.JavaApplication import org.gradle.api.provider.Property import org.gradle.api.tasks.Copy +import org.gradle.api.tasks.bundling.Compression +import org.gradle.api.tasks.bundling.Tar import org.gradle.api.tasks.compile.JavaCompile import org.gradle.api.tasks.testing.Test import org.gradle.api.tasks.testing.logging.TestExceptionFormat @@ -23,6 +26,7 @@ fun Project.radarKotlin(configure: RadarKotlinExtension.() -> Unit) { interface RadarKotlinExtension { val javaVersion: Property val kotlinVersion: Property + val kotlinApiVersion: Property val junitVersion: Property val log4j2Version: Property val slf4jVersion: Property @@ -34,6 +38,7 @@ class RadarKotlinPlugin : Plugin { val extension = extensions.create("radarKotlin").apply { javaVersion.convention(Versions.java) kotlinVersion.convention(Versions.kotlin) + kotlinApiVersion.convention("") junitVersion.convention(Versions.junit) ktlintVersion.convention(Versions.ktlint) slf4jVersion.convention(Versions.ktlint) @@ -67,17 +72,21 @@ class RadarKotlinPlugin : Plugin { tasks.withType { compilerOptions { - jvmTarget.set(extension.javaVersion.map { JvmTarget.fromTarget(it.toString()) }) - val kotlinVersion = extension.kotlinVersion.map { version -> - KotlinVersion.fromVersion( - version - .splitToSequence('.') - .take(2) - .joinToString(separator = "."), - ) - } - apiVersion.set(kotlinVersion) - languageVersion.set(kotlinVersion) + jvmTarget.set( + extension.javaVersion.map { JvmTarget.fromTarget(it.toString()) } + ) + apiVersion.set( + extension.kotlinApiVersion.zip(extension.kotlinVersion) { apiVersion, kotlinVersion -> + if (apiVersion.isNotEmpty()) { + KotlinVersion.fromVersion(apiVersion) + } else { + kotlinVersion.toKotlinVersion() + } + } + ) + languageVersion.set( + extension.kotlinVersion.map { it.toKotlinVersion() } + ) } } @@ -117,6 +126,19 @@ class RadarKotlinPlugin : Plugin { } } + apply() + + tasks.register("collectLicenses") { + from( + fileTree("$buildDir/reports/dependency-license"), + rootDir.resolve("LICENSE"), + ) + compression = Compression.GZIP + destinationDirectory.set(file("$buildDir/reports")) + archiveBaseName.set("${project.name}-dependency-license") + dependsOn(tasks["generateLicenseReport"]) + } + afterEvaluate { if (extension.slf4jVersion.isPresent) { dependencies { @@ -164,4 +186,12 @@ class RadarKotlinPlugin : Plugin { resolutionStrategy.cacheChangingModulesFor(0, "SECONDS") } } + + companion object { + fun String.toKotlinVersion() = KotlinVersion.fromVersion( + splitToSequence('.') + .take(2) + .joinToString(separator = "."), + ) + } } diff --git a/radar-commons-gradle/src/main/kotlin/org/radarbase/gradle/plugin/Versions.kt b/radar-commons-gradle/src/main/kotlin/org/radarbase/gradle/plugin/Versions.kt index f21d4a8d..d9224dec 100644 --- a/radar-commons-gradle/src/main/kotlin/org/radarbase/gradle/plugin/Versions.kt +++ b/radar-commons-gradle/src/main/kotlin/org/radarbase/gradle/plugin/Versions.kt @@ -1,9 +1,9 @@ package org.radarbase.gradle.plugin object Versions { - const val wrapper = "8.1.1" - const val kotlin = "1.8.21" - const val ktlint = "0.48.2" + const val wrapper = "8.2" + const val kotlin = "1.8.22" + const val ktlint = "0.49.1" const val java = 11 const val junit = "5.9.3" } diff --git a/radar-commons-kotlin/build.gradle.kts b/radar-commons-kotlin/build.gradle.kts index 33cced0f..a288b7cc 100644 --- a/radar-commons-kotlin/build.gradle.kts +++ b/radar-commons-kotlin/build.gradle.kts @@ -13,5 +13,5 @@ dependencies { implementation("io.ktor:ktor-client-content-negotiation") implementation("io.ktor:ktor-serialization-kotlinx-json") - testImplementation("org.hamcrest:hamcrest:2.2") + testImplementation("org.hamcrest:hamcrest:${Versions.hamcrest}") } diff --git a/radar-commons-kotlin/src/main/kotlin/org/radarbase/kotlin/util/Extensions.kt b/radar-commons-kotlin/src/main/kotlin/org/radarbase/kotlin/util/Extensions.kt new file mode 100644 index 00000000..651e8d04 --- /dev/null +++ b/radar-commons-kotlin/src/main/kotlin/org/radarbase/kotlin/util/Extensions.kt @@ -0,0 +1,3 @@ +package org.radarbase.kotlin.util + +fun String?.removeSensitive(): String = if (this == null) "null" else "***" diff --git a/radar-commons-kotlin/src/main/kotlin/org/radarbase/ktor/auth/ClientCredentialsConfig.kt b/radar-commons-kotlin/src/main/kotlin/org/radarbase/ktor/auth/ClientCredentialsConfig.kt index 3584c895..b1ba8a72 100644 --- a/radar-commons-kotlin/src/main/kotlin/org/radarbase/ktor/auth/ClientCredentialsConfig.kt +++ b/radar-commons-kotlin/src/main/kotlin/org/radarbase/ktor/auth/ClientCredentialsConfig.kt @@ -1,5 +1,7 @@ package org.radarbase.ktor.auth +import org.radarbase.kotlin.util.removeSensitive + data class ClientCredentialsConfig( val tokenUrl: String, val clientId: String? = null, @@ -21,4 +23,7 @@ data class ClientCredentialsConfig( } return result } + + override fun toString(): String = + "ClientCredentialsConfig(tokenUrl='$tokenUrl', clientId=$clientId, clientSecret=${clientSecret.removeSensitive()})" } diff --git a/radar-commons-kotlin/src/main/kotlin/org/radarbase/ktor/auth/OAuthClientProvider.kt b/radar-commons-kotlin/src/main/kotlin/org/radarbase/ktor/auth/OAuthClientProvider.kt index 26df4678..785096e5 100644 --- a/radar-commons-kotlin/src/main/kotlin/org/radarbase/ktor/auth/OAuthClientProvider.kt +++ b/radar-commons-kotlin/src/main/kotlin/org/radarbase/ktor/auth/OAuthClientProvider.kt @@ -4,13 +4,11 @@ import io.ktor.client.* import io.ktor.client.call.* import io.ktor.client.plugins.auth.* import io.ktor.client.plugins.auth.providers.* -import io.ktor.client.plugins.contentnegotiation.* import io.ktor.client.request.* import io.ktor.client.request.forms.* import io.ktor.client.statement.* import io.ktor.http.* import io.ktor.http.auth.* -import io.ktor.serialization.kotlinx.json.* import io.ktor.util.* import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow diff --git a/radar-commons-server/build.gradle.kts b/radar-commons-server/build.gradle.kts index f3522cda..b55bdca7 100644 --- a/radar-commons-server/build.gradle.kts +++ b/radar-commons-server/build.gradle.kts @@ -32,7 +32,13 @@ dependencies { api("org.apache.avro:avro:${Versions.avro}") - implementation("org.apache.kafka:kafka-clients:${Versions.kafka}") + implementation("org.apache.kafka:kafka-clients:${Versions.kafka}") { + runtimeOnly("org.xerial.snappy:snappy-java") { + version { + strictly(Versions.snappy) + } + } + } testImplementation("org.mockito:mockito-core:${Versions.mockito}") // Direct producer uses KafkaAvroSerializer if initialized diff --git a/radar-commons-testing/build.gradle.kts b/radar-commons-testing/build.gradle.kts index a1513bcc..184589a2 100644 --- a/radar-commons-testing/build.gradle.kts +++ b/radar-commons-testing/build.gradle.kts @@ -47,8 +47,17 @@ dependencies { implementation(platform("com.fasterxml.jackson:jackson-bom:${Versions.jackson}")) implementation("com.fasterxml.jackson.core:jackson-databind") - implementation("org.apache.kafka:kafka-clients:${Versions.kafka}") - implementation("io.confluent:kafka-avro-serializer:${Versions.confluent}") + implementation("org.apache.kafka:kafka-clients:${Versions.kafka}") { + runtimeOnly("org.xerial.snappy:snappy-java") { + version { + strictly(Versions.snappy) + } + } + } + + implementation("io.confluent:kafka-avro-serializer:${Versions.confluent}") { + runtimeOnly("com.google.guava:guava:${Versions.guava}") + } implementation(platform("io.ktor:ktor-bom:${Versions.ktor}")) implementation("io.ktor:ktor-serialization-kotlinx-json") diff --git a/radar-commons/build.gradle.kts b/radar-commons/build.gradle.kts index 02d3db94..906a901f 100644 --- a/radar-commons/build.gradle.kts +++ b/radar-commons/build.gradle.kts @@ -15,7 +15,9 @@ repositories { // In this section you declare the dependencies for your production and test code dependencies { - api("org.apache.avro:avro:${Versions.avro}") + api("org.apache.avro:avro:${Versions.avro}") { + runtimeOnly("com.fasterxml.jackson.core:jackson-databind:${Versions.jackson}") + } api(kotlin("reflect")) implementation(project(":radar-commons-kotlin")) diff --git a/radar-commons/src/main/java/org/radarbase/data/Record.kt b/radar-commons/src/main/java/org/radarbase/data/Record.kt index 4c3d4c8e..f26981de 100644 --- a/radar-commons/src/main/java/org/radarbase/data/Record.kt +++ b/radar-commons/src/main/java/org/radarbase/data/Record.kt @@ -18,12 +18,7 @@ package org.radarbase.data /** * A single data record. * - * @param key type - * @param value type - */ -class Record -/** - * Single record, with current time as time added. - * @param key key - * @param value value - */(val key: K, val value: V) + * @param K key type + * @param V value type +*/ +class Record(val key: K, val value: V) diff --git a/radar-commons/src/main/java/org/radarbase/producer/io/DirectBinaryEncoder.kt b/radar-commons/src/main/java/org/radarbase/producer/io/DirectBinaryEncoder.kt index c82df2b4..0b51276b 100644 --- a/radar-commons/src/main/java/org/radarbase/producer/io/DirectBinaryEncoder.kt +++ b/radar-commons/src/main/java/org/radarbase/producer/io/DirectBinaryEncoder.kt @@ -67,9 +67,9 @@ class DirectBinaryEncoder( } /* - * buffering is slower for ints that encode to just 1 or two bytes, and and - * faster for large ones. (Sun JRE 1.6u22, x64 -server) - */ + * buffering is slower for ints that encode to just 1 or two bytes, and and + * faster for large ones. (Sun JRE 1.6u22, x64 -server) + */ @Throws(IOException::class) override suspend fun writeInt(n: Int) { val `val` = n shl 1 xor (n shr 31) @@ -86,9 +86,9 @@ class DirectBinaryEncoder( } /* - * buffering is slower for writeLong when the number is small enough to fit in - * an int. (Sun JRE 1.6u22, x64 -server) - */ + * buffering is slower for writeLong when the number is small enough to fit in + * an int. (Sun JRE 1.6u22, x64 -server) + */ @Throws(IOException::class) override suspend fun writeLong(n: Long) { val `val` = n shl 1 xor (n shr 63) // move sign to low-order bit diff --git a/radar-commons/src/main/java/org/radarbase/producer/rest/RestException.kt b/radar-commons/src/main/java/org/radarbase/producer/rest/RestException.kt index 9048105b..0cc307ca 100644 --- a/radar-commons/src/main/java/org/radarbase/producer/rest/RestException.kt +++ b/radar-commons/src/main/java/org/radarbase/producer/rest/RestException.kt @@ -20,13 +20,10 @@ import java.io.IOException /** * Exception when a HTTP REST request fails. - */ -class RestException -/** - * Request with status code and response body. * @param status HTTP status code * @param body response body. - */( + */ +class RestException( val status: HttpStatusCode, body: String? = null, cause: Throwable? = null, diff --git a/radar-commons/src/main/java/org/radarbase/producer/schema/ParsedSchemaMetadata.kt b/radar-commons/src/main/java/org/radarbase/producer/schema/ParsedSchemaMetadata.kt index 64ff333c..53fd5126 100644 --- a/radar-commons/src/main/java/org/radarbase/producer/schema/ParsedSchemaMetadata.kt +++ b/radar-commons/src/main/java/org/radarbase/producer/schema/ParsedSchemaMetadata.kt @@ -19,14 +19,11 @@ import org.apache.avro.Schema /** * Parsed schema metadata from a Schema Registry. - */ -data class ParsedSchemaMetadata -/** - * Schema metadata. * @param id schema ID, may be null. * @param version schema version, may be null. * @param schema parsed schema. - */( + */ +data class ParsedSchemaMetadata( val id: Int, val version: Int?, val schema: Schema, diff --git a/radar-commons/src/main/java/org/radarbase/producer/schema/SchemaMetadata.kt b/radar-commons/src/main/java/org/radarbase/producer/schema/SchemaMetadata.kt index 2eb8096a..2dde56ca 100644 --- a/radar-commons/src/main/java/org/radarbase/producer/schema/SchemaMetadata.kt +++ b/radar-commons/src/main/java/org/radarbase/producer/schema/SchemaMetadata.kt @@ -20,15 +20,12 @@ import org.apache.avro.Schema /** * Parsed schema metadata from a Schema Registry. - */ -@Serializable -data class SchemaMetadata -/** - * Schema metadata. * @param id schema ID, may be null. * @param version schema version, may be null. * @param schema parsed schema. - */( + */ +@Serializable +data class SchemaMetadata( val id: Int? = null, val version: Int? = null, val schema: String? = null,