Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

grails.project.war.file is not creating a war with the correct file name, seems to be caching previous name?

I am having trouble building my Grails 2.2.3 project from Groovy/Grails Tool Suite. The war filename is dynamic and is not always set properly. The first build will be fine, but any successive builds will have the previous filename.

I am using almost the exact technique identified by @Burt Beckwith in Grails war filename based on environment to create a war that includes the environment and date/time. So the output war should be something like myapp-1.3-TEST-2013_12_02-11_31.war or myapp-1.3-PRODUCTION-2013_12_02-12_00.war

The BuildConfig.groovy is as follows:

grails.project.war.file = "target/${appName}-${appVersion}-${grails.util.Environment.current}-${new Date().format('yyyy_MM_dd-HH_mm')}.war"

This problem does NOT exist if I build from the command line. I am using Groovy/Grails Tool Suite Version 3.3.0.Release with build ID 201307091644. Java version is 1.6. I am on a Windows 7 64 bit machine.

The first time I ever run "test war" the following is properly generated/output:

Loading Grails 2.2.3
| Configuring classpath.
| Environment set to test.....
| Packaging Grails application..
| Compiling 179 source files
Note: C:\Users\me\.grails\2.2.3\projects\myapp\plugins\cache-1.0.0\src\java\grails\plugin\cache\web\GenericResponseWrapper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
| Compiling 179 source files..
| Compiling 31 source files.....
| Compiling 66 GSP files for package [myapp]..
| Compiling 4 GSP files for package [mail]..
| Building WAR file.....
| Done creating WAR target\myapp-1.3-TEST-2013_12_02-11_31.war

The second time I run "prod war" the following is incorrectly generated/output:

Loading Grails 2.2.3
| Environment set to production.....
| Packaging Grails application.....
| Compiling 66 GSP files for package [myapp]..
| Compiling 4 GSP files for package [mail]..
| Building WAR file.....
| Done creating WAR target\myapp-1.3-TEST-2013_12_02-11_31.war

The environment and date/time is incorrect! A new war is generated in place of the previous one, but with the previously environment and previous date! Inspecting the war reveals that is a production war was generated (despite the filename). Specifically I checked out the web.xml and observed that the display-name has a value of /myapp-production-1.3.

As previously mentioned this issue is not observed via the command line:

C:\data\GGTSWorkspace\myapp>grails prod war
| Done creating WAR target\myapp-1.3-production-2013_12_02-10_36.war

C:\data\GGTSWorkspace\myapp>grails test war
| Done creating WAR target\myapp-1.3-test-2013_12_02-10_41.war

I have also created a new dummy project and observed the issue in this new dummy project as well, so I currently believe this is an GGTS issue/setting.

Is anyone aware of a configuration change to fix this issue?

UPDATE #1: I have also been able to reproduce this issue using the latest GGTS (3.4.0) on Windows and a co-worker has been able to reproduce the issue on Mac.

UPDATE #2: I have discovered that this issue did not exist when using GGTS 3.1.0 (based on Eclipse 4.2). The issue is present on at least GGTS 3.3.0 (based on Eclipse 4.3) and up.

Thanks in advance!

like image 734
bigfatony Avatar asked Oct 21 '22 19:10

bigfatony


1 Answers

I believe this occurs when the setting "Groovy > Grails > Keep external Grails Running" is checked. Also, seems like a bug, but unchecking this resolved the issue for me.

like image 86
Chad Skinner Avatar answered Jan 02 '23 21:01

Chad Skinner