SVN version number available in compiled GWT package

I have a GWT project that has its own source managed in SVN, is packaged using Maven and has its own assemblies managed through Hudson. I want the SVN version number of the last check / assembly to be visible in the comment at the bottom of the root HTML file of the application. I don’t care where in the development process this happens!

Here are the options I got to Googled without success:

  • Can I get Hudson, after creation, to write the build / revision number to one of my output build files (namely, the HTML root file of the application) file)? I have not seen a way to do this.
  • Can I get Maven to write the SVN version number for one of my constructions output files (namely the root HTML file of the application)? I saw Maven paths by writing this to the JAR / WAR manifest file (which may be available in Java code), but I'm not sure if this works in GWT (I'm not very knowledgeable about the internal components of GWT).
  • Can I get SubVersion as a binding to pre-fix the version number for a specific file? I know that it is easy to write the version number to the file that you are editing, but not so confident in writing a completely separate file (so that it is updated with every commit, regardless of whether this commit was changed).

Does anyone have a complete, cross-cutting example of how to get any of these workers to work? I keep finding small pieces of / config code that do one part of the job, but not what I'm exactly looking for.

Thanks!

+4
source share
2 answers

You can achieve what you are looking for by combining Maven and Hudson. In this example, suppose you want the version.txt file at the root of your web application to contain a revision.

version.txt :

 ${SVN_REVISION} 

In the pom.xml project pom.xml enable filtering in the maven-war-plugin :

 <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.1</version> <configuration> <webResources> <webResource> <directory>src/main/webapp</directory> <filtering>true</filtering> <includes> <include>version.txt</include> </includes> </webResource> </webResources> </configuration> </plugin> 

Make sure Hudson is building your project. Subversion checkout, and it will set the SVN_REVISION environment SVN_REVISION for each assembly, and Maven will populate it.

+4
source

This solution is for those who continue to receive {SVN_REVISION} instead of the actual value of SVN_REVISION inside the target file .

My solution was to use filtering. However, since I wanted SVN_REVISION to appear on my html gwt app main page (as a means of "fighting" the user's cache, making sure that if we do a new build, then the user will load the last html file), I wasn not able to use the solution Jason Grater. The html file just printed {SVN_REVISION} instead of the actual value of SVN_REVISION.

So, I defined a property inside <properties> :

 <properties> ... <buildVersion>${SVN_REVISION}</buildVersion> ... </properties> 

Then I made sure that I was filtering the corresponding html file (as described in the Jason solution), and then “extracted” SVN_REVISION in the html file like this:

 <script type="text/javascript"> ... var versionIdSuffix = '?v=${buildVersion}'; .... </script> 

In a nutshell: I could not directly refer to the {SVN_REVISION} property from the html file, so I "wrapped" it through <properties> , giving maven a link to it instead.

0
source

Source: https://habr.com/ru/post/1369099/


All Articles