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

refactor/align-target-versions #172

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
Open
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
20 changes: 5 additions & 15 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,17 @@ import org.radarbase.gradle.plugin.radarPublishing
* limitations under the License.
*/
plugins {
kotlin("plugin.serialization") version Versions.Plugins.kotlinSerialization apply false
kotlin("plugin.allopen") version Versions.Plugins.kotlinAllOpen apply false
id("com.github.davidmc24.gradle.plugin.avro") version Versions.Plugins.avro apply false
alias(libs.plugins.avro) apply false
id("org.radarbase.radar-root-project")
id("org.radarbase.radar-dependency-management")
id("org.radarbase.radar-kotlin") apply false
id("org.radarbase.radar-publishing") apply false
}

val githubRepoName = "RADAR-base/radar-commons"
val githubUrl = "https://github.com/$githubRepoName"

radarRootProject {
projectVersion.set(Versions.project)
gradleVersion.set(Versions.Plugins.gradle)
projectVersion.set(properties["projectVersion"] as String)
gradleVersion.set(libs.versions.gradle)
}

subprojects {
Expand All @@ -40,8 +36,8 @@ subprojects {
apply(plugin = "org.radarbase.radar-publishing")

dependencies {
configurations["testImplementation"]("org.jetbrains.kotlinx:kotlinx-coroutines-test:${Versions.coroutines}")
configurations["testRuntimeOnly"]("org.slf4j:slf4j-simple:${Versions.slf4j}")
configurations["testImplementation"](rootProject.libs.coroutines.test)
configurations["testRuntimeOnly"](rootProject.libs.slf4j.simple)
}

radarPublishing {
Expand All @@ -62,10 +58,4 @@ subprojects {
}
}

radarKotlin {
javaVersion.set(Versions.java)
kotlinVersion.set(Versions.Plugins.kotlin)
junitVersion.set(Versions.junit)
slf4jVersion.set(Versions.slf4j)
}
}
23 changes: 0 additions & 23 deletions buildSrc/build.gradle.kts

This file was deleted.

36 changes: 0 additions & 36 deletions buildSrc/src/main/kotlin/Versions.kt

This file was deleted.

3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# IMPORTANT!! Also set projectVersion in radar-commons-gradle/gradle.properties
projectVersion=1.1.3-SNAPSHOT

org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
73 changes: 73 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# IMPORTANT!! The versions in the following files must be kept in sync:
# - gradle/libs.versions.toml
# - radar-commons-gradle/src/main/kotlin/org/radarbase/gradle/plugin/Versions.kt
[versions]

# platform
java = "17"
gradle = "8.7"
kotlin = "1.9.21"
ktlint = "0.50.0"

# libraries
coroutines = "1.7.3"
ktor = "2.3.4"
slf4j = "2.0.16"
confluent = "7.6.0"
kafka = "7.6.0-ce"
avro = "1.12.0"
jackson = "2.15.3"
okhttp = "4.12.0"
junit = "5.10.0"
mockito = "5.5.0"
mockitoKotlin = "5.1.0"
hamcrest = "2.2"
radarSchemas = "0.8.8"
opencsv = "5.8"
commonsCompress = "1.26.0"
snappy = "1.1.10.5"
guava = "32.1.1-jre"

# gradle plugins
gradleVersionsPlugin = "0.50.0"
ktlintPlugin = "12.0.3"
licenseReportPlugin = "2.5"
dokkaPlugin = "1.9.10"
avroPlugin = "1.8.0"
nexusPublishPlugin = "2.0.0-rc-1"
sentryPlugin = "4.10.0"

[libraries]
# Note: some gradle plugins are passed as API dependencies, hence appreance in the libraries section.
gradle-kotlin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
gradle-dokka = { group = "org.jetbrains.dokka", name = "dokka-gradle-plugin", version.ref = "dokkaPlugin" }
gradle-versions = { group = "com.github.ben-manes", name = "gradle-versions-plugin", version.ref = "gradleVersionsPlugin" }
gradle-nexus-publish = { group = "io.github.gradle-nexus", name = "publish-plugin", version.ref = "nexusPublishPlugin" }
gradle-ktlint = { group = "org.jlleitschuh.gradle", name = "ktlint-gradle", version.ref = "ktlintPlugin" }
gradle-license-report = { group = "com.github.jk1.dependency-license-report", name = "com.github.jk1.dependency-license-report.gradle.plugin", version.ref = "licenseReportPlugin" }
gradle-sentry = { group = "io.sentry.jvm.gradle", name = "io.sentry.jvm.gradle.gradle.plugin", version.ref = "sentryPlugin" }
avro = { group = "org.apache.avro", name = "avro", version.ref = "avro" }
commons-compress = { group = "org.apache.commons", name = "commons-compress", version.ref = "commonsCompress" }
ktor-bom = { group = "io.ktor", name = "ktor-bom", version.ref = "ktor" }
coroutines-bom = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-bom", version.ref = "coroutines" }
coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "coroutines" }
coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "coroutines" }
jackson-bom = { group = "com.fasterxml.jackson", name = "jackson-bom", version.ref = "jackson" }
radar-schemas-commons = { group = "org.radarbase", name = "radar-schemas-commons", version.ref = "radarSchemas" }
mockito-core = { group = "org.mockito", name = "mockito-core", version.ref = "mockito" }
mockito-kotlin = { group = "org.mockito.kotlin", name = "mockito-kotlin", version.ref = "mockitoKotlin" }
mockwebserver = { group = "com.squareup.okhttp3", name = "mockwebserver", version.ref = "okhttp" }
hamcrest = { group = "org.hamcrest", name = "hamcrest", version.ref = "hamcrest" }
snappy-java = { group = "org.xerial.snappy", name = "snappy-java", version.ref = "snappy" }
kafka-avro-serializer = { group = "io.confluent", name = "kafka-avro-serializer", version.ref = "confluent" }
guava = { group = "com.google.guava", name = "guava", version.ref = "guava" }
opencsv = { group = "com.opencsv", name = "opencsv", version.ref = "opencsv" }
slf4j-simple = { group = "org.slf4j", name = "slf4j-simple", version.ref = "slf4j" }

