Awesome Ilia. I’m sure that’ll come in handy. Unfortunately your usage of a maven archetype stops me as a gradle user from following your steps. It’d be interesting to setup a similar blog for gradle users…
There is a gradle based vaadin plugin… It works for eclipse. However, it does not work for intellij. It attached dependencies in such a way that intellij fails to pick up on them. This caused a lot of errors in idea. The idea plugin fixes that to some degree in that it rebuilds your idea project files adding all the appropriate dependencies. But that is flawed in the sense that I could not get it to work for multiple modules and the dependencies tended to ‘break’ a lot…
So I ended up dropping the vaadin gradle plugin. Here’s my current gradle file for those who are interested:
Also see the html file I attached in an earlier message, it describes how to setup your initial project…
apply plugin: ‘java’
// Application plugin allows you to run the program from command line. Consider it optional…
apply plugin: ‘application’
// The war plugin is required in case you want to deploy your project.
apply plugin: ‘war’
// This line tells the application plugin what main class to run.
mainClassName = “willow.hearthbonds.Startup”
repositories {
mavenCentral()
}
dependencies {
testCompile group: ‘junit’, name: ‘junit’, version: ‘4.11’
// Multi project support works... Yay... Needless to say, you can leave this out.
compile project(':kernel')
// I think these are the vaadin libraries you need at a bare minimum.
compile 'com.vaadin:vaadin-server:7.5.4'
compile 'com.vaadin:vaadin-client:7.5.4'
compile 'com.vaadin:vaadin-themes:7.5.4'
compile 'com.vaadin:vaadin-client-compiled:7.5.4'
// These are required to run the servlet in an embedded environment.
compile 'org.apache.tomcat:tomcat-catalina:7.0.41'
compile 'org.apache.tomcat:tomcat-util:7.0.41'
compile 'org.apache.tomcat.embed:tomcat-embed-core:7.0.41'
// Additional dependencies go here...
}
// For some reason intellij refuses to copy resources there is bound to be a way to get it to work, but I eventually gave up and just put this in side stepping the issue…
task copyResources(type: Copy) {
from “${projectDir}/src/main/webapp”
into “${buildDir}/classes/main”
}
processResources.dependsOn copyResources
I’m not a gradle expert. So this file can probably be improved upon. But it will get your vaadin project to work under intellij CE…
Running via embedded server goes a little something like this: Note the vaadin specific addInitParameter, that one had me struggling for a bit.
public static void main(final String args) throws IOException, LifecycleException, URISyntaxException {
Tomcat tomcat = new Tomcat();
tomcat.setPort(8080);
File base = new File(System.getProperty(“java.io.tmpdir”));
Context rootCtx = tomcat.addContext(“/app”, base.getAbsolutePath());
Wrapper wrapper = Tomcat.addServlet(rootCtx, “myApp”, new HeartbondsServlet());
wrapper.addInitParameter(“ui”, “willow.heartbonds.HeartbondsUI”);
rootCtx.addServletMapping(“/*”, “myApp”);
tomcat.start();
Desktop.getDesktop().browse(new URI(“http://localhost:8080/app”));
tomcat.getServer().await();
}