Search code examples
angularjsgradlegulpbuild.gradleyargs

gradle not passing args to gulp with extended use options


Using the following Gradle gulp plugin which simply executes the gulp task from a gradle task via a simple naming convention gulp_<task name>

In the extended options on the docs : Gradle gulp plugin extended docs it demonstrates the following:

task gulpBuildWithOpts(type: GulpTask) {
  args = ["build", "arg1", "arg2"]
}

In my standard build task executed by gradle like so:

// runs "gulp build" as part of your gradle build
bootRepackage.dependsOn gulpBuildWithOpts

task gulpBuildWithOpts(type: GulpTask) {
  args = ["build", "--env prod", "--buildType gradle"]
}

The following is executed and built, however the args are ignored, gulp never picks them up. The args should be handled by Yargs command line parser

If I run direct with gulp (like below) then this works fine, so why am I getting my args ignored when ran from gradle?

 gulp build --env dev --buildType gulp

NOTE - App layout is Springboot / AngularJS (^1.5) if you're wondering about choice of tooling.


Solution

  • You need to pass those options in separately:

    task gulpBuildWithOpts(type: GulpTask) {
      args = ["build", "--env", "prod", "--buildType", "gradle"]
    }
    

    Otherwise "--env prod" is interpreted by yargs as a single option named env prod, instead of an option named env with an argument of prod.