srs / gradle-node-plugin

Gradle plugin for integrating NodeJS in your build. :rocket:
Apache License 2.0
866 stars 211 forks source link

support for Gradle incremental builds #252

Open scphantm opened 7 years ago

scphantm commented 7 years ago

Not sure if im missing something or not, but my JS project is a subproject of a much larger system. there are 5 other projects in the same gradle build.

The problem is incrementals. gulp_build is a task in the gradlew build pipeline so it executes every time you do a task. like running the unit tests. The problem is that task takes about 20 seconds and it recompiles the JS whether anything changed or not.

what does it take to get that task to recognize the gradle incremental build system and skip if nothing in the JS changed?

https://blog.gradle.org/introducing-incremental-build-support

bsbodden commented 7 years ago

@scphantm you can use Gradle's AdHoc task with inputs/outputs set. I use yarn run to run Webpack scripts in my package.json as:

task buildVendor(type: YarnTask, group: 'build') {
  dependsOn updateDependencies
  inputs.files('src/main/webapp/root/src/vendor.js')
  outputs.files('src/main/webapp/root/dist/vendor.js')

  args = ['run', 'build-vendor']
  execOverrides {
    it.workingDir = 'src/main/webapp'
  }
}

During the build I get:

:my-app:buildVendor UP-TO-DATE

My package.json uses Workspaces (https://yarnpkg.com/en/docs/workspaces) but that's irrelevant:

{
  "private": true,
  "workspaces": [
    "root"
  ],
  "scripts": {
    "build-root": "webpack --config root/webpack/webpack.config.js",
    "build-vendor": "webpack --config root/webpack/webpack.vendor.config.js"
  }
}