Skip to content

Instantly share code, notes, and snippets.

@ysb33r
Last active December 17, 2015 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ysb33r/5554324 to your computer and use it in GitHub Desktop.
Save ysb33r/5554324 to your computer and use it in GitHub Desktop.
I am trying to wrapper a Task class in Gradle to wrap some legacy build tools i.e. GNU Make, SCons etc. This is to help migrating legacy builds to Gradle. The idea is to still call parts of the old build systems and just to collect the artifacts from them. So instead of inheriting from DefaultTask I thought it would be easier to just to extend s…
class GnuMake extends DefaultTask {
@Input
@Optional
List<String> targets
@Input
@Optional
Map<String,Object> flags = [:]
@Input
@Optional
def switches = []
@Input
@Optional
String executable
ExecResult execResult
GnuMake() {
// Can make this assume certain defaults based upon the OS
executable = executable ?: 'make'
}
@TaskAction
void exec() {
execResult = project.exec {
executable = this.executable
if(this.switches) {
args+= switches
}
if(this.targets) {
args+= targets
}
if(this.flags) {
args+= flags.collect { k,v -> "'$k=$v'" }
}
}
}
}
// This is the basic intention with an interface for calling a legacy build
task runMake( type : GnuMake ) {
targets = 'build', 'install'
flags = DESTDIR : '/path/to/somewhere', BUILDNUMBER : 1234
}
@ysb33r
Copy link
Author

ysb33r commented May 13, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment