<!--
  ~ Copyright 2009 the original author or authors.
  ~
  ~ Licensed 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
  ~
  ~      http://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.
  -->
<chapter id="web_project_tutorial">
    <title>Web Application Quickstart</title>

    <note>
        <para>This chapter is a work in progress.</para>
    </note>

    <para>This chapter introduces some of the Gradle's support for web applications. Gradle provides two plugins for web
        application development: the War plugin and the Jetty plugin. The War plugin extends the Java plugin to build a
        WAR file for your project. The Jetty plugin extends the War plugin to allow you to deploy your web application
        to an embedded Jetty web container.
    </para>

    <section>
        <title>Building a WAR file</title>
        <para>To build a WAR file, you apply the War plugin to your project:</para>
        <sample id="webQuickstart" dir="webApplication/quickstart" includeLocation="true" title="War plugin">
            <sourcefile file="build.gradle" snippet="use-war-plugin"/>
        </sample>
        <para>This also applies the Java plugin to your project. Running <userinput>gradle build</userinput> will compile,
            test and WAR your project. Gradle will look for the source files to include in the WAR file in
            <filename>src/main/webapp</filename>. Your compiled classes, and their runtime dependencies are also
            included in the WAR file.
        </para>
        <tip><title>Groovy web applications</title><para>You can combine multiple plugins in a single project, so you
            can use the War and Groovy plugins together to build a Groovy based web application. The appropriate groovy
            libraries will be added to the WAR file for you.</para></tip>
    </section>

    <section>
        <title>Running your web application</title>
        <para>To run your web application, you apply the Jetty plugin to your project:</para>
        <sample id="webQuickstart" dir="webApplication/quickstart" title="Running web application with Jetty plugin">
            <sourcefile file="build.gradle" snippet="use-jetty-plugin"/>
        </sample>
        <para>This also applies the War plugin to your project. Running <userinput>gradle jettyRun</userinput> will
            run your web application in an embedded Jetty web container. Running <userinput>gradle jettyRunWar</userinput>
            will build the WAR file, and then run it in an embedded web container.
        </para>
        <para>TODO: which url, configure port, uses source files in place and can edit your files and reload.</para>
    </section>

    <section>
        <title>Summary</title>
        <para>You can find out more about the War plugin in <xref linkend="war_plugin"/> and the Jetty plugin in
            <xref linkend="jetty_plugin"/>. You can find more sample Java projects in the
            <filename>samples/webApplication</filename> directory in the Gradle distribution.
        </para>
    </section>
</chapter>
