Running Kotlin Code on SBT / Play Framework?
Asked Answered
T

2

13

I'm a huge fan of the PlayFramework, but I have limited experience with SBT / Scala. I've been trying to use Kotlin more, so I'm trying to get Kotlin Running on SBT / PlayFramework.

I've used Kotlin with the Gradle Build system, but that requires me to apply the Kotlin Gradle plugin. Not sure how to do the equivalent for SBT.

Here is your basic build.sbt for Play. How would I go about getting adding Kotlin?

name := """KotlinTestServer"""

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayJava)

scalaVersion := "2.11.1"

libraryDependencies ++= Seq(
  javaJdbc,
  javaEbean,
  cache,
  javaWs
)

I'd have to add "org.jetbrains.kotlin" % "kotlin-stdlib" % "0.10.195" as a library dependency, but what else?

Tome answered 2/1, 2015 at 23:22 Comment(3)
As an alternative, have you considered going the opposite way. How about a play2 app built in maven. code.google.com/p/play2-maven-plugin then Kotlin integration should be a lot more straight forward.Fayfayal
Thanks for the recommendation. I was considering building with Gradle, which would allow the same thing. The Gradle team is actually officially working on play integration, but the project is going a little slower than I'd hoped. I'll look into the maven plugin. Thanks!Tome
Gradle support for Play is documented here along with known issues: docs.gradle.org/current/userguide/play_plugin.htmlCeria
D
12

8 months late, but there is now: Github kotlin-plugin

addSbtPlugin("com.hanhuy.sbt" % "kotlin-plugin" % "0.5")
Divestiture answered 11/9, 2015 at 16:32 Comment(2)
Any comments anyone about how this worked for you in practice for your project?Roister
looks like this plugin is not maintained anymoreBrassy
B
0

You must have some additional configuration to compile Kotlin code, like a plugin for Kotlin... but AFAIK that plugin doesn't exists.

I don't know if is possible to reuse Maven plugins inside SBT, that could work. Or you could contribute with your own SBT plugin gor Kotlin

Blackthorn answered 3/1, 2015 at 11:42 Comment(3)
I essentially need to do whatever the plugin does manually. Interesting idea about the maven plugin inside SBT. I'll look into that.Tome
Ended up not panning out.Tome
The plugin does now exist. See other answer.Ceria

© 2022 - 2024 — McMap. All rights reserved.