This project provides the same functionality as the Jetty Plugin: http://www.gradle.org/docs/current/userguide/jetty_plugin.html, But JettyMulti is based on Jetty 8 and allows you to deploy multiple war in a single Jetty instance.
Features added to the jetty plugin:
- Jetty 8 embedded
- Run multiple war in a single Jetty instance
- You can utilize Servlets (in your project) with @WebServlet annotation
- Easy SSL configuration.
Also support hot deploy of declared dependents war and the project as the Jetty Plugin: http://www.gradle.org/docs/current/dsl/org.gradle.api.plugins.jetty.JettyRun.html
This plugin is designated for Gradle projects, the project layout that require this plugin is the same of war plugin: http://www.gradle.org/docs/current/userguide/war_plugin.html
- Modify build.gradle of your project and add the following lines:
apply plugin: 'java'
apply plugin: 'war'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'com.github.martins1930.gradle', name: 'JettyMulti', version: '1.2.0-RELEASE'
}
}
apply plugin: 'jettymulti'
- Configure the ports : Note: If SSL is not needed coment (or delete) jMPortSecure, jMKeyStore and jMKeyStorePassword
jettyMulti {
jMPort = 8096 ;
jMPortSecure = 8443 ;
jMKeyStore = "/opt/keystore/jetty.keystore" ;
jMKeyStorePassword = "secret" ;
jMScanInterval = 1 ;
}
- In your project folder execute the gradle task jettyMRun:
gradle jettyMRun
- Go to browser and open the project URL:
http://localhost:8096/ProjectName/
orhttps://localhost:8443/ProjectName/
Add jMDeployDeps with path to other wars to be deployed in jetty:
jettyMulti {
jMPort = 8096 ;
jMScanInterval = 1 ;
jMDeployDeps = ['/path/to/archive/App1.war', '/path/to/other/archive/App3.war']
}
When run the project with
gradle jettyMRun
, three projects will be deployed in Jetty in the following order:
- App1 - http://localhost:8096/App1
- App2 - http://localhost:8096/App2
- The project itself, if the project is called Foo then you can access http://localhost:8096/Foo
https://github.com/martins1930/samples/tree/master/gradle/Foop