aboutsummaryrefslogtreecommitdiff
path: root/src/main/groovy/frege/gradle/tasks/FregeNativeGen.groovy
diff options
context:
space:
mode:
authorDierk König <dierk.koenig@canoo.com>2015-11-21 10:09:31 +0100
committerDierk König <dierk.koenig@canoo.com>2015-11-21 10:09:31 +0100
commitf0807811f48c50b6a5fe7816ef48c148be9f9903 (patch)
treec61df925b637d26c95086510ee471ac861a36731 /src/main/groovy/frege/gradle/tasks/FregeNativeGen.groovy
parentfa6dce676590c83bc84d130e1241cf585f88a469 (diff)
parent73dd702743a5b4d8816e495e55c19f391669fc25 (diff)
downloadfrege-gradle-plugin-f0807811f48c50b6a5fe7816ef48c148be9f9903.tar.gz
frege-gradle-plugin-f0807811f48c50b6a5fe7816ef48c148be9f9903.tar.bz2
frege-gradle-plugin-f0807811f48c50b6a5fe7816ef48c148be9f9903.zip
Merge pull request #28 from breskeby/base-plugin
Base plugin
Diffstat (limited to 'src/main/groovy/frege/gradle/tasks/FregeNativeGen.groovy')
-rw-r--r--src/main/groovy/frege/gradle/tasks/FregeNativeGen.groovy61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/main/groovy/frege/gradle/tasks/FregeNativeGen.groovy b/src/main/groovy/frege/gradle/tasks/FregeNativeGen.groovy
new file mode 100644
index 0000000..6f51218
--- /dev/null
+++ b/src/main/groovy/frege/gradle/tasks/FregeNativeGen.groovy
@@ -0,0 +1,61 @@
+package frege.gradle.tasks
+
+import org.gradle.api.DefaultTask
+import org.gradle.api.internal.file.FileResolver
+import org.gradle.api.tasks.Input
+import org.gradle.api.tasks.InputFile
+import org.gradle.api.tasks.Optional
+import org.gradle.api.tasks.OutputFile
+import org.gradle.api.tasks.TaskAction
+
+import org.gradle.process.internal.DefaultJavaExecAction
+import org.gradle.process.internal.JavaExecAction
+
+class FregeNativeGen extends DefaultTask {
+
+ /*
+ * Example from https://github.com/Frege/frege-native-gen:
+ * java -cp /path/to/guava-15.0.jar:lib/frege-YY.jar:frege-native-gen-XX.jar frege.nativegen.Main com.google.common.collect.ImmutableCollection
+ */
+
+ // help not currently supported by native gen tool
+ Boolean help = false
+
+ @Optional
+ @InputFile
+ File typesFile = new File(project.projectDir, "types.properties")
+
+ @Input
+ String className = null
+
+ @Optional
+ @OutputFile
+ File outputFile = new File(project.buildDir, "generated/frege/NativeGenOutput.fr")
+
+
+ @TaskAction
+ void gen() {
+
+ FileResolver fileResolver = getServices().get(FileResolver.class)
+ JavaExecAction action = new DefaultJavaExecAction(fileResolver)
+ action.setMain("frege.nativegen.Main")
+ action.workingDir = project.projectDir
+ action.standardInput = System.in
+ action.standardOutput = outputFile.newOutputStream()
+ action.errorOutput = System.err
+ action.setClasspath(project.files(project.configurations.compile) + project.files("$project.buildDir/classes/main"))
+
+ def args = []
+ if (help) {
+ args << "-h"
+ } else {
+ args << className
+ args << typesFile.absolutePath
+ }
+ logger.info("Calling Frege NativeGen with args: '$args'")
+ action.args args
+ action.execute()
+ }
+
+
+}