Skip to content

Commit

Permalink
#33 Translate Java sources to Kotlin (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
vityaman authored Oct 6, 2024
1 parent 87daf0f commit 0e8bc27
Show file tree
Hide file tree
Showing 56 changed files with 402 additions and 541 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Setup up JDK 21
- name: Setup up JDK 20
uses: actions/setup-java@v3
with:
java-version: '21'
java-version: '20'
distribution: 'temurin'
cache: gradle

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Build
run: gradle build
4 changes: 0 additions & 4 deletions .vscode/settings.json

This file was deleted.

10 changes: 10 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
plugins {
kotlin("jvm") version "1.9.24"
`kotlin-dsl`
}

repositories {
mavenCentral()
gradlePluginPortal()
}

dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin.coreLibrariesVersion}")
implementation("org.jetbrains.kotlin:kotlin-allopen:${kotlin.coreLibrariesVersion}")

implementation("org.springframework.boot:spring-boot-gradle-plugin:3.3.4")
implementation("io.spring.gradle:dependency-management-plugin:1.1.6")
}
23 changes: 0 additions & 23 deletions buildSrc/src/main/kotlin/buildlogic.java-conventions.gradle.kts

This file was deleted.

This file was deleted.

14 changes: 14 additions & 0 deletions buildSrc/src/main/kotlin/buildlogic.kotlin-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
plugins {
kotlin("jvm")
}

group = "ru.ifmo.se.dating"
version = "1.0.0"

repositories {
mavenCentral()
}

