Configuring Gulp

Support for working with Gulp is available via the Gulp plugin (org.ysb33r.nodejs.gulp). It adds a gulp extension which is the place to configure global settings for working with Gulp.

build.gradle
gulp {
    executableByVersion('1.2.3') (1)
    gulpFile 'foo/gulpfile.js'   (2)
    requires 'foo', 'bar'        (3)
}
1 Tell Gradle where to find Gulp. The recommended approach is just to specify a version. if nothing is configured gradle will use a default version set with the plugin. See GulpExtension.GULP_DEFAULT.
2 Set the location of gulpfile.js. The default is "${project.projectDir}/gulpfile.js". This causes Gulp to change working directory to the location of this file. It does however still keep the original working directory from NPM in mind as well.
3 Add additional requires that will be passed as --requires to Gulp.

In most cases the default settings should suffice and the user will not need to configure anything extra.

Gulp users will be familiar with using task as the entity of work to be processed by the build tool. In this plugin the keyword target is used to signify a Gulp task. This is done to prevent accidental clashes with the common Gradle keyword called task.

GulpTask type

build.gradle
myGulpTask {
    target 'clean' (1)
}
1 Set the target task to execute. If nothing is configured, the default Gulp task will be executed.

In some cases the global Gulp configuration might not be suitable and per-task customisations can be done by accessing nodejs, npm and gulp extensions on the task itself. the task will always look at the local extensions first before retrieving values from the global extensions.

build.gradle
myGulpTask {
    gulp {
        gulpFile 'foo/gulpfile.js' (1)
    }
    npm {
        homeDirectory 'foo' (2)
    }
}
1 Override the location of gulpfile.js for this specific task.
2 Use a different NPM setup to run this task.

This shows the flexibility of the plugin and how behaviour can be changed to deal with very specific situations. In most cases you will not need it, but when you need to do something extraordinary, it should be able to be configured.

Change dependency group

By default, Gulp will be added to devDependencies. It is possible to override and make it a different type of dependency.

build.gradle
gulp {
    installGroup NpmDependencyGroup.OPTIONAL (1)
}
1 See NpmDependencyGroup for valid settings.