Search code examples
gwtmavenuibinder

Replace version number variable in GWT UIBinder XML File


Help me to find best way for replacing version variable in my ui.xml

<gwt:HTML>
    <span>Current version: ${version}</span>
</gwt:HTML>

Can i use Maven resourse plugin? Like this:

        <resource>
            <directory>src/main/java</directory>
            <filtering>true</filtering>
            <includes>
                <include>**/*.ui.xml</include>
            </includes>
        </resource>

I think UIBinder is part of GWT client side code, and it compiled by gwt plugin. This plugin don't finds my ${version} variable and don't replace it.


Solution

  • You are correct, UIBinder templates are part of GWT client-side code and are compiled down to JavaScript.

    The only ways I can think of to expose what version your app is running are:

    1. Hard-code it somewhere in your client-side code, e.g., in your EntryPoint class, as a static final constant.
    2. Expose it from your server-side code through your hosting page and read it in your client-side code by doing something like this article suggests.
    3. Write a simple GWT generator to create a UI widget which has its code generated to display the current version. The article is a general introduction to generators.

    There may be others but those are the first ones off the top of my head, in order from least to most effort involved.