Last active
February 15, 2018 15:41
-
-
Save samie/e2bc8f690ddd6f2fa653 to your computer and use it in GitHub Desktop.
Minimal Standalone Vaadin Application Jar with Maven (~ 7.7MB)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.vaadin.lightvaadin; | |
import com.vaadin.server.VaadinServlet; | |
import java.util.EventListener; | |
import java.util.logging.Level; | |
import java.util.logging.Logger; | |
import org.eclipse.jetty.server.Server; | |
import org.eclipse.jetty.servlet.ServletContextHandler; | |
import org.eclipse.jetty.servlet.ServletHolder; | |
/** Minimal Servlet bootstrap for Vaadin application. | |
* | |
* @author Sami Ekblad | |
*/ | |
public class App { | |
public static void main(String[] args) { | |
Server server = new Server(8080); | |
ServletContextHandler contextHandler | |
= new ServletContextHandler(ServletContextHandler.SESSIONS); | |
contextHandler.setContextPath("/"); | |
ServletHolder sh = new ServletHolder(new VaadinServlet()); | |
contextHandler.addServlet(sh, "/*"); | |
contextHandler.setInitParameter("ui", HelloWorldUI.class.getCanonicalName()); | |
// Register cdn.virit.in if present | |
try { | |
Class cls = Class.forName("in.virit.WidgetSet"); | |
if (cls != null) { | |
contextHandler.getSessionHandler().addEventListener((EventListener) cls.newInstance()); | |
} | |
} catch (Exception ex) { | |
Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); | |
} | |
server.setHandler(contextHandler); | |
try { | |
server.start(); | |
server.join(); | |
} catch (Exception ex) { | |
Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.vaadin.lightvaadin; | |
import com.vaadin.annotations.Theme; | |
import com.vaadin.annotations.Title; | |
import com.vaadin.server.VaadinRequest; | |
import com.vaadin.ui.*; | |
import com.vaadin.ui.Button.ClickEvent; | |
import java.util.Date; | |
@Title("Light Vaadin") | |
@Theme("valo") | |
public class HelloWorldUI extends UI { | |
private static final long serialVersionUID = 1L; | |
private CssLayout layout; | |
protected void init(VaadinRequest request) { | |
layout = new CssLayout(); | |
setContent(layout); | |
layout.addComponent(new Label("Hello world")); | |
layout.addComponent(new Button("Click me", new Button.ClickListener() { | |
@Override | |
public void buttonClick(ClickEvent event) { | |
Notification.show("Hello at " + new Date()); | |
} | |
})); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>org.vaadin.directory</groupId> | |
<artifactId>light-vaadin</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<packaging>jar</packaging> | |
<properties> | |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
<maven.compiler.source>1.7</maven.compiler.source> | |
<maven.compiler.target>1.7</maven.compiler.target> | |
<vaadin.version>7.4.2</vaadin.version> | |
<jetty.version>9.2.3.v20140905</jetty.version> | |
</properties> | |
<dependencies> | |
<dependency> | |
<groupId>com.vaadin</groupId> | |
<artifactId>vaadin-server</artifactId> | |
<version>${vaadin.version}</version> | |
<type>jar</type> | |
<exclusions> | |
<exclusion> | |
<groupId>com.vaadin.external.flute</groupId> | |
<artifactId>flute</artifactId> | |
</exclusion> | |
<exclusion> | |
<groupId>com.vaadin.external.google</groupId> | |
<artifactId>guava</artifactId> | |
</exclusion> | |
<exclusion> | |
<groupId>com.vaadin</groupId> | |
<artifactId>vaadin-sass-compiler</artifactId> | |
</exclusion> | |
</exclusions> | |
</dependency> | |
<!-- Instead of Valo, we use dawn --> | |
<dependency> | |
<groupId>org.peimari</groupId> | |
<artifactId>dawn</artifactId> | |
<version>4</version> | |
</dependency> | |
<dependency> | |
<groupId>org.eclipse.jetty</groupId> | |
<artifactId>jetty-webapp</artifactId> | |
<version>${jetty.version}</version> | |
<type>jar</type> | |
</dependency> | |
</dependencies> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>in.virit.vwscdn</groupId> | |
<artifactId>vwscdn-maven-plugin</artifactId> | |
<version>1.3.3</version> | |
<executions> | |
<execution> | |
<phase>generate-sources</phase> | |
<goals> | |
<goal>generate</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
<plugin> | |
<artifactId>maven-assembly-plugin</artifactId> | |
<configuration> | |
<archive> | |
<manifest> | |
<mainClass>org.vaadin.lightvaadin.App</mainClass> | |
</manifest> | |
</archive> | |
<descriptorRefs> | |
<descriptorRef>jar-with-dependencies</descriptorRef> | |
</descriptorRefs> | |
</configuration> | |
<executions> | |
<execution> | |
<id>make-assembly</id> | |
<phase>package</phase> | |
<goals> | |
<goal>single</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
</plugins> | |
</build> | |
<repositories> | |
<repository> | |
<id>vaadin-addons</id> | |
<url>http://maven.vaadin.com/vaadin-addons</url> | |
</repository> | |
</repositories> | |
</project> |
Here is an upgraded version and a bit smaller size: https://github.com/amahdy/vaadin-light
I've also included some instructions on how to get it to work, and removed broken dependencies.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@sunke-github, you can ignore the error, it's essentially looking for a plugin and if it finds it, it will initialize it. The error is simply there to tell you that it didn't find the plugin