Source

gradle-site-plugin /

Filename Size Date modified Message
src
106 B
94 B
308 B
9.9 KB
4.4 KB
2.0 KB
3.5 KB

Overview

The Site plugin is a Gradle plugin for publishing static HTML websites. It is available for use under the Apache License, Version 2.0. If you have any issues, please check the issue tracker, and if there isn't anything relevant, submit a new issue.

Distribution

The plugin is distributed via Bintray. If desired, you can use the Bintray plugin to simplify the configuration of Bintray repositories within Gradle build scripts.

Usage

To use the plugin, configure your build.gradle based the example below. See the CHANGES file for a listing of versions.

buildscript {
    repositories {
        maven {
            name = 'BintrayJCenter'
            url = 'http://jcenter.bintray.com'
        }
    }
    dependencies {
        classpath 'us.carrclan.david.gradle:gradle-site-plugin:VERSION'
    }
}
apply plugin: 'site'

Source sets

The Site plugin adds a site source set. This source set works in the same manner as with other plugins, though our interest is primarily in the resources.

Tasks

The Site plugin adds a couple tasks to your project, as shown below.

Task name Depends on Type Description
processSiteResources - Copy Copies site resources into the site resources output directory.
publishSite processSiteResources PublishSite Uploads the site resources output.

Project Layout

The Site plugin assumes the project layout shown below.

Directory Meaning
src/site/resources Site resources

Changing the project layout

You can configure the project layout by configuring the source set. Below is a brief example that changes the site resources directory to be a direct child of the project root.

build.gradle

sourceSets {
    site {
        resources {
            srcDir 'website'
        }
    }
}

Extension Properties

The Site plugin adds a site extension to the project. You can use its properties to customize the behavior of the plugin's tasks.

Property name Type Default value Description
sourceSet SourceSet sourceSets.site The source set to use for site tasks.
url String None The URL to which the site should be published.
authenticationInfo AuthenticationInfo None The authentication information with to use when publishing the site.

Configuration Example

build.gradle

site {
    url = 'sftp://ftp.example.com/joe'
    authenticationInfo {
        userName = 'joe'
        password = 'secretPassword'
    }
}

ProcessSiteResources

The Site plugin uses the Copy task for resource handling. See the Gradle User Guide for more information.

Task Property Type Default Value
srcDirs Object site.sourceSet.resources
destinationDir File site.sourceSet.output.resourceDir

PublishSite

The Site plugin uses Maven Wagon to provide site publishing capability over a number of different protocols. Currently, only the SFTP provider has been tested, though others (HTTP, FTP, SCP, WebDAV, file) may work as well.

Task Property Type Default Value
baseDir File site.sourceSet.output.resourceDir
url String site.url
authenticationInfo AuthenticationInfo site.authenticationInfo
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.