diff options
author | Galder Zamarreño <galder@zamarreno.com> | 2013-10-17 21:39:24 +0200 |
---|---|---|
committer | Galder Zamarreño <galder@zamarreno.com> | 2013-10-17 21:39:24 +0200 |
commit | ab07b29c22a0979ddfce1d5fde9150996e6a5345 (patch) | |
tree | 3e9ee0db0bdc6eb1c15c0a80d57b5b9e15cf3cd8 /src/main/groovy/org | |
parent | c0295b839de7c2c2a32c0e32fea7a58fd893383f (diff) | |
download | frege-gradle-plugin-ab07b29c22a0979ddfce1d5fde9150996e6a5345.tar.gz frege-gradle-plugin-ab07b29c22a0979ddfce1d5fde9150996e6a5345.tar.bz2 frege-gradle-plugin-ab07b29c22a0979ddfce1d5fde9150996e6a5345.zip |
Reshuffle to make plugin a first level project
Diffstat (limited to 'src/main/groovy/org')
-rw-r--r-- | src/main/groovy/org/gradle/frege/FregePlugin.groovy | 13 | ||||
-rw-r--r-- | src/main/groovy/org/gradle/frege/FregeTask.groovy | 77 |
2 files changed, 90 insertions, 0 deletions
diff --git a/src/main/groovy/org/gradle/frege/FregePlugin.groovy b/src/main/groovy/org/gradle/frege/FregePlugin.groovy new file mode 100644 index 0000000..93c5f26 --- /dev/null +++ b/src/main/groovy/org/gradle/frege/FregePlugin.groovy @@ -0,0 +1,13 @@ +package org.gradle.frege + +import org.gradle.api.Plugin +import org.gradle.api.Project + +class FregePlugin implements Plugin<Project> { + + void apply(Project project) { + project.apply(plugin: 'base') + project.task('compileFrege', type: FregeTask, group: 'Build') + } + +} diff --git a/src/main/groovy/org/gradle/frege/FregeTask.groovy b/src/main/groovy/org/gradle/frege/FregeTask.groovy new file mode 100644 index 0000000..26598b9 --- /dev/null +++ b/src/main/groovy/org/gradle/frege/FregeTask.groovy @@ -0,0 +1,77 @@ +package org.gradle.frege + +import org.gradle.api.DefaultTask +import org.gradle.api.GradleException +import org.gradle.api.InvalidUserDataException +import org.gradle.api.tasks.* +import org.gradle.process.internal.DefaultJavaExecAction +import org.gradle.process.internal.JavaExecAction +import org.gradle.api.internal.file.FileResolver + +class FregeTask extends DefaultTask { + + private static final FREGE_FILE_EXTENSION_PATTERN = ~/.*\.fr?$/ + + @Input boolean hints + + @Input boolean verbose + + @Input boolean inline = true + + @Input boolean make = true + + @Input boolean skipCompile + + @Input boolean includeStale + + // TODO: Find default + @OutputDirectory File outputDir = new File("build/classes") + + @TaskAction + void executeCompile() { + println "Compiling Frege to " + outputDir + + FileResolver fileResolver = getServices().get(FileResolver.class) + JavaExecAction action = new DefaultJavaExecAction(fileResolver) + action.setMain("frege.compiler.Main") + action.setClasspath(project.files(project.configurations.compile)) + + List args = [] + if (hints) + args << "-hints" + if (inline) + args << "-inline" + if (make) + args << "-make" + if (verbose) + args << "-v" + if (skipCompile) + args << "-j" + + args << "-d" + args << outputDir + + + eachFileRecurse(new File("src/main/frege")) { File file -> + if (file.name =~ FREGE_FILE_EXTENSION_PATTERN) { + args << file + } + + } + + action.args(args) + + action.execute() + } + + private static void eachFileRecurse(File dir, Closure fileProcessor) { + dir.eachFile { File file -> + if (file.directory) { + eachFileRecurse(file, fileProcessor) + } else { + fileProcessor(file) + } + } + } + +}
\ No newline at end of file |