I started my project by applying obvious collection of plugins to Gradle:
apply plugin: 'scala'
apply plugin: 'maven'
apply plugin: 'eclipse'
apply from: 'http://plugins.jasoft.fi/vaadin.plugin' //<-- Vaadin plugin
After that 'createVaadinServlet3Project' task generated some Java code for me to get started. I decided to keep that generated code in Java, since it is trivial and I would like to keep it obvious that it was auto-generated. I was all happy and ventured forth to define View, but this time I used Scala as the language. To my great surprise, the code failed to compile, because :compileJava was called before :compileScala and autogenerated code fails to find View defined in Scala.
Hence, we need to enable joint compilation in the Scala plugin:
// Enable joint compilation between Java and Scala
sourceSets.main.scala.srcDir "src/main/java"
sourceSets.main.java.srcDirs = []
Not the most obvious way, but that works. To certain extent... The next problem is reported by Vaadin plugin:
* What went wrong:
Execution failed for task ':updateWidgetset'.
> java.util.NoSuchElementException (no error message)
Apparently, Vaadin plugin looks at java source location and does not like it when there is nothing there. I was on the verge of treating it as a bug in Vaadin Gradle Plugin. I cloned the source code and made a change to look for Scala source path as well. But then I thought that it is wrong. Gradle is supposed to be powerful enough to be able to glue together different plugins without changes to the plugins themselves. That kind of problem with plugins was the very issue that drove me away from Maven. Hence, I decided to do in pure Gradle. Imagine my surprise when I did it with a simple one-liner. In some cases, the right question has half of the answer.
// Restore Java path for GWT widgetset to work
updateWidgetset.doFirst {
sourceSets.main.java.srcDir "src/main/java"
}
That is it. I amended the task from the Vaadin plugin and everything works like a charm. And it only took me an hour to figure out the whole project setup :)