Get It
Build script snippet for use in all Gradle versions:buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.stehno.gradle:webpreview:0.3.0"
}
}
apply plugin: "com.stehno.gradle.webpreview"
Build script snippet for new, incubating, plugin mechanism introduced in Gradle 2.1:
plugins {
id "com.stehno.gradle.webpreview" version "0.3.0"
}
Configure It
To configure the Web Preview plugin, the `webPreview` extension is provided:
webPreview {
port = 0
copyUrl = true
resourceDir = file('build/web')
contextPath = '/'
}
where:
port- the web server port where content is to be served. The default is0, which will choose a random available port. This port will be displayed in the output logs on startup.resourceUrl- used to specify the directory where the web resources are to be served from. This property is required and the server will fail to start without it.copyUrl- determines whether or not the server URL is copied to the local clipboard on startup. This is handy when running locally with the random port setting.contextPath- optional root context path to be used as a prefix for all content. If not specified the server root "/" will be used.
Use It
The plugin provides two tasks:
startPreview- used to start the preview server with the configuration provided in thewebPreviewextension.previewStatus- used to display the current status of the preview server.stopPreview- used to stop the preview server when it is running in background mode.