Skip to content

Instantly share code, notes, and snippets.

@bbarker
Last active August 29, 2015 14:13
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 bbarker/c73ecf257bca966c1efd to your computer and use it in GitHub Desktop.
Save bbarker/c73ecf257bca966c1efd to your computer and use it in GitHub Desktop.
A build.gradle script that will wrap a generic makefile.
//
// Author: Brandon Barker, January 2015
//
// Copy this Makefile wrapper in to a project directory.
// Name it 'build.gradle'
// You should then be able to use Java IDEs with Gradle
// support to build makefile related projects. You may
// want to adjust your .gitignore to include the following:
//
// *.iml
// .gradle
// .idea
// gradle
// gradlew
// gradlew.bat
// atlassian-ide-plugin.xml
apply plugin: 'java'
sourceCompatibility = 1.5
version = '1.0'
repositories {
mavenCentral()
}
apply plugin: 'idea' // '' for creating an IntelliJ project
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
}
ext {
taskLen = project.gradle.startParameter.taskNames.size()
}
task baseNull {
println "Gradle finished."
}
def myNextTask(Integer i) {
if (i > 0) {
return "${project.gradle.startParameter.taskNames[i - 1]}"
} else {
return "baseNull"
}
}
taskLen.times { i ->
task "${project.gradle.startParameter.taskNames[i]}" (
type: MyExternTask,
dependsOn: myNextTask(i)) {
mycmdln = "make ${project.gradle.startParameter.taskNames[i]}"
}
}
// Need to include this somehow, so as to avoid copying it each time
// (like atsmake-pre, etc.)
/* ****** ****** */
class \
MyExternTask
extends DefaultTask
{
//
def mycmdln
//
def OSName
def CYGHOME = System.getenv('CYGHOME')
def SHELL = ''
//
@TaskAction
def myrun()
{
OSName = System.getProperty("os.name")
//
if (OSName.startsWith("Windows")) {
if (CYGHOME != null) {
if (!File(CYGHOME).isDirectory()) {
CYGHOME = "C:\\cygwin64"
}
} else {
CYGHOME = "C:\\cygwin64"
}
// For now need to use Cygwin
// Probably should use `cygpath` in the future for lower chance of breaking.
SHELL = "${CYGHOME}\\bin\\bash"
mycmdln = "${SHELL} -l -c 'cd \"${project.projectDir}\"; ${mycmdln}'"
}
project.exec
{
commandLine = mycmdln.split().toList()
}
}
//
} // end of [MyExternTask]
/* ****** ****** */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment