-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kotlin Controllers are not able to resolve Twirl templates #15
Comments
kotlin cannot compile before scala in this plugin. This is due to mix-mode scala+java+kotlin support. If twirl compiles directly to classes, you can make kotlinCompile depend on twirl:
|
I'll see if I can find out the name of that task, thanks for the pointer. |
will compile the Twirl templates, but the task doesn't result in .class files but rather some .scala files under target/scala-1.12/twirl/main/views/html. Since the Kotlin Controller needs to import and reference these as classes, it sounds like I would need a mix-mode scala+java+kotlin which doesn't exist. Thanks for your help. |
You will need to remove the dependency on // fix task scopes as necessary.
compile in Compile := Defaults.compileTask.value
compile in Compile := { // this will make kotlinCompile run after compile
KotlinCompile.compile(kotlincOptions.value,
sourceDirectories.value, kotlincPluginOptions.value,
dependencyClasspath.value, (managedClasspath in KotlinInternal).value,
classDirectory.value, streams.value)
(compile in Compile).value
}, |
I started with a very simple Play application which has a Controller in Kotlin that references a Twirl template. The Twirl needs to be complied before the Kotlin so that the generated class is visible, but the Kotlin appears to be compiled first resulting in errors:
My Controller is:
If I remove the reference to the Twirl template (eg:
return Results.ok("Kotlin controller is working")
) then the compilation is successful, Java controllers can reference this template and the application runs.Is there a way to force the Twirl/scala compilation to happen first?
The text was updated successfully, but these errors were encountered: