ProjectA |-- ProjectB \-- ProjectC
Create three empty folders: ProjectA, ProjectB and ProjectC, so that folder tree looks like this:
ProjectA |-- ProjectB \-- ProjectC
Create file "ProjectA/settings.gradle", insert code:
include 'ProjectB', 'ProjectC'
Explanation: we organize multi-project setup, so that multiple web-apps can be started/stopped by gretty plugin.
Create file "ProjectA/build.gradle", insert code:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.gretty:gretty:+'
}
}
apply plugin: 'org.gretty'
Create file "ProjectA/ProjectB/build.gradle", insert code:
apply plugin: 'org.gretty'
Create file "ProjectA/ProjectC/build.gradle", insert code:
apply plugin: 'org.gretty'
Done! Now you can run multiple web-apps by running the following command in ProjectA:
gradle farmRun
Expected output:
Jetty 9.2.1.v20140609 started. :ProjectB runs at the address http://localhost:8080/ProjectB :ProjectC runs at the address http://localhost:8080/ProjectC Press any key to stop the jetty server.
Of course, you’ll get 404 in the browser, because web-apps don’t contain any pages. But, as soon as you add pages or/and servlets to the web-apps, things will get real.
Now explanation on the details of what we just did. We defined three gradle projects, all facilitated with gretty plugin.
The projects ProjectB and ProjectC are usual web-apps, potentially with src/main/webapp, configuration files, servlets etc.etc.
The project ProjectA is special. It defines farm - logical group of web-apps that should run together.
By default farm automatically adds all subprojects of the farm project, which are facilitated with gretty plugin, to web-apps list. On the next page you’ll see how you can control, which projects are added to a farm.
Gretty plugin also defines distinct set of tasks for running farms: farmRun, farmRunDebug, farmRunWar, farmRunWarDebug, etc. (see complete list of farm tasks here).
See also: Multiple web-apps.