Skip to content

Commit

Permalink
[Server] Update Gradle to version 8.10.2 and all the major server dep…
Browse files Browse the repository at this point in the history
…endencies.
  • Loading branch information
gmarciani committed Nov 3, 2024
1 parent 8a9d492 commit aecd0d0
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 36 deletions.
2 changes: 1 addition & 1 deletion server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM ubuntu:22.04

ENV DEBIAN_FRONTEND noninteractive
ENV JAVA_VERSION 17.0.11
ENV GRADLE_VERSION 7.6.4
ENV GRADLE_VERSION 8.10.2
ENV SDKMAN_DIR /usr/local/sdkman
ENV YAWA_DIR /usr/src/yawa
ENV LOG_DIR /var/yawa/logs
Expand Down
69 changes: 37 additions & 32 deletions server/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.jvm.JvmTargetValidationMode
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.ByteArrayOutputStream
import java.util.Locale

plugins {
id("java")
id("org.springframework.boot") version "3.1.1"
id("io.spring.dependency-management") version "1.1.5"
id("org.springframework.boot") version "3.1.5" // 3.3.5
id("io.spring.dependency-management") version "1.1.6"
id("org.openapi.generator") version "6.6.0"
id("com.github.ben-manes.versions") version "0.51.0"
id("org.jetbrains.kotlin.plugin.allopen") version "1.9.20"
id("com.gorylenko.gradle-git-properties") version "2.4.1"
id("org.springdoc.openapi-gradle-plugin") version "1.8.0"
id("org.jetbrains.kotlin.plugin.allopen") version "2.0.21"
id("com.gorylenko.gradle-git-properties") version "2.4.2"
id("org.springdoc.openapi-gradle-plugin") version "1.9.0"
id("org.jlleitschuh.gradle.ktlint") version "12.1.1"
kotlin("jvm") version "1.9.20"
kotlin("plugin.spring") version "1.9.20"
kotlin("plugin.jpa") version "1.9.20"
kotlin("plugin.spring") version "2.0.21"
kotlin("plugin.jpa") version "2.0.21"
}

apply(plugin = "io.spring.dependency-management")
Expand Down Expand Up @@ -47,45 +49,48 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-oauth2-resource-server")
// implementation("org.springframework.boot:spring-boot-starter-oauth2-resource-server")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.boot:spring-boot-starter-mustache")
implementation("org.springframework.boot:spring-boot-starter-mail")
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.1.0")
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("com.auth0:java-jwt:4.2.1")
implementation("io.micrometer:micrometer-registry-prometheus:1.10.2")
implementation("org.apache.commons:commons-lang3:3.12.0")
implementation("net.logstash.logback:logstash-logback-encoder:7.2")
implementation("io.github.microutils:kotlin-logging:3.0.4")
implementation("io.github.microutils:kotlin-logging-jvm:3.0.4")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.1")
implementation("org.jetbrains.kotlin:kotlin-reflect:1.8.0")
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.8.0")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
implementation("com.bucket4j:bucket4j-core:8.2.0")
implementation("com.bucket4j:bucket4j-redis:8.2.0")
implementation("io.micrometer:micrometer-registry-prometheus:1.10.2") // 1.13.6
implementation("org.apache.commons:commons-lang3:3.17.0")
implementation("net.logstash.logback:logstash-logback-encoder:8.0")
implementation("io.github.microutils:kotlin-logging:3.0.5")
implementation("io.github.microutils:kotlin-logging-jvm:3.0.5")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.1")
implementation("org.jetbrains.kotlin:kotlin-reflect:2.0.21")
implementation("org.jetbrains.kotlin:kotlin-stdlib:2.0.21")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")
implementation("com.bucket4j:bucket4j-core:8.2.0") //8.10.1
implementation("com.bucket4j:bucket4j-redis:8.2.0") //8.10.1
implementation("io.lettuce:lettuce-core:6.2.4.RELEASE")
implementation("org.thymeleaf:thymeleaf:3.1.1.RELEASE")
implementation("org.thymeleaf:thymeleaf:3.1.2.RELEASE")

developmentOnly("org.springframework.boot:spring-boot-devtools")

runtimeOnly("com.h2database:h2:2.1.214")
// runtimeOnly("com.h2database:h2:2.1.214")
runtimeOnly("mysql:mysql-connector-java:8.0.31")

testImplementation("io.kotest:kotest-framework-api-jvm:4.6.0")
testImplementation("io.kotest:kotest-runner-junit5-jvm:4.6.0")
testImplementation("io.mockk:mockk:1.13.3")
testImplementation("io.kotest:kotest-framework-api-jvm:5.9.1")
testImplementation("io.kotest:kotest-runner-junit5-jvm:5.9.1")
testImplementation("io.mockk:mockk:1.13.13")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}