[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
kotlin-allopen = { id = "org.jetbrains.kotlin.plugin.allopen", version.ref = "kotlin" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokkaPlugin" }
nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexusPublishPlugin"}
avro = { id = "com.github.davidmc24.gradle.plugin.avro", version.ref = "avroPlugin" }
77 changes: 19 additions & 58 deletions radar-commons-gradle/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
`kotlin-dsl`
`java-gradle-plugin`
// Match to the versions in the bottom of this file
kotlin("jvm") version "1.9.24"
`maven-publish`
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
id("org.jetbrains.dokka") version "1.9.10"
signing
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.nexus.publish)
alias(libs.plugins.dokka)
}

version = Versions.project
version = properties["projectVersion"] as String
group = "org.radarbase"
description = "RADAR-base common Gradle plugin setup"

Expand All @@ -24,13 +23,13 @@ repositories {
}

dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.Plugins.kotlin}")
implementation("org.jetbrains.dokka:dokka-gradle-plugin:${Versions.Plugins.dokka}")
implementation("com.github.ben-manes:gradle-versions-plugin:${Versions.gradleVersionsPlugin}")
implementation("io.github.gradle-nexus:publish-plugin:${Versions.Plugins.publishPlugin}")
implementation("org.jlleitschuh.gradle:ktlint-gradle:${Versions.ktlint}")
implementation("com.github.jk1.dependency-license-report:com.github.jk1.dependency-license-report.gradle.plugin:${Versions.Plugins.licenseReport}")
implementation("io.sentry.jvm.gradle:io.sentry.jvm.gradle.gradle.plugin:${Versions.sentry}")
implementation(libs.gradle.kotlin)
implementation(libs.gradle.dokka)
implementation(libs.gradle.versions)
implementation(libs.gradle.nexus.publish)
implementation(libs.gradle.ktlint)
implementation(libs.gradle.sentry)
implementation(libs.gradle.license.report)
}

gradlePlugin {
Expand All @@ -55,12 +54,12 @@ gradlePlugin {
}

tasks.withType<JavaCompile> {
options.release.set(Versions.java)
options.release.set(libs.versions.java.get().toIntOrNull())
}

tasks.withType<KotlinCompile> {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
jvmTarget.set(JvmTarget.fromTarget(libs.versions.java.get()))
languageVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9)
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9)
}
Expand All @@ -70,7 +69,7 @@ tasks.withType<Jar> {
manifest {
attributes(
"Implementation-Title" to project.name,
"Implementation-Version" to project.version
"Implementation-Version" to project.version,
)
}
}
Expand Down Expand Up @@ -136,13 +135,15 @@ publishing {
}
}

