////
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
////


== war



=== Purpose


The `war` command creates a Web Application Archive (WAR) file which can be deployed on any Java EE compliant application server.


=== Examples


[source,groovy]
----
grails war
grails test war
grails -Dgrails.env=staging war
----


=== Description


Usage:
[source,groovy]
----
grails <<environment>>* war <<arguments>>*
----


By default the `war` command creates a web application archive (WAR) file using the application name and version number. The `war` command is different from most commands since it runs in the production environment by default instead of development, but like any script the environment can be specified using the standard convention:

[source,groovy]
----
grails test war
grails dev war
grails prod war
----

You can also specify a custom environment:

[source,groovy]
----
grails -Dgrails.env=UAT war
----

Once the WAR has been created you can deploy it to your container using its standard WAR deployment process.

NOTE: Grails 2.x `war` command allowed you to supply the argument `nojars` - which packaged the WAR with no jar files. In Grails 3.x, this argument is no longer available. Instead, you may use Gradle capabilities to generate a WAR without jar files. One option would be to set your dependencies as `providedCompile` and `providedRuntime`. Those two configurations have the same scope as the respective compile and runtime configurations, except that they are not added to the WAR archive. Check https://docs.gradle.org/current/userguide/war_plugin.html[Gradle WAR Plugin] documentation for more information.
