Skip to content

Commit

Permalink
Added support for specifying an output directory not just an output file
Browse files Browse the repository at this point in the history
Cleaned up the boolean logic for when out and dir args are added to command line
  • Loading branch information
boardbloke committed Aug 22, 2013
1 parent ddf5e1d commit edaab6a
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions src/main/groovy/com/eriwen/gradle/js/tasks/RequireJsTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
package com.eriwen.gradle.js.tasks

import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
import com.eriwen.gradle.js.ResourceUtil
import com.eriwen.gradle.js.RhinoExec
Expand All @@ -28,12 +30,16 @@ class RequireJsTask extends SourceTask {
private static final ResourceUtil RESOURCE_UTIL = new ResourceUtil()
private final RhinoExec rhino = new RhinoExec(project)

@OutputFile def dest
@Input def ignoreExitCode = false
@OutputDirectory
@Optional
def destDir

File getDest() {
project.file(dest)
}
@OutputFile
@Optional
def dest

@Input
def ignoreExitCode = false

@TaskAction
def run() {
Expand All @@ -47,17 +53,17 @@ class RequireJsTask extends SourceTask {
args.add("${project.requirejs.buildprofile.canonicalPath}")
}

def outAdded = false
if (!options.containsKey("out")) {
args.add("out=${getDest().canonicalPath}")
outAdded = true
if (destDir) {
args.add("dir=${ project.file(destDir).canonicalPath}")
}
if (dest) {
args.add("out=${ project.file(dest).canonicalPath}")
}

options.each() { key, value ->
logger.debug("${key} == ${value}")
if (key.equalsIgnoreCase("out") & !outAdded) {
args.add("out=${getDest().canonicalPath}")
outAdded = true
} else {
logger.debug("${key} == ${options[value]}")
def keyAlreadyAdded = (key.equalsIgnoreCase("out") && dest) || (key.equalsIgnoreCase("dir") && destDir)
if (!keyAlreadyAdded) {
args.add("${key}=${value}")
}
}
Expand Down

0 comments on commit edaab6a

Please sign in to comment.