Git Product home page Git Product logo

gradle-warlike-plugin's Introduction

gradle-warlike-plugin

When using the "war" plugin to make webapps, use gradle-warlike-plugin for a local server with hot reloading of classes.

Uses an embedded jetty set up to emulate a WAR environment.

Uses springloaded for hot reloading of classes.

Installing

Install as any Gradle plugin. The package is deployed to bintray/jcenter.

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath "com.augustl:gradle-warlike-plugin:0.3.5"
    }
}
apply plugin: 'com.augustl.warlike'

Running

To start the local server with hot code reloading, run the task provided by the plugin:

gradle runWarlike

This task will start the server.

Live resources

The plugin configures the classpath so that src/main/resources (and whatever you put in sourceSets.main.resources.srcDirs) is available, and build/resources/main is not. That means you can edit your resources in src/main/resources and se the changes immediately, instead of having to rebuild the project to make your changes visible. This is particularly useful if you have things like javascripts and templates on the classpath.

Manually reloading server instance

NOT IMPLEMENTED YET

Hit the enter key in the terminal where you're running the server.

This is faster than restarting the entire Gradle process.

You need this when you make changes that hot code reloading doesn't affect, such as changing web.xml.

Reloading means shutting down the embedded WAR container server. Any servlets you have will have their shutdown hooks called. If you have global state, you're responsible for tearing that down yourself if you want to. The plugin doesn't provide any hooks. Global state is bad, m'kay! One recommendation is to create a spring-context that contains all your state, and avoid global state entirely. Ensure that all your stateful beans implement teardown hooks properly, and this method o

Configuring

You can configure the runWarlike task:

runWarlike {
    port = 1234
}
port The port number to start the local web server at.

web.xml

This plugin follows the conventions of the "war" plugin. This is where you'll put web.xml:

src/main/webapp/WEB-INF/web.xml

Note that web.xml is not required. We implement Servlet 3.0 annotation based web listeners as well.

Todo

  • Make more stuff configurable. Perhaps the IP to bind to, now we just use Jetty defaults.
  • [your feature request here]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.