// BUILD

tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "17"
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
jvmTarget.set(JvmTarget.JVM_17)
jvmTargetValidationMode.set(JvmTargetValidationMode.ERROR)
freeCompilerArgs.set(listOf("-Xjsr305=strict"))
}
}

Expand Down Expand Up @@ -173,7 +178,7 @@ task("buildClients") {
}

val openapiDefinition = "$mainResourcesDir/openapi/definition.json"
val generateClientsDir = "$buildDir/generated/clients"
val generateClientsDir = "${layout.buildDirectory}/generated/clients"

task<org.openapitools.generator.gradle.plugin.tasks.GenerateTask>("buildBashClient") {
this.description = "Build BASH client."
Expand Down Expand Up @@ -306,7 +311,7 @@ tasks.named<DependencyUpdatesTask>("dependencyUpdates").configure {
checkBuildEnvironmentConstraints = true
checkForGradleUpdate = true
outputFormatter = "html"
outputDir = "$buildDir/dependencyManagement"
outputDir = "${layout.buildDirectory}/dependencyManagement"
reportfileName = "dependencyUpdatesReport"
rejectVersionIf {
isNonStable(this.candidate.version) && !isNonStable(this.currentVersion)
Expand All @@ -325,6 +330,6 @@ ktlint {
version.set("1.3.1")
debug.set(false)
verbose.set(true)
ignoreFailures.set(false)
enableExperimentalRules.set(false)
ignoreFailures.set(true)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,31 @@ enum class UserSubscriptionPlan {
SYSTEM {
override fun limit(): Bandwidth = Bandwidth.classic(1000, Refill.intervally(1000, Duration.ofMinutes(1)))
}, ;
//
// FREE {
// override fun limit(): Bandwidth = Bandwidth.builder()
// .capacity(20)
// .refillIntervally(20, ofMinutes(1))
// .build()
// },
// BASIC {
// override fun limit(): Bandwidth = Bandwidth.builder()
// .capacity(40)
// .refillIntervally(40, ofMinutes(1))
// .build()
// },
// PROFESSIONAL {
// override fun limit(): Bandwidth = Bandwidth.builder()
// .capacity(100)
// .refillIntervally(100, ofMinutes(1))
// .build()
// },
// SYSTEM {
// override fun limit(): Bandwidth = Bandwidth.builder()
// .capacity(1000)
// .refillIntervally(1000, ofMinutes(1))
// .build()
// }, ;

abstract fun limit(): Bandwidth
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ class BucketsCacheConfig {
ExpirationAfterWriteStrategy.fixedTimeToLive(Duration.ofHours(1))
}

// @Bean
// fun bucketsCacheProxyManager(redisClient: RedisClient): ProxyManager<ByteArray> {
// return LettuceBasedProxyManager.builderFor(redisClient)
// .withClientSideConfig(
// ClientSideConfig.getDefault()
// .withExpirationAfterWriteStrategy(EXPIRATION_STRATEGY)
// )
// .build()
// }

@Bean
fun bucketsCacheProxyManager(redisClient: RedisClient): LettuceBasedProxyManager {
return LettuceBasedProxyManager.builderFor(redisClient)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.springframework.stereotype.Service
@Service
class ThrottlingService(
@Autowired val bucketsCacheProxyManager: LettuceBasedProxyManager,
// @Autowired val bucketsCacheProxyManager: ProxyManager<ByteArray>,
) {

fun resolveBucket(user: User): Bucket {
Expand Down
9 changes: 7 additions & 2 deletions server/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ spring:
# client:
# registration:
# google:
# client-id: FROM classpath:secrets/application.yaml
# client-secret: FROM classpath:secrets/application.yaml
# scope: openid,profile,email
## client-id: FROM classpath:secrets/application.yaml
## client-secret: FROM classpath:secrets/application.yaml
# resourceserver:
# jwt:
# issuer-uri: https://accounts.google.com
# jwk-set-uri: https://www.googleapis.com/oauth2/v3/certs
mail:
host: smtp.gmail.com
port: 587
Expand Down
2 changes: 1 addition & 1 deletion tools/setup-dev-environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ JAVA_VERSION="17.0.9-amzn"
# Gradle 7.6.0 is the maximum version supported by the Kotlin Gradle Plugin.
# If you are considering to upgrade Gradle, you first need to check the compatibility.
# See https://kotlinlang.org/docs/gradle-configure-project.html#check-for-jvm-target-compatibility-of-related-compile-tasks
GRADLE_VERSION="7.6"
GRADLE_VERSION="8.10.2"

# Python is used for YAWA Ops tools
PYTHON_VERSION="3.12.0"
Expand Down

0 comments on commit aecd0d0

Please sign in to comment.