Skip to content

Commit

Permalink
Fix multi gradle project Gruntfile.js location (fixes #31)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sten Roger Sandvik committed Jun 27, 2016
1 parent 2ce8d01 commit 12e6a4e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Version 0.13 *(not released)*
* Bumped gradle wrapper version to 2.14
* Updated plugin versions and test versions
* Using gradle-node-plugin version 0.13
* Fix multi gradle project Gruntfile.js location _(mhmxs)_
* ...

Version 0.12 *(2016-03-10)*
Expand Down
35 changes: 24 additions & 11 deletions src/main/groovy/com/moowork/gradle/grunt/GruntTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,46 @@ class GruntTask
"Grunt-CLI not installed in node_modules, please first run 'gradle ${GruntPlugin.GRUNT_INSTALL_NAME}'" )
}

// If colors are disabled, add --no-color to args
if ( !this.project.grunt.colors ) {
def addArg = { List<?> original, def newArg ->
def tempArgs = []
tempArgs.addAll( args as List )
tempArgs.add( '--no-color' )
setArgs( tempArgs )
tempArgs.addAll( original )
tempArgs.add( newArg )
return tempArgs
}

// On multi project scenario, need to specify Gruntfile.js location
setArgs( addArg( args as List, "--gruntfile ${this.project.grunt.workDir}/Gruntfile.js" ) )

// If colors are disabled, add --no-color to args
if ( !this.project.grunt.colors )
{
setArgs( addArg( args as List, '--no-color' ) )
}

// If output should be buffered (useful when running in parallel)
// set standardOutput of ExecRunner to a buffer
def bufferedOutput
if ( this.project.grunt.bufferOutput ) {
if ( this.project.grunt.bufferOutput )
{
bufferedOutput = new ByteArrayOutputStream()
setExecOverrides({
setExecOverrides( {
it.standardOutput = bufferedOutput
})
} )
}

setWorkingDir( this.project.grunt.workDir )
setScript( localGrunt )

// If the exec fails, make sure to still print output
try {
try
{
super.exec()
} finally {
}
finally
{
// If we were buffering output, print it
if ( this.project.grunt.bufferOutput ) {
if ( this.project.grunt.bufferOutput )
{
println "Output from ${this.project.grunt.workDir}/Gruntfile.js"
println bufferedOutput.toString()
}
Expand Down

0 comments on commit 12e6a4e

Please sign in to comment.