Reputation:
How do I create a grails war file so that it doesn't have the version number
(e.g. foo-0.1.war)
attached to the end when I execute the 'grails war' command?
Upvotes: 29
Views: 19113
Reputation: 684
I am kind of late to the party... but anyway:
I think the reason behind removing the version number is to eliminate the need to rename the war file so it deploys on "correct" context path /appName. If that's the case then a better option is to use a versioned war filename so you can deploy multiple versions at the same time on tomcat using the following naming pattern in grails-app/conf/BuildConfig.groovy:
grails.project.war.file = "target/${appName}##${appVersion}.war"
As explained in http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Parallel_deployment
This method applies to wars in general, not only grails' wars.
Upvotes: 0
Reputation: 5465
Grails 3.x has switched to gradle and uses the war plugin. You can just specify name like this in the build.gradle
file:
war {
archiveName 'foo.war'
}
Upvotes: 4
Reputation: 15265
I think you can specify the war name in the war command.
grails war foo.war
Also check the latest Grails documentation for where to set this as a configuration option. See the other answers for details.
Upvotes: 34
Reputation: 1854
In case anybody comes upon this article and is using Grails 1.3.x, the configuration option has changed from grails.war.destFile
in Config.groovy
to being grails.project.war.file
in BuildConfig.groovy
.
Also the file name is relative to the project workspace, so it should have a value like:
grails.project.war.file = "target/${appName}.war"
This is according to the latest Grails documentation.
Upvotes: 43
Reputation:
Rolling up the other excellent answers. There are several options:
Explicitly set it on the command line: grails war foo.war
Set the app.version
property to empty in application.properties will cause the war to be named foo.war
.
Explicitly set the name of the war using the grails.war.destFile
property in Config.groovy
Upvotes: 5
Reputation:
Another way to generate war files without version number is to keep the property, app.version, empty in the application.properties
Upvotes: 1
Reputation: 13357
From the Grails Documentation, Chapter 17, Deployment
There are also many ways in which you can customise the WAR file that is created. For example, you can specify a path (either absolute or relative) to the command that instructs it where to place the file and what name to give it:
grails war /opt/java/tomcat-5.5.24/foobar.war
Alternatively, you can add a line to Config.groovy that changes the default location and filename:
grails.war.destFile = "foobar-prod.war"
Of course, any command line argument that you provide overrides this setting.
Upvotes: 10