Add some pojos and configs

This commit is contained in:
Mikołaj Pich 2021-09-25 15:54:48 +02:00
parent 231193a842
commit d239094dbe
8 changed files with 86 additions and 21 deletions

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
@ -8,6 +9,8 @@
<option name="modules"> <option name="modules">
<set> <set>
<option value="$PROJECT_DIR$" /> <option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/generator" />
<option value="$PROJECT_DIR$/pojos" />
</set> </set>
</option> </option>
</GradleProjectSettings> </GradleProjectSettings>

View file

@ -1,28 +1,32 @@
buildscript {
repositories {
google()
gradlePluginPortal()
}
}
plugins { plugins {
id 'org.jetbrains.kotlin.jvm' version '1.5.31' id 'org.jetbrains.kotlin.jvm' version '1.5.31'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.5.31'
} }
group = 'io.github.wulkanowy' version = "0.1.0-SNAPSHOT"
version = '0.1.0-SNAPSHOT' group = "io.github.wulkanowy"
repositories { allprojects {
repositories {
mavenCentral() mavenCentral()
}
} }
dependencies { subprojects {
implementation 'net.pwall.json:json-kotlin-schema:0.28' java {
sourceCompatibility = JavaVersion.VERSION_11
testImplementation 'org.jetbrains.kotlin:kotlin-test:1.5.21' targetCompatibility = JavaVersion.VERSION_11
} }
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
test { kotlinOptions {
useJUnit() jvmTarget = JavaVersion.VERSION_11.toString()
} }
}
compileKotlin {
kotlinOptions.jvmTarget = '11'
}
compileTestKotlin {
kotlinOptions.jvmTarget = '11'
} }

10
generator/build.gradle Normal file
View file

@ -0,0 +1,10 @@
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm'
id 'org.jetbrains.kotlin.plugin.serialization'
}
dependencies {
implementation project(":pojos")
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.0"
}

View file

@ -0,0 +1,18 @@
import io.github.wulkanowy.messages.pojo.Message
import io.github.wulkanowy.messages.pojo.MessageType
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
val messages = listOf(
Message(
id = 1,
title = "Problemy z zadaniami domowymi",
content = "Występują problemy z zadaniami domowymi. Zaktualizuj aplikację!",
type = MessageType.USER_MESSAGE,
)
)
fun main() {
val json = Json.encodeToString(messages)
println(json)
}

10
pojos/build.gradle Normal file
View file

@ -0,0 +1,10 @@
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm'
id 'org.jetbrains.kotlin.plugin.serialization'
id 'maven-publish'
}
dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.0"
}

View file

@ -0,0 +1,13 @@
package io.github.wulkanowy.messages.pojo
import kotlinx.serialization.Serializable
@Serializable
data class Message(
val id: Int,
val title: String,
val content: String,
val versionMin: Int? = null,
val versionMax: Int? = null,
val type: MessageType,
)

View file

@ -0,0 +1,6 @@
package io.github.wulkanowy.messages.pojo
enum class MessageType {
USER_MESSAGE,
ERROR_OVERRIDE,
}

View file

@ -1,3 +1,4 @@
include "generator"
include "pojos"
rootProject.name = 'messages' rootProject.name = 'messages'