aboutsummaryrefslogtreecommitdiff
path: root/src/main/groovy/frege/gradle/FregeReplTask.groovy
diff options
context:
space:
mode:
authorDierk Koenig <dierk.koenig@canoo.com>2015-02-24 01:08:54 +0100
committerDierk Koenig <dierk.koenig@canoo.com>2015-02-24 01:08:54 +0100
commit91d37b288290b99993cdeccbca653af87dbfcad8 (patch)
tree1544d0886404c784250729c813ad15bd16914404 /src/main/groovy/frege/gradle/FregeReplTask.groovy
parentb563f27267f9fee7756284feb60797c04e6316cf (diff)
downloadfrege-gradle-plugin-91d37b288290b99993cdeccbca653af87dbfcad8.tar.gz
frege-gradle-plugin-91d37b288290b99993cdeccbca653af87dbfcad8.tar.bz2
frege-gradle-plugin-91d37b288290b99993cdeccbca653af87dbfcad8.zip
we now have two repl tasks to choose from :-)
Diffstat (limited to 'src/main/groovy/frege/gradle/FregeReplTask.groovy')
-rw-r--r--src/main/groovy/frege/gradle/FregeReplTask.groovy37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/main/groovy/frege/gradle/FregeReplTask.groovy b/src/main/groovy/frege/gradle/FregeReplTask.groovy
new file mode 100644
index 0000000..50d8026
--- /dev/null
+++ b/src/main/groovy/frege/gradle/FregeReplTask.groovy
@@ -0,0 +1,37 @@
+package frege.gradle
+
+import org.gradle.api.DefaultTask
+import org.gradle.api.internal.file.FileResolver
+import org.gradle.api.tasks.*
+import org.gradle.process.internal.DefaultJavaExecAction
+import org.gradle.process.internal.JavaExecAction
+
+import javax.management.relation.Relation
+
+class FregeReplTask extends DefaultTask {
+
+ static String DEFAULT_SRC_DIR = "src/main/frege" // TODO: should this come from a source set?
+
+ @Optional @InputDirectory
+ File sourceDir = new File(project.projectDir, DEFAULT_SRC_DIR)
+
+ @TaskAction
+ void openFregeRepl() {
+
+ if (! sourceDir.exists() ) {
+ def currentDir = new File('.')
+ logger.info "Intended source dir '${sourceDir.absolutePath}' doesn't exist. Using current dir '${currentDir.absolutePath}' ."
+ sourceDir = currentDir
+ }
+
+ FileResolver fileResolver = getServices().get(FileResolver.class)
+ JavaExecAction action = new DefaultJavaExecAction(fileResolver)
+ action.setMain("frege.repl.FregeRepl")
+ action.workingDir = sourceDir
+ action.standardInput = System.in
+ action.setClasspath(project.files(project.configurations.compile ))
+
+ action.execute()
+ }
+
+} \ No newline at end of file