build(connector): add Compose and split desktop app and server

This commit is contained in:
Anthony
2024-03-30 18:43:11 +01:00
parent 609c8393ae
commit 89451ba849
25 changed files with 361 additions and 49 deletions

View File

@@ -0,0 +1,23 @@
plugins {
alias(libs.plugins.kotlinJvm)
alias(libs.plugins.ktor)
application
}
group = "io.anthonyberg.connector"
version = "1.0.0"
application {
mainClass.set("io.anthonyberg.connector.ApplicationKt")
applicationDefaultJvmArgs = listOf("-Dio.ktor.development=${extra["development"] ?: "false"}")
}
dependencies {
implementation(projects.shared)
implementation(libs.logback)
implementation(libs.ktor.server.core)
implementation(libs.ktor.server.netty)
testImplementation(libs.ktor.server.tests)
testImplementation(libs.kotlin.test.junit)
implementation("dk.au.ece.vdmj:vdmj:4.5.0")
}

View File

@@ -0,0 +1,22 @@
package io.anthonyberg.connector
import Greeting
import SERVER_PORT
import io.ktor.server.application.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
fun main() {
embeddedServer(Netty, port = SERVER_PORT, host = "0.0.0.0", module = Application::module)
.start(wait = true)
}
fun Application.module() {
routing {
get("/") {
call.respondText("Ktor: ${Greeting().greet()}")
}
}
}

View File

@@ -0,0 +1,33 @@
package io.anthonyberg.connector
import com.fujitsu.vdmj.ExitStatus
import com.fujitsu.vdmj.Settings
import com.fujitsu.vdmj.config.Properties
import com.fujitsu.vdmj.plugins.Lifecycle
import com.fujitsu.vdmj.plugins.VDMJ
import kotlin.system.exitProcess
/**
* Handler for the VDM Model
*/
class VDMJ {
init {
Settings.mainClass = VDMJ::class.java
Properties.init()
val lifecycle: Lifecycle = createLifecycle()
exitProcess(if (lifecycle.run() == ExitStatus.EXIT_OK) 0 else 1)
}
/**
* Creates arguments for VDMJ
*/
private fun createLifecycle(): Lifecycle {
// Creates the arguments for VDMJ - i.e. where the file is located
val args: Array<String> = arrayOf("resources/checklist.vdmsl")
return Lifecycle(args)
}
}

View File

@@ -0,0 +1,12 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="trace">
<appender-ref ref="STDOUT"/>
</root>
<logger name="org.eclipse.jetty" level="INFO"/>
<logger name="io.netty" level="INFO"/>
</configuration>