diff -x '*.svn*' -r -uN trunk/src/docs/userguide/warPlugin.tex /home/phil/downloads/svn/gradle-core/trunk/src/docs/userguide/warPlugin.tex --- trunk/src/docs/userguide/warPlugin.tex 2008-10-13 12:17:26.000000000 +0100 +++ /home/phil/downloads/svn/gradle-core/trunk/src/docs/userguide/warPlugin.tex 2008-10-13 12:08:22.000000000 +0100 @@ -21,6 +21,84 @@ % section customizing (end) \section{Eclipse WTP} % (fold) \label{sec:eclipse_wtp} -\href{\API tasks/ide/eclipse/EclipseWtp.html}{org.gradle.api.tasks.ide.eclipse.EclipseWtp} has a default instance with the name \texttt{eclipseWtp}. It generates a \texttt{.settings/org.eclipse.wst.common.component} file. +\href{\API tasks/ide/eclipse/EclipseWtp.html}{org.gradle.api.tasks.ide.eclipse.EclipseWtp} has a default instance with the name \texttt{eclipseWtp}. It generates the configuration files required to make a project function in Eclipse WTP. This task supports simple standalone webapp projects as well as more complex multi module projects. Here is an example of a multi module WTP project. +\\ + +We have the following project tree\footnote{F means File and D means Directory}. This is a multi-project build with a root project \texttt{wtp-project} and two subprojects \texttt{webapp} and \texttt{library}. + +\begin{minipage}[t]{7cm} +\begin{Verbatim}[frame=single,label=Project Tree] +D- wtp-project + F- build.gradle + F- settings.gradle + D- library + -F build.gradle + -F .... + D- webapp + -F build.gradle + -F .... +\end{Verbatim} +\end{minipage} +\\ +\\ +\noindent We wish to have the \texttt{webapp} project deployable in Eclipse WTP and make use of code in \texttt{library}. + +\noindent The buildscript in \texttt{webapp} is as follows: + +\codeInput{../../samples/wtp-project/webapp/build.gradle} + +\noindent The important declarations are: + +\begin{Verbatim}[frame=single] +eclipseWtp { + warResourceMappings = [["src/main/webapp"], "/WEB-INF/classes" : ["src/main/java"]] +} +\end{Verbatim} + +\noindent The \texttt{warResourceMappings} property is a Map, with the value being a location of the webapp's path and the key being a list of directories in the source tree. In our example, our static webapplication files (JSP's, images) are kept in the src/main/webapp directory. At deployment/runtime, the web server expects to find these files under the webapp root directory, so we map the source folder \texttt{src/main/conf} to \textttt{"/"}. + +\begin{Verbatim}[frame=single] +eclipseProject { + projectType = ProjectType.WTP_WEBAPP +} +\end{Verbatim} + +\noindent This tells Gradle that our eclipse project is a WTP web application. + +\begin{Verbatim}[frame=single] +dependencies { + compile project(":library"); +} +\end{Verbatim} + +\noindent We wish to make use of code shared in our library sibling project. +\\ +\noindent In the \texttt{library} project, the build script is: + +\codeInput{../../samples/wtp-project/library/build.gradle} + +\noindent There is just a single vital entry here: + +\begin{Verbatim}[frame=single] +eclipseProject { + projectType = ProjectType.WTP_MODULE +} +\end{Verbatim} + +\noindent This tells Gradle that the \texttt{library} sibling project is an Eclispe WTP module project. +\\ +For these projects to work in eclipse we have to generate the required project settings files. In the +root of the parent project, invoke: + +\begin{Verbatim}[frame=single] +gradle eclipse +\end{Verbatim} + +\noindent In the library sub project, invoke: + +\begin{Verbatim}[frame=single] +gradle eclipseWtpModule +\end{Verbatim} + % section eclipse_wtp (end) -% chapter the_war_plugin (end) \ No newline at end of file +% chapter the_war_plugin (end) diff -x '*.svn*' -r -uN trunk/src/samples/wtp-project/build.gradle /home/phil/downloads/svn/gradle-core/trunk/src/samples/wtp-project/build.gradle --- trunk/src/samples/wtp-project/build.gradle 1970-01-01 01:00:00.000000000 +0100 +++ /home/phil/downloads/svn/gradle-core/trunk/src/samples/wtp-project/build.gradle 2008-10-13 11:06:00.000000000 +0100 @@ -0,0 +1,3 @@ +group = 'gradle' +version = '1.0' + diff -x '*.svn*' -r -uN trunk/src/samples/wtp-project/library/build.gradle /home/phil/downloads/svn/gradle-core/trunk/src/samples/wtp-project/library/build.gradle --- trunk/src/samples/wtp-project/library/build.gradle 1970-01-01 01:00:00.000000000 +0100 +++ /home/phil/downloads/svn/gradle-core/trunk/src/samples/wtp-project/library/build.gradle 2008-10-13 11:06:06.000000000 +0100 @@ -0,0 +1,10 @@ +import org.gradle.api.tasks.ide.eclipse.ProjectType; + +usePlugin('java') + +targetCompatibility = '1.5' +sourceCompatibility = '1.5' + +eclipseProject { + projectType = ProjectType.WTP_MODULE +} diff -x '*.svn*' -r -uN trunk/src/samples/wtp-project/library/src/main/java/org/gradle/eclipsewtp/TestLibraryClass.java /home/phil/downloads/svn/gradle-core/trunk/src/samples/wtp-project/library/src/main/java/org/gradle/eclipsewtp/TestLibraryClass.java --- trunk/src/samples/wtp-project/library/src/main/java/org/gradle/eclipsewtp/TestLibraryClass.java 1970-01-01 01:00:00.000000000 +0100 +++ /home/phil/downloads/svn/gradle-core/trunk/src/samples/wtp-project/library/src/main/java/org/gradle/eclipsewtp/TestLibraryClass.java 2008-10-13 11:18:27.000000000 +0100 @@ -0,0 +1,11 @@ +package org.gradle.eclipsewtp; + +public class TestLibraryClass +{ + + public String getHello() + { + return "Hello from " + this.getClass().getName() + "!"; + } + +} diff -x '*.svn*' -r -uN trunk/src/samples/wtp-project/settings.gradle /home/phil/downloads/svn/gradle-core/trunk/src/samples/wtp-project/settings.gradle --- trunk/src/samples/wtp-project/settings.gradle 1970-01-01 01:00:00.000000000 +0100 +++ /home/phil/downloads/svn/gradle-core/trunk/src/samples/wtp-project/settings.gradle 2008-10-13 10:59:55.000000000 +0100 @@ -0,0 +1 @@ +include 'webapp', 'library' diff -x '*.svn*' -r -uN trunk/src/samples/wtp-project/webapp/build.gradle /home/phil/downloads/svn/gradle-core/trunk/src/samples/wtp-project/webapp/build.gradle --- trunk/src/samples/wtp-project/webapp/build.gradle 1970-01-01 01:00:00.000000000 +0100 +++ /home/phil/downloads/svn/gradle-core/trunk/src/samples/wtp-project/webapp/build.gradle 2008-10-13 11:21:41.000000000 +0100 @@ -0,0 +1,18 @@ +import org.gradle.api.tasks.ide.eclipse.ProjectType; + +usePlugin('war') + +targetCompatibility = '1.5' +sourceCompatibility = '1.5' + +eclipseWtp { + warResourceMappings = ["/WEB-INF" : ["src/main/conf"], "/" : ["src/main/webapp"], "/WEB-INF/classes" : ["src/main/java"]] +} + +eclipseProject { + projectType = ProjectType.WTP_WEBAPP +} + +dependencies { + compile project(":library"); +} diff -x '*.svn*' -r -uN trunk/src/samples/wtp-project/webapp/src/main/webapp/index.jsp /home/phil/downloads/svn/gradle-core/trunk/src/samples/wtp-project/webapp/src/main/webapp/index.jsp --- trunk/src/samples/wtp-project/webapp/src/main/webapp/index.jsp 1970-01-01 01:00:00.000000000 +0100 +++ /home/phil/downloads/svn/gradle-core/trunk/src/samples/wtp-project/webapp/src/main/webapp/index.jsp 2008-10-13 11:29:56.000000000 +0100 @@ -0,0 +1,17 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + +
+ +