diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7d00a1afe2..6f5db6b67e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -396,4 +396,4 @@ jobs: key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} - name: Run ktlint - run: ./gradlew ktlint + run: ./gradlew ktlintCheck diff --git a/.gitignore b/.gitignore index 06b3b5cf28..52dd7d7cb7 100644 --- a/.gitignore +++ b/.gitignore @@ -62,4 +62,5 @@ backend/app/src/main/resources/application-js-e2e.properties /backend/*/build /backend/*/out - +/ee/backend/*/build +/ee/backend/*/out diff --git a/backend/api/build.gradle b/backend/api/build.gradle index 575f1e7cd7..031e98f966 100644 --- a/backend/api/build.gradle +++ b/backend/api/build.gradle @@ -2,34 +2,21 @@ * Copyright (c) 2020. Tolgee */ -buildscript { - repositories { - mavenCentral() - } -} - plugins { - id 'java' - id 'io.spring.dependency-management' - id 'org.jetbrains.kotlin.jvm' - id 'org.springframework.boot' - id "kotlin-allopen" - + id 'io.tolgee.gradle.base' + id 'io.tolgee.gradle.kotlin' + id 'io.tolgee.gradle.spring' } group = 'io.tolgee' apply plugin: 'java' apply plugin: 'idea' -apply plugin: "org.jetbrains.kotlin.plugin.spring" +apply plugin: 'org.jetbrains.kotlin.plugin.spring' apply plugin: 'org.springframework.boot' -apply plugin: "kotlin-allopen" +apply plugin: 'org.jetbrains.kotlin.plugin.allopen' apply plugin: 'io.spring.dependency-management' -repositories { - mavenCentral() -} - kotlin { jvmToolchain(11) } @@ -41,10 +28,10 @@ allOpen { dependencies { implementation libs.kotlinCoroutines - implementation "org.springframework.boot:spring-boot-starter-hateoas" + implementation 'org.springframework.boot:spring-boot-starter-hateoas' implementation 'org.springframework.boot:spring-boot-starter-web' - implementation("org.springframework.boot:spring-boot-starter-security") - implementation "org.springframework.boot:spring-boot-starter-websocket" + implementation 'org.springframework.boot:spring-boot-starter-security' + implementation 'org.springframework.boot:spring-boot-starter-websocket' implementation(project(':data')) implementation(project(':misc')) @@ -71,7 +58,7 @@ dependencies { implementation libs.jjwtApi implementation libs.jjwtImpl implementation libs.jjwtJackson - implementation("com.github.ben-manes.caffeine:caffeine:3.0.5") + implementation libs.caffeineCaching api libs.postHog } diff --git a/backend/app/build.gradle b/backend/app/build.gradle index 9539aac0ad..16aa42fa98 100644 --- a/backend/app/build.gradle +++ b/backend/app/build.gradle @@ -2,30 +2,15 @@ * Copyright (c) 2020. Tolgee */ -buildscript { - repositories { - mavenCentral() - } -} - plugins { - id 'io.spring.dependency-management' - id 'org.springframework.boot' - id 'java' - id 'org.jetbrains.kotlin.jvm' - id "kotlin-jpa" - id "org.jetbrains.kotlin.kapt" - id "kotlin-allopen" + id 'io.tolgee.gradle.base' + id 'io.tolgee.gradle.kotlin' + id 'io.tolgee.gradle.spring' + id 'io.tolgee.gradle.hibernate' } group = 'io.tolgee' -if (System.getenv().containsKey("VERSION")) { - project.version = System.getenv().get("VERSION") -} else { - project.version = 'local' -} - configurations { developmentOnly runtimeClasspath { @@ -38,14 +23,9 @@ apply plugin: 'idea' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' apply plugin: "org.jetbrains.kotlin.plugin.jpa" -apply plugin: "kotlin-allopen" +apply plugin: "org.jetbrains.kotlin.plugin.allopen" apply plugin: "org.jetbrains.kotlin.plugin.spring" -repositories { - mavenCentral() -} - - allOpen { annotation("javax.persistence.Entity") annotation("javax.persistence.MappedSuperclass") @@ -91,9 +71,9 @@ dependencies { implementation libs.springmockk implementation libs.jsonUnitAssert testImplementation libs.mockito - testImplementation("io.findify:s3mock_2.13:0.2.6") - testImplementation("io.socket:socket.io-client:1.0.1") - testImplementation group: 'org.springframework.batch', name: 'spring-batch-test', version: '4.3.5' + testImplementation libs.amazonS3Mock + testImplementation libs.socketIoClient + testImplementation 'org.springframework.batch:spring-batch-test' testImplementation libs.sendInBlue testImplementation "org.springframework.boot:spring-boot-starter-websocket" diff --git a/backend/app/src/test/resources/application.yaml b/backend/app/src/test/resources/application.yaml index d65b78ee82..ba5fb55614 100644 --- a/backend/app/src/test/resources/application.yaml +++ b/backend/app/src/test/resources/application.yaml @@ -1,3 +1,5 @@ +#debug: true + spring: autoconfigure: exclude: diff --git a/backend/data/build.gradle b/backend/data/build.gradle index 2e142269a5..f4050cc5da 100644 --- a/backend/data/build.gradle +++ b/backend/data/build.gradle @@ -2,34 +2,16 @@ * Copyright (c) 2020. Tolgee */ -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath "org.hibernate:hibernate-gradle-plugin:5.6.10.Final" - } -} - plugins { - id 'io.spring.dependency-management' - id 'org.springframework.boot' - id 'java' - id 'org.liquibase.gradle' - id 'org.jetbrains.kotlin.jvm' - id "kotlin-jpa" - id "org.jetbrains.kotlin.kapt" - id "kotlin-allopen" + id 'io.tolgee.gradle.base' + id 'io.tolgee.gradle.kotlin' + id 'io.tolgee.gradle.spring' + id 'io.tolgee.gradle.hibernate' + id 'io.tolgee.gradle.liquibase' } group = 'io.tolgee' -if (System.getenv().containsKey("VERSION")) { - project.version = System.getenv().get("VERSION") -} else { - project.version = 'local' -} - configurations { developmentOnly runtimeClasspath { @@ -45,16 +27,11 @@ apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' apply plugin: "org.jetbrains.kotlin.plugin.jpa" apply plugin: "org.jetbrains.kotlin.plugin.spring" -apply plugin: "kotlin-allopen" -apply plugin: "kotlin-kapt" +apply plugin: "org.jetbrains.kotlin.plugin.allopen" +apply plugin: "org.jetbrains.kotlin.kapt" apply plugin: 'kotlin' apply plugin: 'org.hibernate.orm' -repositories { - mavenCentral() - jcenter() -} - idea { module { generatedSourceDirs += files('build/generated/source/kapt/main', 'build/generated/source/kaptKotlin/main') @@ -80,9 +57,7 @@ allOpen { annotation("org.springframework.beans.factory.annotation.Configurable") } -apply from: "$rootDir/gradle/liquibase.gradle" - -configureLiquibase("public", "hibernate:spring:io.tolgee", 'src/main/resources/db/changelog/schema.xml') +//configureLiquibase("public", "hibernate:spring:io.tolgee", 'src/main/resources/db/changelog/schema.xml') diff.dependsOn compileKotlin diffChangeLog.dependsOn compileKotlin @@ -130,7 +105,7 @@ dependencies { implementation libs.liquibaseCore liquibaseRuntime libs.liquibaseCore liquibaseRuntime 'org.postgresql:postgresql' - liquibaseRuntime('org.liquibase:liquibase-groovy-dsl:3.0.2') + liquibaseRuntime libs.liquibaseGroovyDsl liquibaseRuntime libs.liquibaseHibernate liquibaseRuntime libs.kotlinReflect liquibaseRuntime sourceSets.main.output @@ -162,19 +137,19 @@ dependencies { * MISC */ implementation libs.commonsCodec - implementation group: 'org.apache.commons', name: 'commons-text', version: '1.9' + implementation libs.commonsText implementation libs.icu4j implementation libs.jjwtApi implementation libs.jjwtImpl implementation libs.jjwtJackson implementation libs.jacksonModuleKotlin - implementation 'net.datafaker:datafaker:1.5.0' - implementation 'jaxen:jaxen:1.2.0' + implementation libs.datafaker + implementation libs.jaxen implementation libs.sendInBlue implementation libs.sentry implementation libs.hibernateTypes liquibaseRuntime libs.hibernateTypes - implementation 'com.eatthepath:java-otp:0.4.0' + implementation libs.otp implementation libs.postHog implementation libs.micrometerPrometheus diff --git a/backend/development/build.gradle b/backend/development/build.gradle index 572dbc7827..c6cf8f3671 100644 --- a/backend/development/build.gradle +++ b/backend/development/build.gradle @@ -2,20 +2,11 @@ * Copyright (c) 2020. Tolgee */ -buildscript { - repositories { - mavenCentral() - } -} - plugins { - id 'io.spring.dependency-management' - id 'org.springframework.boot' - id 'java' - id 'org.jetbrains.kotlin.jvm' - id "kotlin-jpa" - id "org.jetbrains.kotlin.kapt" - id "kotlin-allopen" + id 'io.tolgee.gradle.base' + id 'io.tolgee.gradle.kotlin' + id 'io.tolgee.gradle.spring' + id 'io.tolgee.gradle.hibernate' } group = 'io.tolgee' @@ -33,12 +24,8 @@ apply plugin: 'idea' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' apply plugin: "org.jetbrains.kotlin.plugin.jpa" -apply plugin: "kotlin-allopen" -apply plugin: "kotlin-kapt" - -repositories { - mavenCentral() -} +apply plugin: "org.jetbrains.kotlin.plugin.allopen" +apply plugin: "org.jetbrains.kotlin.kapt" kotlin { jvmToolchain(11) diff --git a/backend/misc/build.gradle b/backend/misc/build.gradle index ffe1bd6e5c..5c588b8520 100644 --- a/backend/misc/build.gradle +++ b/backend/misc/build.gradle @@ -2,15 +2,9 @@ * Copyright (c) 2020. Tolgee */ -buildscript { - repositories { - mavenCentral() - } -} - plugins { - id 'java' - id 'org.jetbrains.kotlin.jvm' + id 'io.tolgee.gradle.base' + id 'io.tolgee.gradle.kotlin' } group = 'io.tolgee' @@ -18,10 +12,6 @@ group = 'io.tolgee' apply plugin: 'java' apply plugin: 'idea' -repositories { - mavenCentral() -} - kotlin { jvmToolchain(11) } diff --git a/backend/testing/build.gradle b/backend/testing/build.gradle index 5081f578dd..4a27beb378 100644 --- a/backend/testing/build.gradle +++ b/backend/testing/build.gradle @@ -2,30 +2,15 @@ * Copyright (c) 2020. Tolgee */ -buildscript { - repositories { - mavenCentral() - } -} - plugins { - id 'io.spring.dependency-management' - id 'org.springframework.boot' - id 'java' - id 'org.jetbrains.kotlin.jvm' - id "kotlin-jpa" - id "org.jetbrains.kotlin.kapt" - id "kotlin-allopen" + id 'io.tolgee.gradle.base' + id 'io.tolgee.gradle.kotlin' + id 'io.tolgee.gradle.spring' + id 'io.tolgee.gradle.hibernate' } group = 'io.tolgee' -if (System.getenv().containsKey("VERSION")) { - project.version = System.getenv().get("VERSION") -} else { - project.version = 'local' -} - configurations { developmentOnly runtimeClasspath { @@ -39,13 +24,8 @@ apply plugin: 'idea' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' apply plugin: "org.jetbrains.kotlin.plugin.jpa" -apply plugin: "kotlin-allopen" -apply plugin: "kotlin-kapt" - -repositories { - mavenCentral() - jcenter() -} +apply plugin: "org.jetbrains.kotlin.plugin.allopen" +apply plugin: "org.jetbrains.kotlin.kapt" kotlin { jvmToolchain(11) diff --git a/build.gradle b/build.gradle index 1a99e233cd..ea304c7a0a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,45 +1,19 @@ /* * Copyright (c) 2020. Tolgee */ -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath libs.kotlin - } + +plugins { + id 'io.tolgee.gradle.base' } project.ext { dbSchemaContainerName = 'tolgee_postgres_dbschema' } -if (System.getenv().containsKey("VERSION")) { - project.version = System.getenv().get("VERSION") -} else { - project.version = 'local' -} - -configurations { - ktlint -} - apply plugin: 'idea' -repositories { - mavenCentral() -} - def unpackTarget = "${project.buildDir}/dependency" -dependencies { - ktlint("com.pinterest:ktlint:0.43.2") { - attributes { - attribute(Bundling.BUNDLING_ATTRIBUTE, getObjects().named(Bundling, Bundling.EXTERNAL)) - } - } -} - project(':server-app').afterEvaluate { task unpack(type: Copy) { from(zipTree(project(':server-app').tasks.findByName("bootJar").outputs.files.singleFile)) @@ -80,7 +54,7 @@ project(':server-app').afterEvaluate { task check { dependsOn project(':server-app').tasks.findByName("check") - dependsOn ktlint + dependsOn project(':server-app').tasks.findByName("ktlintCheck") } task bootJar { @@ -131,22 +105,8 @@ project(':server-app').afterEvaluate { } } -task ktlint(type: JavaExec, group: "verification") { - description = "Check Kotlin code style." - classpath = configurations.ktlint - main = "com.pinterest.ktlint.Main" - args "**/*.kt", "!**/data/PluralData.kt", '../billing/**/*.kt' -} - -task ktlintFormat(type: JavaExec, group: "formatting") { - description = "Fix Kotlin code style deviations." - classpath = configurations.ktlint - main = "com.pinterest.ktlint.Main" - args "-F", "**/*.kt", "!**/data/PluralData.kt", '../billing/**/*.kt' - jvmArgs = ["--add-opens=java.base/java.lang=ALL-UNNAMED"] -} - subprojects { task allDeps(type: DependencyReportTask) {} } +gradle.addListener new io.tolgee.gradle.TimingsListener() diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000000..e27e190716 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,25 @@ +plugins { + java + `kotlin-dsl` +} + +repositories { + gradlePluginPortal() + mavenCentral() +// maven { url 'https://repo.spring.io/release' } +} + +dependencies { + implementation(buildLibs.kotlin) + implementation(buildLibs.kotlinAllOpen) + implementation(buildLibs.kotlinLint) + implementation(buildLibs.kotlinJpa) + implementation(buildLibs.springBoot) + implementation(buildLibs.springDependencyManagement) + implementation(buildLibs.liquibase) + implementation(buildLibs.hibernate) + + // small hack from https://github.com/gradle/gradle/issues/15383#issuecomment-779893192 to access these catalogs in precompiled script plugins + implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) + implementation(files(buildLibs.javaClass.superclass.protectionDomain.codeSource.location)) +} diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts new file mode 100644 index 0000000000..5bb841fa95 --- /dev/null +++ b/buildSrc/settings.gradle.kts @@ -0,0 +1,12 @@ +rootProject.name = "buildSrc" + +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + from(files("../versions.libs.toml")) + } + create("buildLibs") { + from(files("../versions.build.toml")) + } + } +} diff --git a/buildSrc/src/main/kotlin/io/tolgee/gradle/TimingsListener.kt b/buildSrc/src/main/kotlin/io/tolgee/gradle/TimingsListener.kt new file mode 100644 index 0000000000..81319f3bb8 --- /dev/null +++ b/buildSrc/src/main/kotlin/io/tolgee/gradle/TimingsListener.kt @@ -0,0 +1,51 @@ +@file:Suppress("DEPRECATION") + +package io.tolgee.gradle + +import org.gradle.BuildListener +import org.gradle.BuildResult +import org.gradle.api.Task +import org.gradle.api.execution.TaskExecutionListener +import org.gradle.api.initialization.Settings +import org.gradle.api.invocation.Gradle +import org.gradle.api.tasks.TaskState +import java.time.LocalTime +import java.util.concurrent.TimeUnit + +class TimingsListener : TaskExecutionListener, BuildListener { + var startTime: Long = 0 + var timings = mutableListOf() + + override fun beforeExecute(task: Task) { + startTime = System.nanoTime() + } + + override fun afterExecute(task: Task, state: TaskState) { + val ms = TimeUnit.MILLISECONDS.convert(System.nanoTime() - startTime, TimeUnit.NANOSECONDS); + timings += TimingEntry(ms, task.path) + + val now = LocalTime.now() + task.project.logger.warn("$now ${task.path} took ${ms}ms") + } + + override fun buildFinished(result: BuildResult) { + println("Task timings:") + for (timing in timings) { + if (timing.ms >= 50L) { + println(String.format("%dms %s", timing.ms, timing.task)) + } + } + } + + override fun settingsEvaluated(settings: Settings) { + } + + override fun projectsLoaded(gradle: Gradle) { + } + + override fun projectsEvaluated(gradle: Gradle) { + } + + data class TimingEntry(val ms: Long, val task: String) + +} diff --git a/buildSrc/src/main/kotlin/io/tolgee/gradle/base.gradle.kts b/buildSrc/src/main/kotlin/io/tolgee/gradle/base.gradle.kts new file mode 100644 index 0000000000..0dd603dc5b --- /dev/null +++ b/buildSrc/src/main/kotlin/io/tolgee/gradle/base.gradle.kts @@ -0,0 +1,21 @@ +package io.tolgee.gradle + +import org.apache.tools.ant.taskdefs.condition.Os + +plugins { + idea + eclipse +} + +repositories { + mavenCentral() + maven(url = "https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven") +} + +if (System.getenv().containsKey("VERSION")) { + project.version = System.getenv().get("VERSION") as String +} else { + project.version = "local" +} + +val npmCommandName by extra(if (Os.isFamily(Os.FAMILY_WINDOWS)) "npm.cmd" else "npm") diff --git a/buildSrc/src/main/kotlin/io/tolgee/gradle/hibernate.gradle.kts b/buildSrc/src/main/kotlin/io/tolgee/gradle/hibernate.gradle.kts new file mode 100644 index 0000000000..72512e15f8 --- /dev/null +++ b/buildSrc/src/main/kotlin/io/tolgee/gradle/hibernate.gradle.kts @@ -0,0 +1,6 @@ +package io.tolgee.gradle + +plugins { + id("org.jetbrains.kotlin.plugin.jpa") + id("org.hibernate.orm") +} diff --git a/buildSrc/src/main/kotlin/io/tolgee/gradle/kotlin.gradle.kts b/buildSrc/src/main/kotlin/io/tolgee/gradle/kotlin.gradle.kts new file mode 100644 index 0000000000..7e232048ed --- /dev/null +++ b/buildSrc/src/main/kotlin/io/tolgee/gradle/kotlin.gradle.kts @@ -0,0 +1,47 @@ +package io.tolgee.gradle + +import org.gradle.kotlin.dsl.kotlin + +plugins { + java + kotlin("jvm") + id("org.jetbrains.kotlin.kapt") + id("org.jetbrains.kotlin.plugin.allopen") + id("org.jlleitschuh.gradle.ktlint") +} + +kotlin { + jvmToolchain(11) +} + +ktlint { + version.set("0.43.2") + debug.set(false) + verbose.set(true) + filter { + exclude("**/generated/**") + exclude("**/data/PluralData.kt") + include("**/kotlin/**") + } +} + +//ktlint { +// attributes { +// attribute(Bundling.BUNDLING_ATTRIBUTE, getObjects().named(Bundling, Bundling.EXTERNAL)) +// } +//} + +//task ktlint(type: JavaExec, group: "verification") { +// description = "Check Kotlin code style." +// classpath = buildLibs.kotlinLint +// mainClass = "com.pinterest.ktlint.Main" +// args "**/*.kt", "!**/data/PluralData.kt", '../billing/**/*.kt' +//} +// +//task ktlintFormat(type: JavaExec, group: "formatting") { +// description = "Fix Kotlin code style deviations." +// classpath = buildLibs.kotlinLint +// mainClass = "com.pinterest.ktlint.Main" +// args "-F", "**/*.kt", "!**/data/PluralData.kt", '../billing/**/*.kt' +// jvmArgs = ["--add-opens=java.base/java.lang=ALL-UNNAMED"] +//} diff --git a/buildSrc/src/main/kotlin/io/tolgee/gradle/liquibase.gradle.kts b/buildSrc/src/main/kotlin/io/tolgee/gradle/liquibase.gradle.kts new file mode 100644 index 0000000000..e61e66faac --- /dev/null +++ b/buildSrc/src/main/kotlin/io/tolgee/gradle/liquibase.gradle.kts @@ -0,0 +1,38 @@ +package io.tolgee.gradle + +plugins { + id("org.liquibase.gradle") +} + +project.extensions.add("configureLiquibase", { schema: String, referenceUrlPrefix: String, changeLogPah: String -> + configure { + activities.register("main") { + this.arguments = mapOf( + "changeLogFile" to changeLogPah, + "url" to "jdbc:postgresql://localhost:55432/postgres?currentSchema=$schema", + "referenceUrl" to referenceUrlPrefix + + "?dialect=io.tolgee.dialects.postgres.CustomPostgreSQLDialect" + + "&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy" + + "&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy", + "username" to "postgres", + "password" to "postgres", + "driver" to "org.postgresql.Driver", + "excludeObjects" to "table:batch_job_execution_context," + + "batch_step_execution_seq," + + "batch_job_seq," + + "batch_job_execution_seq," + + "batch_step_execution_context," + + "batch_step_execution," + + "batch_job_instance," + + "table:batch_job_execution," + + "table:batch_job_execution_params," + + "hibernate_sequence," + + "revision_sequence_generator," + + "billing_sequence," + + "activity_sequence," + + "FK9xs5a07fba5yqje5jqm6qrehs," + + "column:textsearchable_.*" + ) + } + } +}) diff --git a/buildSrc/src/main/kotlin/io/tolgee/gradle/spring.gradle.kts b/buildSrc/src/main/kotlin/io/tolgee/gradle/spring.gradle.kts new file mode 100644 index 0000000000..b4c581a9d8 --- /dev/null +++ b/buildSrc/src/main/kotlin/io/tolgee/gradle/spring.gradle.kts @@ -0,0 +1,7 @@ +package io.tolgee.gradle + +plugins { + id("io.spring.dependency-management") + id("org.springframework.boot") + id("org.jetbrains.kotlin.plugin.spring") +} diff --git a/ee/backend/app/build.gradle b/ee/backend/app/build.gradle index c11f4dc375..2f83f339e8 100644 --- a/ee/backend/app/build.gradle +++ b/ee/backend/app/build.gradle @@ -1,22 +1,13 @@ -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath "org.hibernate:hibernate-gradle-plugin:5.6.10.Final" - } -} plugins { - id 'io.spring.dependency-management' - id 'org.jetbrains.kotlin.jvm' - id 'org.liquibase.gradle' - id 'org.springframework.boot' - id "java" - id "kotlin-allopen" + id 'io.tolgee.gradle.base' + id 'io.tolgee.gradle.kotlin' + id 'io.tolgee.gradle.spring' + id 'io.tolgee.gradle.hibernate' + id 'io.tolgee.gradle.liquibase' } -apply plugin: "kotlin-allopen" +apply plugin: "org.jetbrains.kotlin.plugin.allopen" apply plugin: "org.jetbrains.kotlin.plugin.spring" apply plugin: 'org.hibernate.orm' @@ -31,17 +22,12 @@ allOpen { annotation("org.springframework.boot.test.context.SpringBootTest") } -repositories { - mavenCentral() -} - test { useJUnitPlatform() maxHeapSize = "2048m" } -apply from: "$rootDir/gradle/liquibase.gradle" -configureLiquibase("ee", "hibernate:spring:io.tolgee.ee.model", 'src/main/resources/db/changelog/ee-schema.xml') +//configureLiquibase("ee", "hibernate:spring:io.tolgee.ee.model", 'src/main/resources/db/changelog/ee-schema.xml') diff.dependsOn compileKotlin diffChangeLog.dependsOn compileKotlin @@ -71,7 +57,7 @@ dependencies { implementation libs.liquibaseCore liquibaseRuntime libs.liquibaseCore liquibaseRuntime 'org.postgresql:postgresql' - liquibaseRuntime('org.liquibase:liquibase-groovy-dsl:3.0.2') + liquibaseRuntime libs.liquibaseGroovyDsl liquibaseRuntime libs.liquibaseHibernate liquibaseRuntime libs.kotlinReflect liquibaseRuntime(project(":data")) diff --git a/ee/backend/tests/build.gradle b/ee/backend/tests/build.gradle index 878da9948a..dbbe0c56b4 100644 --- a/ee/backend/tests/build.gradle +++ b/ee/backend/tests/build.gradle @@ -1,20 +1,12 @@ -buildscript { - repositories { - mavenCentral() - } - dependencies { - } -} plugins { - id 'io.spring.dependency-management' - id 'org.jetbrains.kotlin.jvm' - id 'org.springframework.boot' - id "java" - id "kotlin-allopen" + id 'io.tolgee.gradle.base' + id 'io.tolgee.gradle.kotlin' + id 'io.tolgee.gradle.spring' + id 'io.tolgee.gradle.hibernate' } -apply plugin: "kotlin-allopen" +apply plugin: "org.jetbrains.kotlin.plugin.allopen" apply plugin: "org.jetbrains.kotlin.plugin.spring" allOpen { @@ -27,10 +19,6 @@ allOpen { annotation("org.springframework.boot.test.context.SpringBootTest") } -repositories { - mavenCentral() -} - test { useJUnitPlatform() maxHeapSize = "2048m" diff --git a/gradle.properties b/gradle.properties index 9d14e71e93..4666b28e14 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,6 @@ -kotlinVersion=1.9.10 -springBootVersion=2.7.13 -springDocVersion=1.7.0 -jjwtVersion=0.11.2 -amazonAwsSdkVersion=2.20.8 -springDependencyManagementVersion=1.0.11.RELEASE org.gradle.jvmargs=-Xmx8g -Dkotlin.daemon.jvm.options=-Xmx6g org.gradle.parallel=true +kapt.verbose=true +kapt.include.compile.classpath=false +kapt.incremental.apt=true +kapt.use.worker.api=true diff --git a/gradle/e2e.gradle b/gradle/e2e.gradle index e8c9a973b5..f0c7e3403d 100644 --- a/gradle/e2e.gradle +++ b/gradle/e2e.gradle @@ -1,15 +1,13 @@ -apply from: './gradle/utils.gradle' import groovy.io.FileType import java.time.Duration ext { - E2E_DIR = "${project.projectDir}/e2e" - BILLING_E2E_DIR = "${project.projectDir}/../billing/e2e" - WEBAPP_DIR = "${project.projectDir}/webapp" + E2E_DIR = "${project.rootDir}/e2e" + BILLING_E2E_DIR = "${project.rootDir}/../billing/e2e" + WEBAPP_DIR = "${project.rootDir}/webapp" } - def getE2eTestsToRun() { def totalJobs = System.getenv("E2E_TOTAL_JOBS") def jobIndex = System.getenv("E2E_JOB_INDEX") diff --git a/gradle/liquibase.gradle b/gradle/liquibase.gradle deleted file mode 100644 index 9451fb81d5..0000000000 --- a/gradle/liquibase.gradle +++ /dev/null @@ -1,43 +0,0 @@ -ext { - configureLiquibase = { schema, referenceUrlPrefix, changeLogPah -> - def liveDb = [ - url : "jdbc:postgresql://localhost:55432/postgres?currentSchema=$schema", - referenceUrl: referenceUrlPrefix + - '?dialect=io.tolgee.dialects.postgres.CustomPostgreSQLDialect' + - '&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy' + - '&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy', - username : 'postgres', - password : 'postgres', - driver : "org.postgresql.Driver" - ] - - liquibase { - activities { - //noinspection GroovyAssignabilityCheck - main { - changeLogFile changeLogPah - url liveDb.url - referenceUrl liveDb.referenceUrl - username liveDb.username - password liveDb.password - driver liveDb.driver - excludeObjects "table:batch_job_execution_context," + - "batch_step_execution_seq," + - "batch_job_seq," + - "batch_job_execution_seq," + - "batch_step_execution_context," + - "batch_step_execution," + - "batch_job_instance," + - "table:batch_job_execution," + - "table:batch_job_execution_params," + - "hibernate_sequence," + - "revision_sequence_generator," + - "billing_sequence," + - "activity_sequence," + - "FK9xs5a07fba5yqje5jqm6qrehs,"+ - "column:textsearchable_.*" - } - } - } - } -} diff --git a/gradle/utils.gradle b/gradle/utils.gradle deleted file mode 100644 index 5140ecc781..0000000000 --- a/gradle/utils.gradle +++ /dev/null @@ -1,7 +0,0 @@ -ext { - if (System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("windows")) { - npmCommandName = "npm.cmd" - } else { - npmCommandName = "npm" - } -} diff --git a/gradle/webapp.gradle b/gradle/webapp.gradle index 365349e051..35bbd6b709 100644 --- a/gradle/webapp.gradle +++ b/gradle/webapp.gradle @@ -1,10 +1,8 @@ -apply from: './gradle/utils.gradle' - -def webappPath = "${project.projectDir}/webapp" +def webappPath = "${project.rootDir}/webapp" task copyDist(type: Copy) { def fromDir = "${webappPath}/build" - def toDir = "${project.projectDir}/build/dependency/BOOT-INF/classes/static/." + def toDir = "${project.rootDir}/build/dependency/BOOT-INF/classes/static/." from fromDir into toDir inputs.dir(fromDir) @@ -17,17 +15,17 @@ task installWebappDeps(type: Exec) { onlyIf { System.getenv("SKIP_WEBAPP_BUILD") != "true" } commandLine npmCommandName, "ci" workingDir = webappPath - inputs.file("${project.projectDir}/webapp/package.json") - inputs.file("${project.projectDir}/webapp/package-lock.json") - outputs.dir("${project.projectDir}/webapp/node_modules") + inputs.file("${webappPath}/package.json") + inputs.file("${webappPath}/package-lock.json") + outputs.dir("${webappPath}/node_modules") } task buildWebapp(type: Exec) { onlyIf { System.getenv("SKIP_WEBAPP_BUILD") != "true" } commandLine npmCommandName, "run", "build" workingDir = webappPath - inputs.dir("${project.projectDir}/webapp/") - outputs.dir("${project.projectDir}/webapp/build/") + inputs.dir("${webappPath}/") + outputs.dir("${webappPath}/build/") dependsOn "installWebappDeps", "updateStaticTranslations" } diff --git a/settings.gradle b/settings.gradle index 2b2e6a6854..4d883980e5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,64 +1,10 @@ -pluginManagement { - resolutionStrategy { - eachPlugin { - if (requested.id.id == 'io.spring.dependency-management') { - useModule("io.spring.gradle:dependency-management-plugin:$springDependencyManagementVersion") - } - - if (requested.id.id == 'org.springframework.boot') { - useModule("org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion") - } - - if (requested.id.id == 'kotlin-allopen') { - useModule("org.jetbrains.kotlin:kotlin-allopen:$kotlinVersion") - } - - if (requested.id.id == 'kotlin-jpa') { - useModule("org.jetbrains.kotlin.plugin.jpa:org.jetbrains.kotlin.plugin.jpa.gradle.plugin:$kotlinVersion") - } - - if (requested.id.id == 'org.liquibase.gradle') { - useModule('org.liquibase.gradle:org.liquibase.gradle.gradle.plugin:2.1.1') - } - } - } -} - dependencyResolutionManagement { versionCatalogs { - libs { - library('stripe', 'com.stripe', 'stripe-java').version('22.11.0') - library('sendInBlue', 'com.sendinblue', 'sib-api-v3-sdk').version('5.3.0') - library('jacksonModuleKotlin', 'com.fasterxml.jackson.module', 'jackson-module-kotlin').version('2.12.4') - library('kotlin', 'org.jetbrains.kotlin', 'kotlin-gradle-plugin').version(kotlinVersion) - library('kotlinReflect', 'org.jetbrains.kotlin', 'kotlin-reflect').version(kotlinVersion) - library('kotlinCoroutines', 'org.jetbrains.kotlinx', 'kotlinx-coroutines-core').version('1.6.1') - library('springDocOpenApiWebMvcCore', 'org.springdoc', 'springdoc-openapi-webmvc-core').version(springDocVersion) - library('springDocOpenApiUi', 'org.springdoc', 'springdoc-openapi-ui').version(springDocVersion) - library('springDocOpenApiKotlin', 'org.springdoc', 'springdoc-openapi-kotlin').version(springDocVersion) - library('springDocOpenApiDataRest', 'org.springdoc', 'springdoc-openapi-data-rest').version(springDocVersion) - library('springDocOpenApiHateoas', 'org.springdoc', 'springdoc-openapi-hateoas').version(springDocVersion) - library('jjwtApi', 'io.jsonwebtoken', 'jjwt-api').version(jjwtVersion) - library('jjwtImpl', 'io.jsonwebtoken', 'jjwt-impl').version(jjwtVersion) - library('jjwtJackson', 'io.jsonwebtoken', 'jjwt-jackson').version(jjwtVersion) - library('assertJCore', 'org.assertj:assertj-core:3.19.0') - library('springmockk', 'com.ninja-squad:springmockk:3.0.1') - library('mockito', 'org.mockito.kotlin:mockito-kotlin:5.0.0') - library('commonsCodec', 'commons-codec:commons-codec:1.15') - library('icu4j', 'com.ibm.icu:icu4j:69.1') - library('jsonUnitAssert', 'net.javacrumbs.json-unit:json-unit-assertj:2.28.0') - library('amazonS3', "software.amazon.awssdk:s3:$amazonAwsSdkVersion") - library('amazonSTS', "software.amazon.awssdk:sts:$amazonAwsSdkVersion") - library('amazonTranslate', "software.amazon.awssdk:translate:$amazonAwsSdkVersion") - library('googleCloud', "com.google.cloud:libraries-bom:24.0.0") - library('sentry', "io.sentry:sentry-spring-boot-starter:5.7.3") - library('liquibaseCore', "org.liquibase:liquibase-core:4.9.1") - library('liquibaseHibernate', "org.liquibase.ext:liquibase-hibernate5:4.9.1") - library('hibernateTypes', "com.vladmihalcea:hibernate-types-55:2.14.1") - library('redissonSpringBootStarter', "org.redisson:redisson-spring-boot-starter:3.23.2") - library('redissonSpringData', 'org.redisson:redisson-spring-data-27:3.23.2') - library('postHog', 'com.posthog.java:posthog:1.1.0') - library('micrometerPrometheus', "io.micrometer:micrometer-registry-prometheus:1.9.12") + create("libs") { + from(files("versions.libs.toml")) + } + create("buildLibs") { + from(files("versions.build.toml")) } } } diff --git a/versions.build.toml b/versions.build.toml new file mode 100644 index 0000000000..7748155651 --- /dev/null +++ b/versions.build.toml @@ -0,0 +1,16 @@ +[versions] +kotlin = "1.9.10" +ktlint = "11.5.1" +springBoot = "2.7.13" +springDependencyManagement = "1.0.11.RELEASE" +liquibase = "2.1.1" + +[libraries] +kotlin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } +kotlinAllOpen = { group = "org.jetbrains.kotlin", name = "kotlin-allopen", version.ref = "kotlin" } +kotlinJpa = { group = "org.jetbrains.kotlin", name = "kotlin-noarg", version.ref = "kotlin" } +kotlinLint = { group = "org.jlleitschuh.gradle", name = "ktlint-gradle", version.ref = "ktlint" } +springBoot = { group = "org.springframework.boot", name = "spring-boot-gradle-plugin", version.ref = "springBoot" } +springDependencyManagement = { group = "io.spring.gradle", name = "dependency-management-plugin", version.ref = "springDependencyManagement" } +liquibase = { group = "org.liquibase", name = "liquibase-gradle-plugin", version.ref = "liquibase" } +hibernate = { group = "org.hibernate", name = "hibernate-gradle-plugin", version = "5.6.10.Final" } diff --git a/versions.libs.toml b/versions.libs.toml new file mode 100644 index 0000000000..96145f33e0 --- /dev/null +++ b/versions.libs.toml @@ -0,0 +1,47 @@ +[versions] +kotlin = "1.9.10" +springBoot = "2.7.13" +springDoc = "1.7.0" +jjwt = "0.11.2" +amazonAwsSdk = "2.20.8" + +[libraries] +stripe = { group = "com.stripe", name = "stripe-java", version = "22.11.0" } +sendInBlue = { group = "com.sendinblue", name = "sib-api-v3-sdk", version = "5.3.0" } +jacksonModuleKotlin = { group = "com.fasterxml.jackson.module", name = "jackson-module-kotlin", version = "2.12.4" } +kotlinReflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version.ref = "kotlin" } +kotlinCoroutines = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version = "1.6.1" } +springDocOpenApiWebMvcCore = { group = "org.springdoc", name = "springdoc-openapi-webmvc-core", version.ref = "springDoc" } +springDocOpenApiUi = { group = "org.springdoc", name = "springdoc-openapi-ui", version.ref = "springDoc" } +springDocOpenApiKotlin = { group = "org.springdoc", name = "springdoc-openapi-kotlin", version.ref = "springDoc" } +springDocOpenApiDataRest = { group = "org.springdoc", name = "springdoc-openapi-data-rest", version.ref = "springDoc" } +springDocOpenApiHateoas = { group = "org.springdoc", name = "springdoc-openapi-hateoas", version.ref = "springDoc" } +jjwtApi = { group = "io.jsonwebtoken", name = "jjwt-api", version.ref = "jjwt" } +jjwtImpl = { group = "io.jsonwebtoken", name = "jjwt-impl", version.ref = "jjwt" } +jjwtJackson = { group = "io.jsonwebtoken", name = "jjwt-jackson", version.ref = "jjwt" } +assertJCore = { group = "org.assertj", name = "assertj-core", version = "3.19.0" } +springmockk = { group = "com.ninja-squad", name = "springmockk", version = "3.0.1" } +mockito = { group = "org.mockito.kotlin", name = "mockito-kotlin", version = "5.0.0" } +commonsCodec = { group = "commons-codec", name = "commons-codec", version = "1.15" } +commonsText = { group = "org.apache.commons", name = "commons-text", version = "1.9" } +datafaker = { group = "net.datafaker", name = "datafaker", version = "1.5.0" } +jaxen = { group = "jaxen", name = "jaxen", version = "1.2.0" } +icu4j = { group = "com.ibm.icu", name = "icu4j", version = "69.1" } +jsonUnitAssert = { group = "net.javacrumbs.json-unit", name = "json-unit-assertj", version = "2.28.0" } +otp = { group = "com.eatthepath", name = "java-otp", version = "0.4.0" } +amazonS3 = { group = "software.amazon.awssdk", name = "s3", version.ref = "amazonAwsSdk" } +amazonSTS = { group = "software.amazon.awssdk", name = "sts", version.ref = "amazonAwsSdk" } +amazonTranslate = { group = "software.amazon.awssdk", name = "translate", version.ref = "amazonAwsSdk" } +googleCloud = { group = "com.google.cloud", name = "libraries-bom", version = "24.0.0" } +amazonS3Mock = { group = "io.findify", name = "s3mock_2.13", version = "0.2.6" } +socketIoClient = { group = "io.socket", name = "socket.io-client", version = "1.0.1" } +sentry = { group = "io.sentry", name = "sentry-spring-boot-starter", version = "5.7.3" } +liquibaseCore = { group = "org.liquibase", name = "liquibase-core", version = "4.9.1" } +liquibaseGroovyDsl = { group = "org.liquibase", name = "liquibase-groovy-dsl", version = "3.0.2" } +liquibaseHibernate = { group = "org.liquibase.ext", name = "liquibase-hibernate5", version = "4.9.1" } +hibernateTypes = { group = "com.vladmihalcea", name = "hibernate-types-55", version = "2.14.1" } +redissonSpringBootStarter = { group = "org.redisson", name = "redisson-spring-boot-starter", version = "3.23.2" } +redissonSpringData = { group = "org.redisson", name = "redisson-spring-data-27", version = "3.23.2" } +postHog = { group = "com.posthog.java", name = "posthog", version = "1.1.0" } +micrometerPrometheus = { group = "io.micrometer", name = "micrometer-registry-prometheus", version = "1.9.12" } +caffeineCaching = { group = "com.github.ben-manes.caffeine", name = "caffeine", version = "3.0.5" }