Wednesday, November 4, 2020

Re: How to pass a build number to a gwt app?

I want to share solution for gradle based project. 
This solution allows to get any build's properties on client/server.

1) Add to build.gradle
task createProperties(dependsOn: processResources) {
doLast {
 new File("$buildDir/resources/main/yourmodule/shared/").withWriter { w ->
  Properties p = new Properties()
  p['version'] = project.version.toString() w, null

classes {
  dependsOn createProperties
2) Add

package yourmodule.shared;
public interface IVersion extends Constants {
   String version();

3) Add to your code
public static final IVersion versionResource = GWT.create(IVersion.class);
4) Get version value on client side:
5) Get version on server side:
InputStream stream = this.getClass().getResourceAsStream("/yourmodule/shared/");
InputStreamReader readerIs;
try {
  readerIs = new InputStreamReader(stream, "UTF-8");
  messageInstance = new PropertyResourceBundle(readerIs);
} catch (Exception e) {

вторник, 13 марта 2018 г. в 13:12:30 UTC+4, Bruno Salmon:
Thanks Thomas, I'm using GWT 2.8.2 so I tried your first suggestion and it works :-)

I just declared the property in my gwt.xml module file:

<define-configuration-property name="build.number" is_multi_valued="false"/>

 and set its value (with the maven property which is set by Jenkins) when calling your plugin in the configuation section: 


Then System.getProperty("build.number") returns the expected value :-)

Thank you

On Monday, 12 March 2018 23:27:17 UTC+1, Thomas Broyer wrote:
Easiest with recent GWT version would be to declare a <configuration-property>, get it using System.getProperty(), and set it with --property.

With older versions, use Maven filtering on a properties file you use with a; or have a look at Mojo's Java template plugin.

You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

No comments:

Post a Comment