diff --git a/cloud.ganttproject.colloboque/README.md b/cloud.ganttproject.colloboque/README.md new file mode 100644 index 0000000000..1f410b710b --- /dev/null +++ b/cloud.ganttproject.colloboque/README.md @@ -0,0 +1,61 @@ +# Colloboque: GanttProject real-time collaboration server + +This document gives an overview of a real-time collaboration server for GanttProject documents. + +## Building and running the server + +Colloboque server uses a couple of libraries from GanttProject. They are available in GanttProject GitHub packages, and +it is possible to build them locally. + +### Building + +If you want to use libs from GitHub Packages, you need to pass your GitHub username and Personal Access Token to the +Gradle when building Colloboque using project properties: + +```bash +gradle -Pgpr.user= -Pgpr.key= build +``` + +You can save `gpr.user` and `gpr.key` options into the local `gradle.properties` file (don't commit it into the version control). The remaining gradle command in this doc assume that the access to the required libs/repositories is already configured. + +Please refer to [GitHub Docs](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-gradle-registry#using-a-published-package) +for details on Personal Access Token + + +### Environment + +Colloboque requires an initialized PostgreSQL database. You can run a PostgreSQL instance using Docker: + +``` +docker run -d -p 5432:5432 --name dev-postgres -e POSTGRES_HOST_AUTH_METHOD=trust postgres +``` + +This will start Postgres on port 5432 with `postgres` super user and empty password. Initialize it using + +``` +cd src/main/resources/ +psql -h localhost -U postgres -f ./init-colloboque-server.sql +``` + +### Running the server + +The following command will show the available command line arguments: + +``` +gradle run --args='--help' +``` + +The default values are okay for the local development, so you can run the server with + +``` +gradle run +``` + +It should print to the console something like + +``` +> Task :run +14:49:38.771 DEBUG [Startup @ main] - Starting dev Colloboque server on port 9000 +14:49:38.883 DEBUG [Startup @ main] - Connected to the database. PostgreSQL 15.3 (Debian 15.3-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit +<= +``` \ No newline at end of file diff --git a/cloud.ganttproject.colloboque/build.gradle.kts b/cloud.ganttproject.colloboque/build.gradle.kts index fca722861f..0d695055cb 100644 --- a/cloud.ganttproject.colloboque/build.gradle.kts +++ b/cloud.ganttproject.colloboque/build.gradle.kts @@ -6,7 +6,7 @@ val kotlinVersion: String by project plugins { id("application") - id("org.jetbrains.kotlin.jvm") version "1.7.21" + id("org.jetbrains.kotlin.jvm") version "1.9.10" id("maven-publish") id("org.jetbrains.kotlin.plugin.serialization") version "1.7.21" } @@ -19,6 +19,14 @@ application { repositories { google() mavenCentral() + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/bardsoftware/ganttproject") + credentials { + username = project.findProperty("gpr.user")?.toString() ?: System.getenv("USERNAME") + password = project.findProperty("gpr.key")?.toString() ?: System.getenv("TOKEN") + } + } mavenLocal() } @@ -37,7 +45,7 @@ dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4") implementation("org.jooq:jooq:3.17.5") implementation("org.slf4j:slf4j-api:1.7.36") - implementation("com.github.ajalt.clikt:clikt:3.5.0") + implementation("com.github.ajalt.clikt:clikt:4.+") implementation("org.nanohttpd:nanohttpd:2.3.1") implementation("org.nanohttpd:nanohttpd-websocket:2.3.1") diff --git a/cloud.ganttproject.colloboque/gradle.properties b/cloud.ganttproject.colloboque/gradle.properties index 26089027bc..f1ec025b9b 100644 --- a/cloud.ganttproject.colloboque/gradle.properties +++ b/cloud.ganttproject.colloboque/gradle.properties @@ -1 +1 @@ -kotlinVersion=1.7.0 \ No newline at end of file +kotlinVersion=1.9.10 diff --git a/cloud.ganttproject.colloboque/src/main/kotlin/cloud/ganttproject/colloboque/DevServer.kt b/cloud.ganttproject.colloboque/src/main/kotlin/cloud/ganttproject/colloboque/DevServer.kt index e8052284a9..a0adfdf57c 100644 --- a/cloud.ganttproject.colloboque/src/main/kotlin/cloud/ganttproject/colloboque/DevServer.kt +++ b/cloud.ganttproject.colloboque/src/main/kotlin/cloud/ganttproject/colloboque/DevServer.kt @@ -19,9 +19,11 @@ along with GanttProject. If not, see . package cloud.ganttproject.colloboque import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.context import com.github.ajalt.clikt.parameters.options.default import com.github.ajalt.clikt.parameters.options.option import com.github.ajalt.clikt.parameters.types.int +import com.github.ajalt.clikt.output.MordantHelpFormatter import fi.iki.elonen.NanoHTTPD import fi.iki.elonen.NanoHTTPD.Response.Status import fi.iki.elonen.NanoWSD @@ -43,13 +45,18 @@ import java.util.zip.CRC32 fun main(args: Array) = DevServerMain().main(args) class DevServerMain : CliktCommand() { - private val port by option("--port").int().default(9000) - private val wsPort by option("--ws-port").int().default(9001) - private val pgHost by option("--pg-host").default("localhost") - private val pgPort by option("--pg-port").int().default(5432) - private val pgSuperUser by option("--pg-super-user").default("postgres") - private val pgSuperAuth by option("--pg-super-auth").default("") - + private val port by option("--port", help = "HTTP port to listen on").int().default(9000) + private val wsPort by option("--ws-port", help = "WebSocket port to listen on").int().default(9001) + private val pgHost by option("--pg-host", help = "Postgres host name").default("localhost") + private val pgPort by option("--pg-port", help = "Postgres port").int().default(5432) + private val pgSuperUser by option("--pg-super-user", help = "Postgres super user name").default("postgres") + private val pgSuperAuth by option("--pg-super-auth", help = "Postgres super user password").default("") + + init { + context { + helpFormatter = { MordantHelpFormatter(it, showDefaultValues = true) } + } + } override fun run() { STARTUP_LOG.debug("Starting dev Colloboque server on port {}", port)