/extras | /extras | ||||
uitest/src/main/themes/VAADIN/themes/**/styles.css | uitest/src/main/themes/VAADIN/themes/**/styles.css | ||||
test/servlet-containers/karaf/vaadin-karaf-bundle1/src/main/resources/VAADIN/themes/karaftesttheme/styles.css | |||||
# Persisted scss cache files | # Persisted scss cache files | ||||
uitest/src/main/themes/VAADIN/themes/**/styles.scss.cache | uitest/src/main/themes/VAADIN/themes/**/styles.scss.cache |
<module>servlet-containers/generic</module> | <module>servlet-containers/generic</module> | ||||
<module>cdi</module> | <module>cdi</module> | ||||
<module>servlet-containers/jsp-integration</module> | <module>servlet-containers/jsp-integration</module> | ||||
<module>servlet-containers/karaf</module> | |||||
<module>bean-api-validation</module> | <module>bean-api-validation</module> | ||||
<module>bean-impl-validation</module> | <module>bean-impl-validation</module> | ||||
<module>dependency-rewrite-addon</module> | <module>dependency-rewrite-addon</module> |
Automatic test for Karaf deployment | |||||
=== | |||||
What is tested | |||||
--- | |||||
* Multiple applications are deployed and work properly | |||||
* Default widgetset works | |||||
* Custom widgetset works | |||||
* Custom theme works | |||||
Tips and Tricks | |||||
--- | |||||
* Karaf is downloaded and deployed by maven karaf plugin | |||||
* Karaf is run as a background process using maven `exec:exec` goal | |||||
* Karaf is shut down using maven `karaf:client` goal during `post-integration-test` phase | |||||
* All required karaf features and project bundles are deployed using maven karaf plugin with `client` goal | |||||
Running and stopping karaf manually | |||||
--- | |||||
* To start karaf as a foreground process and deploy both vaadin bundles and two existing applications, run `mvn -f karaf-run-pom.xml clean karaf:run` | |||||
in `karaf-run` module | |||||
* To start karaf as a background process and deploy both vaadin bundles and two existing applications, run `mvn clean pre-integration-test` | |||||
in `karaf-run` module | |||||
* Karaf console is available via ssh at `127.0.0.0:8101` port, username/password is `karaf/karaf` | |||||
* To stop background karaf process, run `mvn karaf:client@karaf-client-shutdown` | |||||
in `karaf-run` module | |||||
Potential problems | |||||
--- | |||||
* Maven executable should be in `PATH` | |||||
* Background karaf process may be left running for 10 minutes if the build fails prior `integration-test` phase. |
<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"> | |||||
<artifactId>karaf-runner</artifactId> | |||||
<groupId>com.vaadin</groupId> | |||||
<version>8.1-SNAPSHOT</version> | |||||
<modelVersion>4.0.0</modelVersion> | |||||
<build> | |||||
<plugins> | |||||
<plugin> | |||||
<groupId>org.apache.karaf.tooling</groupId> | |||||
<artifactId>karaf-maven-plugin</artifactId> | |||||
<version>4.0.8</version> | |||||
<configuration> | |||||
<deployProjectArtifact>false</deployProjectArtifact> | |||||
<startSsh>true</startSsh> | |||||
</configuration> | |||||
</plugin> | |||||
</plugins> | |||||
</build> | |||||
</project> |
<?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"> | |||||
<parent> | |||||
<artifactId>vaadin-test-karaf</artifactId> | |||||
<groupId>com.vaadin</groupId> | |||||
<relativePath>..</relativePath> | |||||
<version>8.1-SNAPSHOT</version> | |||||
</parent> | |||||
<modelVersion>4.0.0</modelVersion> | |||||
<artifactId>karaf-run</artifactId> | |||||
<name>Vaadin Karaf Test Runner</name> | |||||
<dependencies> | |||||
<!--Vaadin dependencies should not be in a classpath--> | |||||
<dependency> | |||||
<groupId>com.vaadin</groupId> | |||||
<artifactId>vaadin-server</artifactId> | |||||
<version>${vaadin.version}</version> | |||||
<scope>provided</scope> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>com.vaadin</groupId> | |||||
<artifactId>vaadin-themes</artifactId> | |||||
<version>${vaadin.version}</version> | |||||
<scope>provided</scope> | |||||
</dependency> | |||||
</dependencies> | |||||
<build> | |||||
<plugins> | |||||
<plugin> | |||||
<groupId>org.codehaus.mojo</groupId> | |||||
<artifactId>exec-maven-plugin</artifactId> | |||||
<version>1.6.0</version> | |||||
<executions> | |||||
<execution> | |||||
<phase>pre-integration-test</phase> | |||||
<goals> | |||||
<goal>exec</goal> | |||||
</goals> | |||||
<configuration> | |||||
<executable>mvn</executable> | |||||
<async>true</async> | |||||
<asyncDestroyOnShutdown>true</asyncDestroyOnShutdown> | |||||
<commandlineArgs>-f karaf-run-pom.xml karaf:run</commandlineArgs> | |||||
</configuration> | |||||
</execution> | |||||
</executions> | |||||
</plugin> | |||||
<plugin> | |||||
<groupId>org.apache.karaf.tooling</groupId> | |||||
<artifactId>karaf-maven-plugin</artifactId> | |||||
<version>4.0.8</version> | |||||
<executions> | |||||
<execution> | |||||
<id>karaf-client-ctrl</id> | |||||
<phase>pre-integration-test</phase> | |||||
<goals> | |||||
<goal>client</goal> | |||||
</goals> | |||||
<configuration> | |||||
<delay>5</delay> | |||||
<attempts>150</attempts> | |||||
<commands> | |||||
<!--Scheduled shutdown in 15 minutes--> | |||||
<command>shutdown -f +10</command> | |||||
<command>feature:install http</command> | |||||
<command>feature:install http-whiteboard</command> | |||||
<command>bundle:install -s mvn:org.jsoup/jsoup/1.8.3</command> | |||||
<command>bundle:install -s mvn:com.vaadin.external/gentyref/1.2.0.vaadin1</command> | |||||
<command>bundle:install -s mvn:com.vaadin/vaadin-shared/${vaadin.version}</command> | |||||
<command>bundle:install -s mvn:com.vaadin/vaadin-server/${vaadin.version}</command> | |||||
<command>bundle:install -s mvn:com.vaadin/vaadin-osgi-integration/${vaadin.version}</command> | |||||
<command>bundle:install -s mvn:com.vaadin/vaadin-client-compiled/${vaadin.version}</command> | |||||
<command>bundle:install -s mvn:com.vaadin/vaadin-themes/${vaadin.version}</command> | |||||
<command> | |||||
<![CDATA[bundle:install -s file:./../vaadin-karaf-bundle1/target/vaadin-karaf-bundle1-${project.version}.jar]]></command> | |||||
<command> | |||||
<![CDATA[bundle:install -s file:./../vaadin-karaf-bundle2/target/vaadin-karaf-bundle2-${project.version}.jar]]></command> | |||||
</commands> | |||||
</configuration> | |||||
</execution> | |||||
<execution> | |||||
<id>karaf-client-shutdown</id> | |||||
<phase>post-integration-test</phase> | |||||
<goals> | |||||
<goal>client</goal> | |||||
</goals> | |||||
<configuration> | |||||
<delay>5</delay> | |||||
<attempts>10</attempts> | |||||
<commands> | |||||
<command>system:shutdown -f</command> | |||||
</commands> | |||||
</configuration> | |||||
</execution> | |||||
</executions> | |||||
</plugin> | |||||
<plugin> | |||||
<groupId>org.apache.maven.plugins</groupId> | |||||
<artifactId>maven-failsafe-plugin</artifactId> | |||||
<version>2.19.1</version> | |||||
<executions> | |||||
<execution> | |||||
<goals> | |||||
<goal>integration-test</goal> | |||||
<goal>verify</goal> | |||||
</goals> | |||||
</execution> | |||||
</executions> | |||||
<configuration> | |||||
<environmentVariables> | |||||
<vaadin.version>${vaadin.version}</vaadin.version> | |||||
</environmentVariables> | |||||
</configuration> | |||||
</plugin> | |||||
</plugins> | |||||
</build> | |||||
</project> |
/* | |||||
* Copyright 2000-2017 Vaadin Ltd. | |||||
* | |||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | |||||
* use this file except in compliance with the License. You may obtain a copy of | |||||
* the License at | |||||
* | |||||
* http://www.apache.org/licenses/LICENSE-2.0 | |||||
* | |||||
* Unless required by applicable law or agreed to in writing, software | |||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |||||
* License for the specific language governing permissions and limitations under | |||||
* the License. | |||||
*/ | |||||
package com.vaadin.test.osgi; | |||||
import com.vaadin.testbench.TestBenchTestCase; | |||||
import org.junit.After; | |||||
import org.junit.Before; | |||||
import org.junit.Test; | |||||
import org.openqa.selenium.By; | |||||
import org.openqa.selenium.WebElement; | |||||
import org.openqa.selenium.phantomjs.PhantomJSDriver; | |||||
import static org.junit.Assert.assertEquals; | |||||
public class KarafIntegrationIT extends TestBenchTestCase { | |||||
private static final String URL_PREFIX = "http://localhost:8181/"; | |||||
private static final String APP1_URL = URL_PREFIX + "myapp1"; | |||||
private static final String APP2_URL = URL_PREFIX + "myapp2"; | |||||
@Test | |||||
public void testApp1() { | |||||
runBasicTest(APP1_URL, "bar"); | |||||
//App theme should make a button pink | |||||
WebElement element = getDriver().findElement(By.className("v-button")); | |||||
String buttonColor = element.getCssValue("color"); | |||||
assertEquals("rgba(255, 128, 128, 1)", buttonColor); | |||||
} | |||||
@Test | |||||
public void testApp2() { | |||||
runBasicTest(APP2_URL, "foo"); | |||||
} | |||||
private void runBasicTest(String app1Url, String text) { | |||||
getDriver().navigate().to(app1Url); | |||||
getDriver().findElement(By.className("v-textfield")).sendKeys(text); | |||||
getDriver().findElement(By.className("v-button")).click(); | |||||
String foundText = getDriver().findElement(By.className("v-label")).getText(); | |||||
assertEquals("Thanks " + text + ", it works!", foundText); | |||||
} | |||||
@Before | |||||
public void setup() { | |||||
setDriver(new PhantomJSDriver()); | |||||
} | |||||
@After | |||||
public void teardown() { | |||||
getDriver().quit(); | |||||
} | |||||
} |
<?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> | |||||
<parent> | |||||
<groupId>com.vaadin</groupId> | |||||
<artifactId>vaadin-test</artifactId> | |||||
<version>8.1-SNAPSHOT</version> | |||||
<relativePath>../..</relativePath> | |||||
</parent> | |||||
<artifactId>vaadin-test-karaf</artifactId> | |||||
<packaging>pom</packaging> | |||||
<name>Vaadin Karaf TestRoot</name> | |||||
<modules> | |||||
<module>vaadin-karaf-bundle1</module> | |||||
<module>vaadin-karaf-bundle2</module> | |||||
<module>karaf-run</module> | |||||
</modules> | |||||
<properties> | |||||
<karaf.plugin.version>4.0.8</karaf.plugin.version> | |||||
<vaadin.widgetset.mode>local</vaadin.widgetset.mode> | |||||
</properties> | |||||
<build> | |||||
<plugins> | |||||
<plugin> | |||||
<groupId>org.eclipse.jetty</groupId> | |||||
<artifactId>jetty-maven-plugin</artifactId> | |||||
<configuration> | |||||
<skip>true</skip> | |||||
</configuration> | |||||
</plugin> | |||||
</plugins> | |||||
</build> | |||||
</project> |
Bundle-Name: ${project.name} | |||||
Bundle-Version: ${project.version} | |||||
Bundle-SymbolicName: ${project.groupId}.${project.artifactId} | |||||
Export-Package: com.vaadin.test.osgi.myapplication1 | |||||
Import-Package: * | |||||
Web-ContentPath: /myapp1 |
<?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> | |||||
<parent> | |||||
<groupId>com.vaadin</groupId> | |||||
<artifactId>vaadin-test-karaf</artifactId> | |||||
<version>8.1-SNAPSHOT</version> | |||||
<relativePath>..</relativePath> | |||||
</parent> | |||||
<artifactId>vaadin-karaf-bundle1</artifactId> | |||||
<packaging>jar</packaging> | |||||
<name>Vaadin Karaf test bundle 1</name> | |||||
<dependencyManagement> | |||||
<dependencies> | |||||
<dependency> | |||||
<groupId>com.vaadin</groupId> | |||||
<artifactId>vaadin-bom</artifactId> | |||||
<version>${vaadin.version}</version> | |||||
<type>pom</type> | |||||
<scope>import</scope> | |||||
</dependency> | |||||
</dependencies> | |||||
</dependencyManagement> | |||||
<dependencies> | |||||
<dependency> | |||||
<groupId>com.vaadin</groupId> | |||||
<artifactId>vaadin-server</artifactId> | |||||
<scope>provided</scope> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>com.vaadin</groupId> | |||||
<artifactId>vaadin-client-compiled</artifactId> | |||||
<scope>provided</scope> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>com.vaadin</groupId> | |||||
<artifactId>vaadin-themes</artifactId> | |||||
<scope>provided</scope> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>com.vaadin</groupId> | |||||
<artifactId>vaadin-osgi-integration</artifactId> | |||||
<version>8.1.0.beta1</version> | |||||
<scope>provided</scope> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.osgi</groupId> | |||||
<artifactId>osgi.core</artifactId> | |||||
<version>6.0.0</version> | |||||
<scope>provided</scope> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.osgi</groupId> | |||||
<artifactId>osgi.annotation</artifactId> | |||||
<version>6.0.1</version> | |||||
<scope>provided</scope> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.osgi</groupId> | |||||
<artifactId>osgi.cmpn</artifactId> | |||||
<version>6.0.0</version> | |||||
<scope>provided</scope> | |||||
</dependency> | |||||
<!-- For compiling WidgetSet --> | |||||
<dependency> | |||||
<groupId>com.vaadin</groupId> | |||||
<artifactId>vaadin-client</artifactId> | |||||
<version>${vaadin.version}</version> | |||||
<scope>provided</scope> | |||||
</dependency> | |||||
</dependencies> | |||||
<build> | |||||
<plugins> | |||||
<plugin> | |||||
<groupId>biz.aQute.bnd</groupId> | |||||
<artifactId>bnd-maven-plugin</artifactId> | |||||
<version>3.3.0</version> | |||||
<executions> | |||||
<execution> | |||||
<goals> | |||||
<goal>bnd-process</goal> | |||||
</goals> | |||||
<configuration> | |||||
</configuration> | |||||
</execution> | |||||
</executions> | |||||
</plugin> | |||||
<plugin> | |||||
<groupId>com.vaadin</groupId> | |||||
<artifactId>vaadin-maven-plugin</artifactId> | |||||
<version>${vaadin.plugin.version}</version> | |||||
<executions> | |||||
<execution> | |||||
<goals> | |||||
<goal>compile</goal> | |||||
<goal>compile-theme</goal> | |||||
</goals> | |||||
</execution> | |||||
</executions> | |||||
</plugin> | |||||
<plugin> | |||||
<groupId>org.apache.maven.plugins</groupId> | |||||
<artifactId>maven-jar-plugin</artifactId> | |||||
<version>3.0.2</version> | |||||
<configuration> | |||||
<archive> | |||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> | |||||
</archive> | |||||
</configuration> | |||||
</plugin> | |||||
</plugins> | |||||
</build> | |||||
<profiles> | |||||
<profile> | |||||
<!-- Vaadin pre-release repositories --> | |||||
<id>vaadin-prerelease</id> | |||||
<activation> | |||||
<activeByDefault>true</activeByDefault> | |||||
</activation> | |||||
<repositories> | |||||
<repository> | |||||
<id>vaadin-prereleases</id> | |||||
<url>http://maven.vaadin.com/vaadin-prereleases</url> | |||||
</repository> | |||||
<repository> | |||||
<id>vaadin-snapshots</id> | |||||
<url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url> | |||||
<releases> | |||||
<enabled>false</enabled> | |||||
</releases> | |||||
<snapshots> | |||||
<enabled>true</enabled> | |||||
</snapshots> | |||||
</repository> | |||||
</repositories> | |||||
<pluginRepositories> | |||||
<pluginRepository> | |||||
<id>vaadin-prereleases</id> | |||||
<url>http://maven.vaadin.com/vaadin-prereleases</url> | |||||
</pluginRepository> | |||||
<pluginRepository> | |||||
<id>vaadin-snapshots</id> | |||||
<url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url> | |||||
<releases> | |||||
<enabled>false</enabled> | |||||
</releases> | |||||
<snapshots> | |||||
<enabled>true</enabled> | |||||
</snapshots> | |||||
</pluginRepository> | |||||
</pluginRepositories> | |||||
</profile> | |||||
</profiles> | |||||
</project> |
package com.vaadin.test.osgi.myapplication1; | |||||
import com.vaadin.osgi.resources.OsgiVaadinTheme; | |||||
import com.vaadin.osgi.resources.OsgiVaadinWidgetset; | |||||
import com.vaadin.ui.themes.ValoTheme; | |||||
import org.osgi.service.component.annotations.Component; | |||||
@Component | |||||
public class CustomWidgetSet implements OsgiVaadinWidgetset { | |||||
@Override | |||||
public String getName() { | |||||
return "com.vaadin.test.osgi.widgetset.CustomWidgetSet"; | |||||
} | |||||
} |
package com.vaadin.test.osgi.myapplication1; | |||||
import com.vaadin.osgi.resources.OsgiVaadinTheme; | |||||
import com.vaadin.ui.themes.ValoTheme; | |||||
import org.osgi.service.component.annotations.Component; | |||||
@Component | |||||
public class KarafTestTheme extends ValoTheme implements OsgiVaadinTheme { | |||||
@Override | |||||
public String getName() { | |||||
return "karaftesttheme"; | |||||
} | |||||
} |
package com.vaadin.test.osgi.myapplication1; | |||||
import javax.servlet.annotation.WebServlet; | |||||
import com.vaadin.annotations.Theme; | |||||
import com.vaadin.annotations.Widgetset; | |||||
import org.osgi.service.component.annotations.Component; | |||||
import com.vaadin.annotations.VaadinServletConfiguration; | |||||
import com.vaadin.server.VaadinRequest; | |||||
import com.vaadin.server.VaadinServlet; | |||||
import com.vaadin.ui.Button; | |||||
import com.vaadin.ui.Label; | |||||
import com.vaadin.ui.TextField; | |||||
import com.vaadin.ui.UI; | |||||
import com.vaadin.ui.VerticalLayout; | |||||
@Theme("karaftesttheme") | |||||
@Widgetset("com.vaadin.test.osgi.widgetset.CustomWidgetSet") | |||||
public class MyUI extends UI { | |||||
@Override | |||||
protected void init(VaadinRequest vaadinRequest) { | |||||
final VerticalLayout layout = new VerticalLayout(); | |||||
final TextField name = new TextField(); | |||||
name.setCaption("Type your name here:"); | |||||
Button button = new Button("Click Me"); | |||||
button.addClickListener(e -> { | |||||
layout.addComponent(new Label("Thanks " + name.getValue() + ", it works!")); | |||||
}); | |||||
layout.addComponents(name, button); | |||||
setContent(layout); | |||||
} | |||||
@Component(service = VaadinServlet.class) | |||||
@WebServlet(urlPatterns = "/myapp1/*", name = "MyUIServlet", asyncSupported = true) | |||||
@VaadinServletConfiguration(ui = MyUI.class, productionMode = false) | |||||
public static class MyUIServlet extends VaadinServlet { | |||||
} | |||||
} |
@import "../valo/valo.scss"; | |||||
@mixin karaftesttheme { | |||||
@include valo; | |||||
.v-button { | |||||
color: rgba(255, 128, 128, 1) | |||||
} | |||||
} | |||||
.karaftesttheme { | |||||
@include karaftesttheme; | |||||
} |
<module> | |||||
<!-- Hint for WidgetSetBuilder not to automatically update the file --> | |||||
<!-- WS Compiler: manually edited --> | |||||
<inherits name="com.vaadin.DefaultWidgetSet" /> | |||||
</module> |
Bundle-Name: ${project.name} | |||||
Bundle-Version: ${project.version} | |||||
Bundle-SymbolicName: ${project.groupId}.${project.artifactId} | |||||
Import-Package: * | |||||
Web-ContentPath: /myapp2 |
<?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> | |||||
<parent> | |||||
<artifactId>vaadin-test-karaf</artifactId> | |||||
<groupId>com.vaadin</groupId> | |||||
<relativePath>..</relativePath> | |||||
<version>8.1-SNAPSHOT</version> | |||||
</parent> | |||||
<artifactId>vaadin-karaf-bundle2</artifactId> | |||||
<packaging>jar</packaging> | |||||
<name>Vaadin Karaf test bundle 2</name> | |||||
<dependencyManagement> | |||||
<dependencies> | |||||
<dependency> | |||||
<groupId>com.vaadin</groupId> | |||||
<artifactId>vaadin-bom</artifactId> | |||||
<version>${vaadin.version}</version> | |||||
<type>pom</type> | |||||
<scope>import</scope> | |||||
</dependency> | |||||
</dependencies> | |||||
</dependencyManagement> | |||||
<dependencies> | |||||
<dependency> | |||||
<groupId>com.vaadin</groupId> | |||||
<artifactId>vaadin-server</artifactId> | |||||
<scope>provided</scope> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>com.vaadin</groupId> | |||||
<artifactId>vaadin-client-compiled</artifactId> | |||||
<scope>provided</scope> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>com.vaadin</groupId> | |||||
<artifactId>vaadin-themes</artifactId> | |||||
<scope>provided</scope> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>com.vaadin</groupId> | |||||
<artifactId>vaadin-osgi-integration</artifactId> | |||||
<version>8.1.0.beta1</version> | |||||
<scope>provided</scope> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.osgi</groupId> | |||||
<artifactId>osgi.core</artifactId> | |||||
<version>6.0.0</version> | |||||
<scope>provided</scope> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.osgi</groupId> | |||||
<artifactId>osgi.annotation</artifactId> | |||||
<version>6.0.1</version> | |||||
<scope>provided</scope> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.osgi</groupId> | |||||
<artifactId>osgi.cmpn</artifactId> | |||||
<version>6.0.0</version> | |||||
<scope>provided</scope> | |||||
</dependency> | |||||
</dependencies> | |||||
<build> | |||||
<plugins> | |||||
<plugin> | |||||
<groupId>biz.aQute.bnd</groupId> | |||||
<artifactId>bnd-maven-plugin</artifactId> | |||||
<version>3.3.0</version> | |||||
<executions> | |||||
<execution> | |||||
<goals> | |||||
<goal>bnd-process</goal> | |||||
</goals> | |||||
</execution> | |||||
</executions> | |||||
</plugin> | |||||
<plugin> | |||||
<groupId>com.vaadin</groupId> | |||||
<artifactId>vaadin-maven-plugin</artifactId> | |||||
<version>${vaadin.plugin.version}</version> | |||||
<executions> | |||||
<execution> | |||||
<phase>process-resources</phase> | |||||
<goals> | |||||
<goal>compile-theme</goal> | |||||
</goals> | |||||
</execution> | |||||
</executions> | |||||
</plugin> | |||||
<plugin> | |||||
<groupId>org.apache.maven.plugins</groupId> | |||||
<artifactId>maven-jar-plugin</artifactId> | |||||
<version>3.0.2</version> | |||||
<configuration> | |||||
<archive> | |||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> | |||||
</archive> | |||||
</configuration> | |||||
</plugin> | |||||
</plugins> | |||||
</build> | |||||
<profiles> | |||||
<profile> | |||||
<!-- Vaadin pre-release repositories --> | |||||
<id>vaadin-prerelease</id> | |||||
<activation> | |||||
<activeByDefault>true</activeByDefault> | |||||
</activation> | |||||
<repositories> | |||||
<repository> | |||||
<id>vaadin-prereleases</id> | |||||
<url>http://maven.vaadin.com/vaadin-prereleases</url> | |||||
</repository> | |||||
<repository> | |||||
<id>vaadin-snapshots</id> | |||||
<url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url> | |||||
<releases> | |||||
<enabled>false</enabled> | |||||
</releases> | |||||
<snapshots> | |||||
<enabled>true</enabled> | |||||
</snapshots> | |||||
</repository> | |||||
</repositories> | |||||
<pluginRepositories> | |||||
<pluginRepository> | |||||
<id>vaadin-prereleases</id> | |||||
<url>http://maven.vaadin.com/vaadin-prereleases</url> | |||||
</pluginRepository> | |||||
<pluginRepository> | |||||
<id>vaadin-snapshots</id> | |||||
<url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url> | |||||
<releases> | |||||
<enabled>false</enabled> | |||||
</releases> | |||||
<snapshots> | |||||
<enabled>true</enabled> | |||||
</snapshots> | |||||
</pluginRepository> | |||||
</pluginRepositories> | |||||
</profile> | |||||
</profiles> | |||||
</project> |
package com.vaadin.test.osgi.myapplication; | |||||
import javax.servlet.annotation.WebServlet; | |||||
import com.vaadin.annotations.Theme; | |||||
import org.osgi.service.component.annotations.Component; | |||||
import com.vaadin.annotations.VaadinServletConfiguration; | |||||
import com.vaadin.server.VaadinRequest; | |||||
import com.vaadin.server.VaadinServlet; | |||||
import com.vaadin.ui.Button; | |||||
import com.vaadin.ui.Label; | |||||
import com.vaadin.ui.TextField; | |||||
import com.vaadin.ui.UI; | |||||
import com.vaadin.ui.VerticalLayout; | |||||
public class MyUI extends UI { | |||||
@Override | |||||
protected void init(VaadinRequest vaadinRequest) { | |||||
final VerticalLayout layout = new VerticalLayout(); | |||||
final TextField name = new TextField(); | |||||
name.setCaption("Type your name here:"); | |||||
Button button = new Button("Click Me"); | |||||
button.addClickListener(e -> { | |||||
layout.addComponent(new Label("Thanks " + name.getValue() + ", it works!")); | |||||
}); | |||||
layout.addComponents(name, button); | |||||
setContent(layout); | |||||
} | |||||
@Component(service = VaadinServlet.class) | |||||
@WebServlet(urlPatterns = "/myapp2/*", name = "MyUIServlet", asyncSupported = true) | |||||
@VaadinServletConfiguration(ui = MyUI.class, productionMode = false) | |||||
public static class MyUIServlet extends VaadinServlet { | |||||
} | |||||
} |