如何编写可以包含在其他Web应用程序中的Vaadin主题? [英] How to write a Vaadin theme I can include in my other webapps?
问题描述
我正在尝试创建一个简单的主题(使用Chameleon以及一些自定义的CSS和图像等).
I'm trying to create a simple theme (using Chameleon and some custom css and images, etc), which I've done.
问题是我想将其包装在一个maven项目中,并作为依赖项从其他Vaadin项目中引用,因此我可以将所有Vaadin应用程序以相同的方式进行主题设置-甚至更好地将其作为父项目的依赖项这样整个应用程序的样式都相同,我可以为不同的客户重新设置外观.
The problem is I want to wrap it up in a maven project and reference from other Vaadin projects as a dependency, so I can theme all my Vaadin apps the same way - or even better have it as a dependency of the parent project so that the whole app gets styled the same way and I can re-skin it for different customers.
我不确定如何打包和部署主题项目,以便它可以在其他项目中使用?我应该把它变成一个战争项目吗?但是其他项目如何做到"呢?他们将在自己的VAADIN/themes目录下查找主题-而不是将其复制到那里(以某种方式),我怎么能让他们引用一个副本?
I'm not sure how to package and deploy the theme project so that it will be usable from the other projects? Should I make it into a war project - but then how do the other projects 'get at it'? They'll be looking for the themes under their own VAADIN/themes directories - rather than copying it there (somehow), how could I just have them reference one single copy?
推荐答案
我遇到了同样的问题.我通过使用战争覆盖物解决了它.
I've had the same problem. I solved it by using war overlays.
我在父项目中有一个基本主题,该主题在客户端的配置项目中得到了扩展.配置项目仅将war用作运行时依赖项,并且父项目的文件被覆盖,如
I have a base theme in the parent project which is extended in clients' configuration projects. The configuration project simply uses the war as a runtime dependency and the parent project's files are overlaid, as explained here.
只需在客户的项目中添加依赖项:
Just add the dependency in the client's project:
<dependency>
<groupId>com.mygroup</groupId>
<artifactId>my-parent-project</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>war</type>
<scope>runtime</scope>
</dependency>
并将父项目的样式导入客户端主题的styles.css文件中:
and import the parent project's styles in the client's theme's styles.css file:
@import "../parent-theme/styles.css"
并添加客户的样式.
如果需要使用父项目的类,则可以在maven-war-plugin配置中将attachClasses
属性设置为true,如果需要调试,还可以使用maven-source-plugin附加源. :
If you need to use the classes of the parent project, you can set the attachClasses
property true in the maven-war-plugin configuration and also attach the sources by using maven-source-plugin if you need them for debugging:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<attachClasses>true</attachClasses>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<attach>true</attach>
</configuration>
</plugin>
并将它们包含在您客户的项目中:
and include them in your client's project:
<dependency>
<groupId>com.mygroup</groupId>
<artifactId>my-parent-project</artifactId>
<version>1.0.0-SNAPSHOT</version>
<classifier>classes</classifier>
<type>jar</type>
<scope>compile</scope>
</dependency>
这篇关于如何编写可以包含在其他Web应用程序中的Vaadin主题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!