Grunt task failing from gradle task (works from command line)

(Karl Krasnowsky) #1
Gradle 2.13

Build time:   2016-04-25 04:10:10 UTC
Build number: none
Revision:     3b427b1481e46232107303c90be7b05079b05b1c

Groovy:       2.4.4
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          1.8.0_74 (Oracle Corporation 25.74-b02)
OS:           Windows 7 6.1 amd64

This morning’s challenge. My compass task is failing from gradle task while seems fine from a console execution.
The task looks like this:

// compile the SASS and Sprites
task compileCSS(type:Exec, dependsOn: updateGrunt) {
	commandLine 'grunt', 'compass'

with the debug dump like this:

10:55:23.969 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTING
10:55:23.969 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Waiting until process started: command 'grunt'.
10:55:23.990 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: FAILED
10:55:23.990 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Process 'command 'grunt'' finished with exit value -1 (state: FAILED)
10:55:23.990 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':compileCSS'
10:55:23.990 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :compileCSS FAILED
10:55:23.991 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :compileCSS (Thread[main,5,main]) completed. Took 0.024 secs.
10:55:23.991 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[main,5,main]] finished, busy: 7.366 secs, idle: 0.0 secs
10:55:23.998 [ERROR] [org.gradle.BuildExceptionReporter]
10:55:23.998 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
10:55:23.998 [ERROR] [org.gradle.BuildExceptionReporter]
10:55:23.998 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
10:55:23.998 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':compileCSS'.
10:55:23.998 [ERROR] [org.gradle.BuildExceptionReporter] > A problem occurred starting process 'command 'grunt''

while running this:

$> grunt compass

directly from command line works fine. What can I do to determine the culprit? It looks like gradle is having an issue locating the grunt executable?

(Karl Krasnowsky) #2

Ack… darn windows. This was exactly the same issue I had with the npm tasks not using npm.cmd on a windows system. Have to do a conditional check for the OS and if windows use grunt.cmd and not grunt as the executable. Sorry for the wasted bandwidth.