Skip to content

Commit

Permalink
Update build with newer dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
cstroe committed Jun 15, 2021
1 parent 2ea817c commit 6871234
Show file tree
Hide file tree
Showing 21 changed files with 80 additions and 97 deletions.
12 changes: 12 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
group = "cloud.cosmin.checklister"

plugins {
kotlin("jvm") version "1.5.10" apply false
// Annotation Processing with Kotlin: https://kotlinlang.org/docs/reference/kapt.html
kotlin("kapt") version "1.5.10" apply false
// https://kotlinlang.org/docs/reference/compiler-plugins.html#spring-support
id("org.jetbrains.kotlin.plugin.spring") version "1.5.10" apply false
// https://kotlinlang.org/docs/reference/compiler-plugins.html#jpa-support
id("org.jetbrains.kotlin.plugin.jpa") version "1.5.10" apply false
// Kotlin Serialization: https://github.com/Kotlin/kotlinx.serialization
kotlin("plugin.serialization") version "1.5.10" apply false
}
6 changes: 3 additions & 3 deletions subprojects/dto/dto.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
`java-library`
kotlin("jvm") version "1.3.72"
kotlin("jvm")
// Kotlin Serialization: https://github.com/Kotlin/kotlinx.serialization
kotlin("plugin.serialization") version "1.3.72"
kotlin("plugin.serialization")
// https://github.com/kotest/kotest-gradle-plugin
id("io.kotlintest") version "1.1.1"
}
Expand All @@ -20,7 +20,7 @@ dependencies {
implementation(kotlin("stdlib-jdk8"))

// Kotlin Serialization: https://github.com/Kotlin/kotlinx.serialization
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.20.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.1")

// KoTest: https://github.com/kotest/kotest
testImplementation("io.kotest:kotest-runner-junit5-jvm:4.1.1")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package cloud.cosmin.checklister.lib.dto.internal

import kotlinx.serialization.Decoder
import kotlinx.serialization.Encoder
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializer
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import java.time.OffsetDateTime
import java.time.format.DateTimeFormatter

/**
* A kotlinx.serialization serializer for java.time.OffsetDateTime.
*/
@ExperimentalSerializationApi
@Serializer(forClass = OffsetDateTime::class)
object OffsetDateTimeSerializer: KSerializer<OffsetDateTime> {
private val formatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package cloud.cosmin.checklister.lib.dto.internal

import kotlinx.serialization.Decoder
import kotlinx.serialization.Encoder
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializer
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import java.util.*

/**
* A kotlinx.serialization serializer for java.util.UUID.
*/
@ExperimentalSerializationApi
@Serializer(forClass = UUID::class)
object UUIDSerializer: KSerializer<UUID> {
override fun serialize(encoder: Encoder, value: UUID) {
Expand Down
2 changes: 1 addition & 1 deletion subprojects/event/event.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
`java-library`
kotlin("jvm") version "1.3.72"
kotlin("jvm")
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package cloud.cosmin.checklister.lib.event.serde
import cloud.cosmin.checklister.lib.event.Event

interface EventDeserializer {
fun <T : Event> deserialize(byteArray: ByteArray, cls: Class<T>): T
fun deserialize(byteArray: ByteArray, cls: Class<Event>): Event
}
2 changes: 1 addition & 1 deletion subprojects/eventserde-json/eventserde-json.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
`java-library`
kotlin("jvm") version "1.3.72"
kotlin("jvm")
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ class JsonEventSerde : EventSerializer, EventDeserializer {
}

override fun serialize(event: Event): ByteArray {
return mapper.writeValueAsBytes(event)!!
return mapper.writeValueAsBytes(event)
}

override fun <T : Event> deserialize(byteArray: ByteArray, cls: Class<T>): T {
override fun deserialize(byteArray: ByteArray, cls: Class<Event>): Event {
return mapper.readValue(byteArray, cls)
}
}
2 changes: 1 addition & 1 deletion subprojects/eventsink-kafka/eventsink-kafka.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
`java-library`
kotlin("jvm") version "1.3.72"
kotlin("jvm")
}

repositories {
Expand Down
2 changes: 1 addition & 1 deletion subprojects/eventsink-logger/eventsink-logger.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
`java-library`
kotlin("jvm") version "1.3.72"
kotlin("jvm")
}

repositories {
Expand Down
2 changes: 1 addition & 1 deletion subprojects/history/history.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("java")
id("org.springframework.boot") version "2.1.3.RELEASE"
kotlin("jvm") version "1.3.72"
kotlin("jvm")
}

repositories {
Expand Down
4 changes: 2 additions & 2 deletions subprojects/integrationTest/integrationTest.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
`java-library`
kotlin("jvm") version "1.3.72"
kotlin("jvm")
// https://github.com/avast/gradle-docker-compose-plugin
id("com.avast.gradle.docker-compose") version "0.9.2"
id("com.avast.gradle.docker-compose") version "0.14.3"
// https://github.com/kotest/kotest-gradle-plugin
id("io.kotlintest") version "1.1.1"
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package cloud.cosmin.checklister.controller

import cloud.cosmin.checklister.lib.dto.EventDto
import cloud.cosmin.checklister.service.event.EventService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
Expand All @@ -15,18 +15,18 @@ import org.springframework.web.bind.annotation.PathVariable
import java.util.UUID

@Controller
@Api(description = "Operations on events that were emitted from this service", tags = arrayOf("event"))
@Tag(name = "event", description = "Operations on events that were emitted from this service")
class EventController
@Autowired constructor(private val eventService: EventService) {
@GetMapping("/api/v1/event")
@ApiOperation("List events")
@Operation(summary = "List events")
fun getEvents(pageable: Pageable): ResponseEntity<Page<EventDto>> {
val page = eventService.findAll(pageable)
return ResponseEntity.ok(page)
}

@DeleteMapping("/api/v1/event/{id}")
@ApiOperation("Delete an event")
@Operation(summary = "Delete an event")
fun deleteEvent(@PathVariable id: UUID): ResponseEntity<EventDto> {
return ResponseEntity.of(eventService.delete(id))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package cloud.cosmin.checklister.controller

import io.swagger.v3.oas.annotations.Hidden
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.RequestMapping
import springfox.documentation.annotations.ApiIgnore

@Controller
@ApiIgnore
@Hidden
class IndexController {
@RequestMapping(path = arrayOf("/"))
fun index(): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import cloud.cosmin.checklister.lib.dto.ItemGetDto
import cloud.cosmin.checklister.lib.dto.ItemPostDto
import cloud.cosmin.checklister.lib.event.model.RankOperation
import cloud.cosmin.checklister.service.ItemService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.ResponseEntity
import org.springframework.stereotype.Controller
Expand All @@ -14,19 +14,19 @@ import java.net.URI
import java.util.*

@Controller
@Api(description = "Operations on list items", tags = arrayOf("item"))
@Tag(name = "item", description = "Operations on list items")
class ItemController
@Autowired
constructor(private val itemService: ItemService) {

@GetMapping("/api/v1/item/{itemId}")
@ApiOperation("Retrieve an item")
@Operation(summary = "Retrieve an item")
fun getListItem(@PathVariable itemId: UUID): ResponseEntity<ItemGetDto> {
return ResponseEntity.of(itemService.findById(itemId))
}

@PostMapping("/api/v1/item")
@ApiOperation("Create an item")
@Operation(summary = "Create an item")
fun createItem(@RequestBody dto: ItemPostDto): ResponseEntity<ItemGetDto> {
val createdItem = itemService.create(dto)
return ResponseEntity
Expand All @@ -36,32 +36,32 @@ constructor(private val itemService: ItemService) {


@PutMapping("/api/v1/item/{itemId}")
@ApiOperation("Update an item")
@Operation(summary = "Update an item")
fun updateItem(@PathVariable itemId: UUID,
@RequestBody dto: ItemPostDto): ResponseEntity<ItemGetDto> {
return ResponseEntity.ok(itemService.update(itemId, dto))
}

@PostMapping("/api/v1/item/{itemId}/rank/up")
@ApiOperation("Move the item one rank up in its list")
@Operation(summary = "Move the item one rank up in its list")
fun rankUp(@PathVariable itemId: UUID): ResponseEntity<ItemGetDto> {
return ResponseEntity.ok(itemService.rank(itemId, RankOperation.UP))
}

@PostMapping("/api/v1/item/{itemId}/rank/down")
@ApiOperation("Move the item one rank down in its list")
@Operation(summary = "Move the item one rank down in its list")
fun rankDown(@PathVariable itemId: UUID): ResponseEntity<ItemGetDto> {
return ResponseEntity.ok(itemService.rank(itemId, RankOperation.DOWN))
}

@PostMapping("/api/v1/item/{itemId}/rank/top")
@ApiOperation("Move the item to the top of its list")
@Operation(summary = "Move the item to the top of its list")
fun rankTop(@PathVariable itemId: UUID): ResponseEntity<ItemGetDto> {
return ResponseEntity.ok(itemService.rank(itemId, RankOperation.TOP))
}

@PostMapping("/api/v1/item/{itemId}/rank/bottom")
@ApiOperation("Move the item to the bottom of its list")
@Operation(summary = "Move the item to the bottom of its list")
fun rankBottom(@PathVariable itemId: UUID): ResponseEntity<ItemGetDto> {
return ResponseEntity.ok(itemService.rank(itemId, RankOperation.BOTTOM))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ import cloud.cosmin.checklister.lib.dto.ListGetDto
import cloud.cosmin.checklister.lib.dto.ListPostDto
import cloud.cosmin.checklister.lib.dto.ListWithItemsDto
import cloud.cosmin.checklister.service.ListService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import java.net.URI
import java.util.*

@RestController
@Api(description = "Operations on lists", tags = arrayOf("list"))
@Tag(name = "list", description = "Operations on lists")
class ListController @Autowired
constructor(
private val listService: ListService
) {
@GetMapping("/api/v1/list")
@ApiOperation("Retrieve all lists")
@Operation(summary = "Retrieve all lists")
fun allLists(): ResponseEntity<List<ListGetDto>> {
return ResponseEntity.ok(listService.findAll())
}

@PostMapping(value = arrayOf("/api/v1/list"), consumes = arrayOf("application/json"))
@ApiOperation("Create a new list")
@Operation(summary = "Create a new list")
fun createList(@RequestBody listDto: ListPostDto): ResponseEntity<ListGetDto> {
val dto = listService.create(listDto)
return ResponseEntity
Expand All @@ -34,7 +34,7 @@ constructor(
}

@GetMapping("/api/v1/list/{listId}")
@ApiOperation("Retrieve a single list")
@Operation(summary = "Retrieve a single list")
fun getList(@PathVariable listId: UUID): ResponseEntity<ListGetDto> {
return ResponseEntity.of(listService.findById(listId))
}
Expand All @@ -46,7 +46,7 @@ constructor(
}

@GetMapping("/api/v1/list/{listId}/item")
@ApiOperation("Retrieve all items in a list")
@Operation(summary = "Retrieve all items in a list")
fun getListWithItems(@PathVariable listId: UUID): ResponseEntity<ListWithItemsDto> {
return ResponseEntity.of(listService.findByIdWithItems(listId))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ class ItemEntity {
@Column(name = "last_modified", nullable = false)
var lastModified: OffsetDateTime? = null

override fun equals(o: Any?): Boolean {
if (this === o) return true
if (o == null || javaClass != o.javaClass) return false
val that = o as ItemEntity?
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other == null || javaClass != other.javaClass) return false
val that = other as ItemEntity?
return rank == that!!.rank &&
id == that.id &&
content == that.content &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ItemService(val listRepo: ListRepository,
val newItem = ItemEntity()
newItem.content = createdDto.content
newItem.contentType = createdDto.contentType
newItem.rank = (list.items!!.size + 1) * 2
newItem.rank = (list.items.size + 1) * 2
newItem.list = list
newItem.createdAt = OffsetDateTime.now()
newItem.lastModified = OffsetDateTime.now()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ class ListService @Autowired constructor(
val otherList = otherListMaybe.get()

itemRepo.moveItems(otherList.id!!, existingList.id!!)
return Either.right(existingList.id!!)
return Either.Right(existingList.id!!)
}
}
Loading

0 comments on commit 6871234

Please sign in to comment.