I want to run two webapps created by the same Gradle project into a Jetty server. Let's call these two webapps "ninja" and "warrior".
Both webapps are very similar, they only differ in the application-context file (referenced in the web.xml file) and resources.
In order to deploy them, these two options are accepted:
http://www.example.com:8080/app (ninja webapp) http://www.example.com:8081/app (warrior webapp)
http://www.example.com:8080/ninja_app http://www.example.com:8080/warrior_app
Having one or two instances of Jetty should be ok for this project.
This is my project layout:
/src/main/java /src/main/resources /src/main/webapp (ninja webapp) /src/main/webapp-warrior
First question: How to create two war files with Gradle?
Second question: How to deploy the two war files in the Jetty Server with Gradle?
Please have a look at Gretty gradle plugin: https://github.com/akhikhl/gretty
It supports multiple web-apps out of the box. It helps you to:
Additionally you can:
There is a lot of documentation helping with everything: http://akhikhl.github.io/gretty-doc/
Disclosure: I am author of Gretty plugin.
Happy coding :)
If you don't want to create two different projects, you may want to create two different gradle profiles, using the apply from: feature from Gradle.
For each webapp instance, ninja and warrior, you must create a script file with all the information specific for the profile.
In these new gradle build files, ninja-profile.gradle and warrior-profile.gradle, you can set the specific configurations that differ from ninja to warrior, which in this case could be:
In your "main" build file you define everything that is common for all profile and build needs, plus you add the following line:
apply from: "${profile}-profile.gradle"
When you run Gradle you can pass the name of the profile using the -P option:
$ gradle -Pprofile=ninja tasks
or
$ gradle -Pprofile=warrior tasks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With