kotlin {
jvmToolchain(20)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
plugins {
id("buildlogic.kotlin-conventions")
`java-library`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
plugins {
id("buildlogic.kotlin-library-conventions")
id("org.springframework.boot")
id("io.spring.dependency-management")
kotlin("plugin.spring")
}
3 changes: 1 addition & 2 deletions common/testing/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
plugins {
id("buildlogic.java-library-conventions")
id("buildlogic.kotlin-library-conventions")
}

dependencies {
api(libs.org.testcontainers.postgresql)
api(libs.junit.junit)
compileOnly(libs.org.projectlombok.lombok)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package ru.ifmo.se.dating.container

import org.testcontainers.containers.PostgreSQLContainer

class Postgres private constructor() : AutoCloseable {
private val container = PostgreSQLContainer(DOCKER_IMAGE_NAME)

fun jdbcUrl(): String {
return container.jdbcUrl
}

fun username(): String {
return container.username
}

fun password(): String {
return container.password
}

override fun close() {
container.stop()
container.close()
}

companion object {
private const val DOCKER_IMAGE_NAME = "postgres"

fun start(): Postgres {
val postgres = Postgres()
postgres.container.start()
return postgres
}
}
}
10 changes: 2 additions & 8 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
com-fasterxml-jackson-core-jackson-databind = "2.17.2"
io-swagger-core-v3-swagger-annotations = "2.2.23"
io-swagger-core-v3-swagger-models = "2.2.23"
javax-annotation-javax-annotation-api = "1.3.2"
javax-servlet-javax-servlet-api = "4.0.1"
javax-validation-validation-api = "2.0.1.Final"
jakarta-validation-jakarta-validation-api = "3.1.0"
junit-junit = "4.13.2"
org-liquibase-liquibase-core = "4.29.2"
org-openapitools-jackson-databind-nullable = "0.2.6"
org-postgresql-postgresql = "42.7.4"
org-projectlombok-lombok = "1.18.34"
org-springdoc-springdoc-openapi-starter-webmvc-ui = "2.6.0"
org-springframework-boot-spring-boot = "3.3.4"
org-springframework-boot-spring-boot-starter-jdbc = "3.3.4"
Expand All @@ -23,14 +20,11 @@ org-testcontainers-postgresql = "1.20.1"
com-fasterxml-jackson-core-jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "com-fasterxml-jackson-core-jackson-databind" }
io-swagger-core-v3-swagger-annotations = { module = "io.swagger.core.v3:swagger-annotations", version.ref = "io-swagger-core-v3-swagger-annotations" }
io-swagger-core-v3-swagger-models = { module = "io.swagger.core.v3:swagger-models", version.ref = "io-swagger-core-v3-swagger-models" }
javax-annotation-javax-annotation-api = { module = "javax.annotation:javax.annotation-api", version.ref = "javax-annotation-javax-annotation-api" }
javax-servlet-javax-servlet-api = { module = "javax.servlet:javax.servlet-api", version.ref = "javax-servlet-javax-servlet-api" }
javax-validation-validation-api = { module = "javax.validation:validation-api", version.ref = "javax-validation-validation-api" }
jakarta-validation-jakarta-validation-api = { module = "jakarta.validation:jakarta.validation-api", version.ref = "jakarta-validation-jakarta-validation-api" }
junit-junit = { module = "junit:junit", version.ref = "junit-junit" }
org-liquibase-liquibase-core = { module = "org.liquibase:liquibase-core", version.ref = "org-liquibase-liquibase-core" }
org-openapitools-jackson-databind-nullable = { module = "org.openapitools:jackson-databind-nullable", version.ref = "org-openapitools-jackson-databind-nullable" }
org-postgresql-postgresql = { module = "org.postgresql:postgresql", version.ref = "org-postgresql-postgresql" }
org-projectlombok-lombok = { module = "org.projectlombok:lombok", version.ref = "org-projectlombok-lombok" }
org-springdoc-springdoc-openapi-starter-webmvc-ui = { module = "org.springdoc:springdoc-openapi-starter-webmvc-ui", version.ref = "org-springdoc-springdoc-openapi-starter-webmvc-ui" }
org-springframework-boot-spring-boot = { module = "org.springframework.boot:spring-boot", version.ref = "org-springframework-boot-spring-boot" }
org-springframework-boot-spring-boot-starter-jdbc = { module = "org.springframework.boot:spring-boot-starter-jdbc", version.ref = "org-springframework-boot-spring-boot-starter-jdbc" }
Expand Down
2 changes: 1 addition & 1 deletion matchmaker/api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
plugins {
id("buildlogic.java-library-conventions")
id("buildlogic.kotlin-library-conventions")
}
3 changes: 0 additions & 3 deletions matchmaker/api/src/main/resources/static/openapi/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ paths:
type: array
items:
$ref: "#/components/schemas/PersonId"
uniqueItems: true
401:
$ref: "#/components/responses/401"
500:
Expand Down Expand Up @@ -145,7 +144,6 @@ paths:
type: array
items:
$ref: "#/components/schemas/PersonId"
uniqueItems: true
401:
$ref: "#/components/responses/401"
403:
Expand Down Expand Up @@ -195,7 +193,6 @@ paths:
- personId
- likes
- skips
uniqueItems: true
401:
$ref: "#/components/responses/401"
403:
Expand Down
11 changes: 2 additions & 9 deletions matchmaker/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
plugins {
id("buildlogic.java-conventions")
id("org.springframework.boot") version "3.0.0"
id("io.spring.dependency-management") version "1.0.11.RELEASE"
java
id("buildlogic.spring-conventions")
application
}

Expand All @@ -13,12 +10,8 @@ dependencies {
implementation(libs.org.springdoc.springdoc.openapi.starter.webmvc.ui)
testImplementation(project(":common-testing"))
testImplementation(libs.org.springframework.boot.spring.boot.starter.test)
compileOnly(libs.org.projectlombok.lombok)
annotationProcessor(libs.org.projectlombok.lombok)
testCompileOnly(libs.org.projectlombok.lombok)
testAnnotationProcessor(libs.org.projectlombok.lombok)
}

application {
mainClass = "${group}.matchmaker.OpenApiGeneratorApplication"
mainClass = "${group}.matchmaker.ApplicationKt"
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package ru.ifmo.se.dating.matchmaker

import org.springframework.boot.test.util.TestPropertyValues
import org.springframework.context.ApplicationContextInitializer
import org.springframework.context.ConfigurableApplicationContext
import ru.ifmo.se.dating.container.Postgres

class DatabaseInitializer : ApplicationContextInitializer<ConfigurableApplicationContext> {
private val postgres: Postgres = Postgres.start()

override fun initialize(applicationContext: ConfigurableApplicationContext) {
TestPropertyValues.of(
"spring.datasource.url=${postgres.jdbcUrl()}",
"spring.datasource.username=${postgres.username()}",
"spring.datasource.password=${postgres.password()}",
).applyTo(applicationContext.environment)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package ru.ifmo.se.dating.matchmaker

import org.junit.Test

class MatchmakerStartupTest : MatchmakerTestSuite() {
@Test
fun contextLoads() {
// Okay
}
}
Loading

0 comments on commit 0e8bc27

Please sign in to comment.