fun Project.propertyOrEnv(propertyName: String, envName: String): String? {
return if (hasProperty(propertyName)) {
fun Project.propertyOrEnv(
propertyName: String,
envName: String,
): String? =
if (hasProperty(propertyName)) {
property(propertyName)?.toString()
} else {
System.getenv(envName)
}
}

nexusPublishing {
this.repositories {
Expand Down Expand Up @@ -172,43 +173,3 @@ tasks.withType<Sign> {
tasks.withType<PublishToMavenRepository> {
dependsOn(tasks.withType<Sign>())
}

// Because this project is where all the required plugins get built, we need to add the dependencies separately here.
// They should be copied from the Versions.kt file directly to maintain consistency.
@Suppress("ConstPropertyName", "MemberVisibilityCanBePrivate")
object Versions {
const val project = "1.1.3-SNAPSHOT"

object Plugins {
const val licenseReport = "2.5"
const val kotlin = "1.9.21"
const val dokka = "1.9.10"
const val kotlinSerialization = kotlin
const val kotlinAllOpen = kotlin
const val avro = "1.8.0"
const val gradle = "8.3"
const val publishPlugin = "2.0.0-rc-1"
}

const val java = 17
const val slf4j = "2.0.13"
const val confluent = "7.6.0"
const val kafka = "${confluent}-ce"
const val avro = "1.12.0"
const val jackson = "2.15.3"
const val okhttp = "4.12.0"
const val junit = "5.10.0"
const val mockito = "5.5.0"
const val mockitoKotlin = "5.1.0"
const val hamcrest = "2.2"
const val radarSchemas = "0.8.8"
const val opencsv = "5.8"
const val ktor = "2.3.4"
const val coroutines = "1.7.3"
const val commonsCompress = "1.26.0"
const val snappy = "1.1.10.5"
const val guava = "32.1.1-jre"
const val gradleVersionsPlugin = "0.50.0"
const val ktlint = "12.0.3"
const val sentry = "4.10.0"
}
2 changes: 2 additions & 0 deletions radar-commons-gradle/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# IMPORTANT!! Also set projectVersion in gradle.properties of the root project.
projectVersion=1.1.3-SNAPSHOT
8 changes: 8 additions & 0 deletions radar-commons-gradle/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Allows to use the root project version catalog in the includeBuild module
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class RadarRootProjectPlugin : Plugin<Project> {
override fun apply(project: Project) = with(project) {
val extension = extensions.create<RadarRootProjectExtension>("radarRootProject").apply {
group.convention("org.radarbase")
gradleVersion.convention(Versions.wrapper)
gradleVersion.convention(Versions.gradle)
}

allprojects {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package org.radarbase.gradle.plugin

/*
Versions are defined in this object because they cannot be read from the gradle project.
IMPORTANT!! The versions in the following files must be kept in sync:
- gradle/libs.versions.toml
- radar-commons-gradle/src/main/kotlin/org/radarbase/gradle/plugin/Versions.kt
*/
@Suppress("ktlint:standard:property-naming")
object Versions {
const val wrapper = "8.3"
const val kotlin = "1.9.10"
const val ktlint = "0.50.0"
const val java = 11
const val gradle = "8.7"
const val java = 17
const val kotlin = "1.9.21"
const val ktlint = "0.50.0" // Ruleset version
const val junit = "5.10.0"
const val slf4j = "2.0.16"
}
16 changes: 8 additions & 8 deletions radar-commons-kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
plugins {
kotlin("plugin.serialization")
alias(libs.plugins.kotlin.serialization)
}

description = "Library for Kotlin utility classes and functions"

dependencies {
api(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:${Versions.coroutines}"))
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.coroutines}")
api(platform(libs.coroutines.bom))
api("org.jetbrains.kotlinx:kotlinx-coroutines-core")

api(platform("io.ktor:ktor-bom:${Versions.ktor}"))
api("io.ktor:ktor-client-auth:${Versions.ktor}")
implementation("io.ktor:ktor-client-content-negotiation:${Versions.ktor}")
implementation("io.ktor:ktor-serialization-kotlinx-json:${Versions.ktor}")
api(platform(libs.ktor.bom))
api("io.ktor:ktor-client-auth")
implementation("io.ktor:ktor-client-content-negotiation")
implementation("io.ktor:ktor-serialization-kotlinx-json")

testImplementation("org.hamcrest:hamcrest:${Versions.hamcrest}")
testImplementation(libs.hamcrest)
}
Loading
Loading