From 31dbd90e17318170f69221ddfe5f3d4570698248 Mon Sep 17 00:00:00 2001 From: whiplash Date: Wed, 16 Oct 2024 17:22:48 +0200 Subject: [PATCH 1/3] [Scala] cask added --- scala/cask/.gitignore | 2 ++ scala/cask/build.sbt | 15 +++++++++++++++ scala/cask/project/build.properties | 1 + scala/cask/project/plugins.sbt | 1 + scala/cask/src/main/scala/Main.scala | 22 ++++++++++++++++++++++ 5 files changed, 41 insertions(+) create mode 100644 scala/cask/.gitignore create mode 100644 scala/cask/build.sbt create mode 100644 scala/cask/project/build.properties create mode 100644 scala/cask/project/plugins.sbt create mode 100644 scala/cask/src/main/scala/Main.scala diff --git a/scala/cask/.gitignore b/scala/cask/.gitignore new file mode 100644 index 00000000000..b7c76f59af8 --- /dev/null +++ b/scala/cask/.gitignore @@ -0,0 +1,2 @@ +cask/.metals/ +cask/.vscode/ diff --git a/scala/cask/build.sbt b/scala/cask/build.sbt new file mode 100644 index 00000000000..c0f7a4cf245 --- /dev/null +++ b/scala/cask/build.sbt @@ -0,0 +1,15 @@ +val CaskVersion = "0.9.4" + +name := "server" + +scalaVersion := "3.5.1" + +run / fork := true + +lazy val root = (project in file(".")) + .settings( + libraryDependencies ++= Seq( + "com.lihaoyi" %% "cask" % CaskVersion + ) + ) + .enablePlugins(JavaAppPackaging) diff --git a/scala/cask/project/build.properties b/scala/cask/project/build.properties new file mode 100644 index 00000000000..04267b14af6 --- /dev/null +++ b/scala/cask/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.9.9 diff --git a/scala/cask/project/plugins.sbt b/scala/cask/project/plugins.sbt new file mode 100644 index 00000000000..5c751f096f8 --- /dev/null +++ b/scala/cask/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "latest.integration") diff --git a/scala/cask/src/main/scala/Main.scala b/scala/cask/src/main/scala/Main.scala new file mode 100644 index 00000000000..8dfec74cb99 --- /dev/null +++ b/scala/cask/src/main/scala/Main.scala @@ -0,0 +1,22 @@ +case class MinimalRoutes()(implicit cc: castor.Context, log: cask.Logger) extends cask.Routes{ + + + @cask.get("/") + def hello() = { + "Hello World!" + } + + @cask.post("/do-thing") + def doThing(request: cask.Request) = { + request.text().reverse + } + + initialize() +} + + +object MinimalRoutesMain extends cask.Main{ + val port = 3000 + + val allRoutes = Seq(MinimalRoutes()) +} \ No newline at end of file From 3eb8710bef18ac7d47c86b67dc1d29b6b6795eae Mon Sep 17 00:00:00 2001 From: "Marco F." Date: Wed, 16 Oct 2024 18:12:56 +0200 Subject: [PATCH 2/3] [Scala] cask fixed --- scala/cask/.gitignore | 9 +++++++-- scala/cask/config.yaml | 3 +++ scala/cask/src/main/scala/Main.scala | 18 +++++++++++------- 3 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 scala/cask/config.yaml diff --git a/scala/cask/.gitignore b/scala/cask/.gitignore index b7c76f59af8..4d5b28e382d 100644 --- a/scala/cask/.gitignore +++ b/scala/cask/.gitignore @@ -1,2 +1,7 @@ -cask/.metals/ -cask/.vscode/ +project/project +project/target +target/ +.bloop/ +.metals/ +.vscode/ +project/metals.sbt \ No newline at end of file diff --git a/scala/cask/config.yaml b/scala/cask/config.yaml new file mode 100644 index 00000000000..ef260d76179 --- /dev/null +++ b/scala/cask/config.yaml @@ -0,0 +1,3 @@ +framework: + website: com-lihaoyi.github.io/cask/ + version: 0.9.4 diff --git a/scala/cask/src/main/scala/Main.scala b/scala/cask/src/main/scala/Main.scala index 8dfec74cb99..1aa48f9c563 100644 --- a/scala/cask/src/main/scala/Main.scala +++ b/scala/cask/src/main/scala/Main.scala @@ -1,22 +1,26 @@ case class MinimalRoutes()(implicit cc: castor.Context, log: cask.Logger) extends cask.Routes{ - @cask.get("/") def hello() = { - "Hello World!" + "" + } + + @cask.post("/user") + def postUser(request: cask.Request) = { + "" } - @cask.post("/do-thing") - def doThing(request: cask.Request) = { - request.text().reverse + @cask.get("/user/:name") // variable path segment, e.g. HOST/user/lihaoyi + def getUser(name: String) = { + name } initialize() } -object MinimalRoutesMain extends cask.Main{ - val port = 3000 +object MinimalRoutesMain extends cask.Main { + override val port = 3000 val allRoutes = Seq(MinimalRoutes()) } \ No newline at end of file From 428b5703d638521d2a85a3880c675dfc965c4855 Mon Sep 17 00:00:00 2001 From: whiplash Date: Sun, 20 Oct 2024 11:32:02 +0200 Subject: [PATCH 3/3] Update build.properties sbt version bump --- scala/cask/project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scala/cask/project/build.properties b/scala/cask/project/build.properties index 04267b14af6..0b699c3052d 100644 --- a/scala/cask/project/build.properties +++ b/scala/cask/project/build.properties @@ -1 +1 @@ -sbt.version=1.9.9 +sbt.version=1.10.2