Search code examples
htmlmavenbuildvaadinvaadin8

Vaadin Maven Build Properties in HTML file


I am using Vaadin 8 with Custom Layout which includes About.html file. This file contains buildId and Version information like below.

aboutview.html

<p>
    Version: ${buildVersion}<br /> Build id: ${buildId}<br />
</p>

myui/pom.xml file

<properties>
    <maven.build.timestamp.format>yyyyMMdd HHmm</maven.build.timestamp.format>
    <buildTimestamp>${maven.build.timestamp}</buildTimestamp>
    <buildVersion>2.0.0</buildVersion>
    <buildId>${buildTimestamp}</buildId>
</properties>
org.apache.maven.plugins maven-war-plugin true WEB-INF/classes/VAADIN/gwt-unitCache/, WEB-INF/classes/VAADIN/widgetsets/WEB-INF/

                <resources>
                    <resource>
                        <directory>src/main/webapp/VAADIN/themes/abstheme/layouts</directory>
                        <includes>
                            <include>aboutview.html</include>
                        </includes>
                        <filtering>true</filtering>
                    </resource>
                </resources>

            </configuration>
        </plugin></plugins></build>

How do I make sure, the properties values are available in aboutview.html once deployed in Tomcat Server?

TIA


Solution

  • According to this documentation, https://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html, you can create a "resource2" folder at the root of your project and place your file there.

    Then, in your pom.xml, you would add the following configuration

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <webResources>
                        <resource>
                            <directory>resource2</directory>
                            <targetPath>VAADIN/themes/abstheme/layout</targetPath>
                            <filtering>true</filtering>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>