From 078bf0a16af0898970cfe09edec3ca126f830f6a Mon Sep 17 00:00:00 2001 From: Shreyas Patil Date: Thu, 29 May 2025 23:10:27 +0530 Subject: [PATCH] Update project to use gradle kotlin script, version catalogue and update dependencies --- .idea/.gitignore | 2 + noty-api/.gitignore | 2 +- noty-api/application/build.gradle | 41 ------ noty-api/application/build.gradle.kts | 48 +++++++ noty-api/build.gradle | 131 ------------------ noty-api/build.gradle.kts | 40 ++++++ noty-api/data/build.gradle | 20 --- noty-api/data/build.gradle.kts | 58 ++++++++ noty-api/gradle/libs.versions.toml | 74 ++++++++++ .../gradle/wrapper/gradle-wrapper.properties | 2 +- noty-api/gradlew | 0 .../{settings.gradle => settings.gradle.kts} | 23 ++- 12 files changed, 245 insertions(+), 196 deletions(-) create mode 100644 .idea/.gitignore delete mode 100644 noty-api/application/build.gradle create mode 100644 noty-api/application/build.gradle.kts delete mode 100644 noty-api/build.gradle create mode 100644 noty-api/build.gradle.kts delete mode 100644 noty-api/data/build.gradle create mode 100644 noty-api/data/build.gradle.kts create mode 100644 noty-api/gradle/libs.versions.toml mode change 100644 => 100755 noty-api/gradlew rename noty-api/{settings.gradle => settings.gradle.kts} (64%) diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..256e2efc --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +** \ No newline at end of file diff --git a/noty-api/.gitignore b/noty-api/.gitignore index 35970e2f..15f5df4b 100644 --- a/noty-api/.gitignore +++ b/noty-api/.gitignore @@ -5,7 +5,7 @@ *.iml *.ipr *.iws -/.idea/ +/.idea/** .DS_Store /.env /build/ diff --git a/noty-api/application/build.gradle b/noty-api/application/build.gradle deleted file mode 100644 index ab5da9f8..00000000 --- a/noty-api/application/build.gradle +++ /dev/null @@ -1,41 +0,0 @@ -apply plugin: 'application' -apply plugin: 'kotlinx-serialization' - -group 'dev.shreyaspatil.noty.application' -version '0.1.0' -mainClassName = "io.ktor.server.netty.EngineMain" - -repositories { - mavenCentral() - mavenLocal() - jcenter() - maven { url 'https://kotlin.bintray.com/ktor' } -} - -dependencies { - // Data module - implementation project(":data") - - // Coroutines - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion" - - // Serializer - implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinSerializerVersion" - - // Ktor - implementation "io.ktor:ktor-server-netty:$ktorVersion" - implementation "io.ktor:ktor-server-core:$ktorVersion" - implementation "io.ktor:ktor-auth:$ktorVersion" - implementation "io.ktor:ktor-auth-jwt:$ktorVersion" - implementation "io.ktor:ktor-serialization:$ktorVersion" - - // Logging - implementation "ch.qos.logback:logback-classic:$logbackVersion" - - // Testing - testImplementation "io.ktor:ktor-server-tests:$ktorVersion" - testImplementation "org.testcontainers:testcontainers:$testContainerVersion" - testImplementation "org.testcontainers:postgresql:$testContainerVersion" -} - -build.finalizedBy(installDist) \ No newline at end of file diff --git a/noty-api/application/build.gradle.kts b/noty-api/application/build.gradle.kts new file mode 100644 index 00000000..2e5eec03 --- /dev/null +++ b/noty-api/application/build.gradle.kts @@ -0,0 +1,48 @@ +plugins { + application + alias(libs.plugins.kotlin.serialization) +} + +group = "dev.shreyaspatil.noty.application" +version = "1.0.0" + +application { + mainClass.set("io.ktor.server.netty.EngineMain") +} + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(libs.versions.java.get().toInt()) + } +} + +dependencies { + // Data module + implementation(project(":data")) + + // Coroutines + implementation(libs.coroutines.core) + + // Serializer + implementation(libs.kotlin.serialization) + + // Ktor + implementation(libs.ktor.server.netty) + implementation(libs.ktor.server.core) + implementation(libs.ktor.server.auth) + implementation(libs.ktor.server.auth.jwt) + implementation(libs.ktor.server.content.negotiation) + implementation(libs.ktor.serialization) + + // Logging + implementation(libs.logback) + + // Testing + testImplementation(libs.ktor.server.tests) + testImplementation(libs.testcontainers.core) + testImplementation(libs.testcontainers.postgres) +} + +tasks.named("build") { + finalizedBy("installDist") +} diff --git a/noty-api/build.gradle b/noty-api/build.gradle deleted file mode 100644 index e78fedc1..00000000 --- a/noty-api/build.gradle +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright 2020 Shreyas Patil - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -buildscript { - ext { - kotlinVersion = "2.0.21" - kotlinSerializerVersion = "1.5.1" - ktlintVersion = "11.6.1" - coroutinesVersion = "1.8.1" - ktorVersion = "1.6.8" - exposedVersion = "0.44.0" - postgresVersion = "42.7.4" - logbackVersion = "1.5.7" - daggerVersion = "2.47" - testContainerVersion = "1.19.1" - kotestVersion = "5.6.2" - hikariVersion = "5.0.1" - } - - repositories { - mavenCentral() - google() - maven { - url("https://plugins.gradle.org/m2/") - } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion" - classpath "org.jlleitschuh.gradle:ktlint-gradle:$ktlintVersion" - } -} - -apply plugin: 'kotlin' -apply plugin: 'jacoco' - -version "0.1.0" -group "dev.shreyaspatil.noty" - -repositories { - mavenCentral() - jcenter() -} - -subprojects { - apply(plugin: 'org.jetbrains.kotlin.jvm') - apply(plugin: 'org.jetbrains.kotlin.kapt') - apply(plugin: 'jacoco') - apply(plugin: 'org.jlleitschuh.gradle.ktlint') - - sourceCompatibility = "11" - targetCompatibility = "11" - - sourceSets { - main.kotlin.srcDirs = main.java.srcDirs = ['src'] - test.kotlin.srcDirs = test.java.srcDirs = ['test'] - main.resources.srcDirs = ['resources'] - test.resources.srcDirs = ['testresources'] - } - - test { - useJUnitPlatform() - jacoco { - destinationFile = file("${buildDir}/jacoco/test.exec") - } - } - - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { - kotlinOptions { - jvmTarget = "11" - } - } - - ktlint { - debug = true - verbose = true - outputToConsole = true - outputColorName = "RED" - } - - repositories { - mavenCentral() - mavenLocal() - google() - } - - dependencies { - // Kotlin - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" - implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion" - - // Dagger - implementation "com.google.dagger:dagger:$daggerVersion" - kapt "com.google.dagger:dagger-compiler:$daggerVersion" - - // Testing - testImplementation "io.kotest:kotest-runner-junit5-jvm:$kotestVersion" - testImplementation "io.kotest:kotest-assertions-core-jvm:$kotestVersion" - testImplementation "io.kotest:kotest-property-jvm:$kotestVersion" - } -} - -// Code Coverage Report (Jacoco) -task codeCoverageReport(type: JacocoReport) { - // Gather execution data from all subprojects - executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec") - - subprojects.each { - sourceSets it.sourceSets.main - } - - reports { - xml.enabled true - html.enabled true - csv.enabled false - } -} diff --git a/noty-api/build.gradle.kts b/noty-api/build.gradle.kts new file mode 100644 index 00000000..fbf9ab9c --- /dev/null +++ b/noty-api/build.gradle.kts @@ -0,0 +1,40 @@ +/* + * Copyright 2020 Shreyas Patil + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + alias(libs.plugins.kotlin.jvm) apply false + alias(libs.plugins.kotlin.ksp) apply false + alias(libs.plugins.ktlint) + alias(libs.plugins.kover) apply false +} + +version = "0.1.0" +group = "dev.shreyaspatil.noty" + +val jvmPluginId = libs.plugins.kotlin.jvm.get().pluginId +val ktlintPluginId = libs.plugins.ktlint.get().pluginId + +subprojects { + apply(plugin = jvmPluginId) + apply(plugin = ktlintPluginId) + + configure { + debug.set(true) + verbose.set(true) + outputToConsole.set(true) + outputColorName.set("RED") + } +} \ No newline at end of file diff --git a/noty-api/data/build.gradle b/noty-api/data/build.gradle deleted file mode 100644 index 2b20f3e4..00000000 --- a/noty-api/data/build.gradle +++ /dev/null @@ -1,20 +0,0 @@ -repositories { - jcenter() -} - -dependencies { - // Exposed - implementation "org.jetbrains.exposed:exposed-core:$exposedVersion" - implementation "org.jetbrains.exposed:exposed-dao:$exposedVersion" - implementation "org.jetbrains.exposed:exposed-jdbc:$exposedVersion" - implementation "org.jetbrains.exposed:exposed-jodatime:$exposedVersion" - - // PostgreSQL - implementation "org.postgresql:postgresql:$postgresVersion" - - // Dagger - implementation "com.google.dagger:dagger:$daggerVersion" - kapt "com.google.dagger:dagger-compiler:$daggerVersion" - - implementation "com.zaxxer:HikariCP:$hikariVersion" -} \ No newline at end of file diff --git a/noty-api/data/build.gradle.kts b/noty-api/data/build.gradle.kts new file mode 100644 index 00000000..f72d9920 --- /dev/null +++ b/noty-api/data/build.gradle.kts @@ -0,0 +1,58 @@ + +plugins { + alias(libs.plugins.kotlin.ksp) + alias(libs.plugins.ktlint) + alias(libs.plugins.kover) +} + +group = "dev.shreyaspatil.noty.data" +version = "0.1.0" + +sourceSets { + main { + kotlin.srcDirs("src") + java.srcDirs("src") + resources.srcDirs("resources") + } + test { + kotlin.srcDirs("test") + java.srcDirs("test") + resources.srcDirs("testresources") + } +} + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(libs.versions.java.get().toInt()) + } +} + +tasks.test { + useJUnitPlatform() +} + +dependencies { + // Kotlin + implementation(libs.kotlin.stdlib) + implementation(libs.kotlin.reflect) + + // Exposed + implementation(libs.exposed.core) + implementation(libs.exposed.dao) + implementation(libs.exposed.jdbc) + implementation(libs.exposed.jodatime) + + // PostgreSQL + implementation(libs.postgres) + + // Dagger + implementation(libs.dagger) + ksp(libs.dagger.compiler) + + implementation(libs.hikari) + + // Testing + testImplementation(libs.kotest.runner) + testImplementation(libs.kotest.assertions) + testImplementation(libs.kotest.property) +} diff --git a/noty-api/gradle/libs.versions.toml b/noty-api/gradle/libs.versions.toml new file mode 100644 index 00000000..2fce94af --- /dev/null +++ b/noty-api/gradle/libs.versions.toml @@ -0,0 +1,74 @@ +[versions] +java = "17" + +# Kotlin +kotlin = "2.1.21" +ksp = "2.1.21-2.0.1" +kotlinSerialization = "1.8.1" +coroutines = "1.10.2" +ktlint = "12.3.0" +kover = "0.9.1" + +# Ktor +ktor = "3.1.3" + +# Database +exposed = "0.50.1" +postgres = "42.7.6" +hikari = "6.3.0" + +# Logging +logback = "1.5.11" + +# Dependency Injection +dagger = "2.51" # Keeping Dagger at 2.51. If you update Kotlin to 2.1.x, you might need Dagger 2.55+ for full KSP2 compatibility. + +# Testing +testcontainers = "1.21.0" +kotest = "6.0.0.M4" + +[libraries] +# Kotlin +kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" } +kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" } +kotlin-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinSerialization" } +coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" } + +# Ktor +ktor-server-netty = { module = "io.ktor:ktor-server-netty", version.ref = "ktor" } +ktor-server-core = { module = "io.ktor:ktor-server-core", version.ref = "ktor" } +ktor-server-auth = { module = "io.ktor:ktor-server-auth", version.ref = "ktor" } +ktor-server-auth-jwt = { module = "io.ktor:ktor-server-auth-jwt", version.ref = "ktor" } +ktor-server-content-negotiation = { module = "io.ktor:ktor-server-content-negotiation", version.ref = "ktor" } +ktor-serialization = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" } +ktor-server-tests = { module = "io.ktor:ktor-server-test-host", version.ref = "ktor" } + +# Database +exposed-core = { module = "org.jetbrains.exposed:exposed-core", version.ref = "exposed" } +exposed-dao = { module = "org.jetbrains.exposed:exposed-dao", version.ref = "exposed" } +exposed-jdbc = { module = "org.jetbrains.exposed:exposed-jdbc", version.ref = "exposed" } +exposed-jodatime = { module = "org.jetbrains.exposed:exposed-jodatime", version.ref = "exposed" } +postgres = { module = "org.postgresql:postgresql", version.ref = "postgres" } +hikari = { module = "com.zaxxer:HikariCP", version.ref = "hikari" } + +# Logging +logback = { module = "ch.qos.logback:logback-classic", version.ref = "logback" } + +# Dependency Injection +dagger = { module = "com.google.dagger:dagger", version.ref = "dagger" } +dagger-compiler = { module = "com.google.dagger:dagger-compiler", version.ref = "dagger" } + +# Testing +kotest-runner = { module = "io.kotest:kotest-runner-junit5-jvm", version.ref = "kotest" } +kotest-assertions = { module = "io.kotest:kotest-assertions-core-jvm", version.ref = "kotest" } +kotest-property = { module = "io.kotest:kotest-property-jvm", version.ref = "kotest" } +testcontainers-core = { module = "org.testcontainers:testcontainers", version.ref = "testcontainers" } +testcontainers-postgres = { module = "org.testcontainers:postgresql", version.ref = "testcontainers" } + +[plugins] +kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } +kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" } +kotlin-ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } +ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" } +kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" } diff --git a/noty-api/gradle/wrapper/gradle-wrapper.properties b/noty-api/gradle/wrapper/gradle-wrapper.properties index 25780d01..8e75fafd 100644 --- a/noty-api/gradle/wrapper/gradle-wrapper.properties +++ b/noty-api/gradle/wrapper/gradle-wrapper.properties @@ -15,6 +15,6 @@ # distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/noty-api/gradlew b/noty-api/gradlew old mode 100644 new mode 100755 diff --git a/noty-api/settings.gradle b/noty-api/settings.gradle.kts similarity index 64% rename from noty-api/settings.gradle rename to noty-api/settings.gradle.kts index 8af76c0f..838ffd28 100644 --- a/noty-api/settings.gradle +++ b/noty-api/settings.gradle.kts @@ -15,5 +15,24 @@ */ rootProject.name = "noty-api" -include 'application' -include 'data' \ No newline at end of file +include("application") +include("data") + +pluginManagement { + repositories { + gradlePluginPortal() + mavenCentral() + google() + } +} + + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + + repositories { + mavenCentral() + mavenLocal() + google() + } +}