假设我有两个项目。 CompanyApp
和CompanyVaadinThemes
。
CompanyApp是正常的Vaadin 7.7.3应用程序。 CompanyVaadinThemesis只是将Vaadin 7.7.3主题编译成一个jar。
CompanyVaadinThemes.jar
source/main/resources/VAADIN/themes/mytheme
mytheme.scss
styles.scss
...
CompanyApp.war
pom.xml
...
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-themes</artifactId>
<version>${vaadin.version}</version>
</dependency>
<dependency>
<groupId>com.company</groupId>
<artifactId>company-vaadin-themes</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
...
UI.java
@SpringUI
@Theme("mytheme")
public class CompanyUI extends UI {
但是,我似乎无法弄清楚如何进行这项工作。如果我将实际代码从CompanyVaadinThemes.jar复制到主CompanyApp,一切都很好。我可以使用“ mytheme”,“ valo”等
但是我想将实际主题保留在一个单独的项目中,以便将来的项目可以简单地将其添加为依赖项。
这是CompanyVaadinThemes的pom:
<?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>com.company</groupId>
<artifactId>company-vaadin-themes</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<vaadin.version>7.7.3</vaadin.version>
<vaadin.theme>mytheme</vaadin.theme>
<vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>
</properties>
<repositories>
<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
<repository>
<id>com-vaadin-prereleases</id>
<url>https://maven.vaadin.com/vaadin-prereleases</url>
</repository>
</repositories>
<dependencies>
<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>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.version}</version>
</plugin>
</plugins>
</build>
</project>
最佳答案
主题中的VAADIN
文件夹应位于jar文件的根目录中:
VAADIN/themes/mytheme
mytheme.scss
styles.scss