summaryrefslogtreecommitdiff
path: root/src/main/groovy/frege/gradle/FregeDocTask.groovy
diff options
context:
space:
mode:
authorDierk Koenig <dierk.koenig@canoo.com>2015-03-18 23:49:43 +0100
committerDierk Koenig <dierk.koenig@canoo.com>2015-03-18 23:49:43 +0100
commit99541ae62dc7e179ff9538c76a13be670b7299c0 (patch)
treee615e22aa5bdcbd0fa3e28b66c2f1f87af85c23b /src/main/groovy/frege/gradle/FregeDocTask.groovy
parentc3de1be778becb0e37569beb0df4752726d0a125 (diff)
downloadfrege-gradle-plugin-99541ae62dc7e179ff9538c76a13be670b7299c0.tar.gz
frege-gradle-plugin-99541ae62dc7e179ff9538c76a13be670b7299c0.tar.bz2
frege-gradle-plugin-99541ae62dc7e179ff9538c76a13be670b7299c0.zip
included the FregeDocTask, streamlined some dependencies
Diffstat (limited to 'src/main/groovy/frege/gradle/FregeDocTask.groovy')
-rw-r--r--src/main/groovy/frege/gradle/FregeDocTask.groovy57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/main/groovy/frege/gradle/FregeDocTask.groovy b/src/main/groovy/frege/gradle/FregeDocTask.groovy
new file mode 100644
index 0000000..077c4e5
--- /dev/null
+++ b/src/main/groovy/frege/gradle/FregeDocTask.groovy
@@ -0,0 +1,57 @@
+package frege.gradle
+
+import org.gradle.api.DefaultTask
+import org.gradle.api.internal.file.FileResolver
+import org.gradle.api.tasks.Input
+import org.gradle.api.tasks.InputDirectory
+import org.gradle.api.tasks.Optional
+import org.gradle.api.tasks.OutputDirectory
+import org.gradle.api.tasks.TaskAction
+import org.gradle.process.internal.DefaultJavaExecAction
+import org.gradle.process.internal.JavaExecAction
+
+class FregeDocTask extends DefaultTask {
+
+ static String DEFAULT_SRC_DIR = "src/main/frege" // TODO: should this come from a source set?
+ static String DEFAULT_DOCS_SUBDIR = "docs/frege" // TODO: should this come from a convention?
+
+ @Optional
+ @InputDirectory
+ File sourceDir = new File(project.projectDir, DEFAULT_SRC_DIR).exists() ? new File(project.projectDir, DEFAULT_SRC_DIR) : null
+
+ @Optional
+ @OutputDirectory
+ File targetDir = new File(project.buildDir, DEFAULT_DOCS_SUBDIR)
+
+ @Input
+ String module = "$project.buildDir/classes/main" // module name or directory or class path. Default is all production modules
+
+ @Input @Optional
+ String exclude = null
+
+ @Input @Optional
+ Boolean verbose = null
+
+ @TaskAction
+ void fregedoc() {
+
+ FileResolver fileResolver = getServices().get(FileResolver.class)
+ JavaExecAction action = new DefaultJavaExecAction(fileResolver)
+ action.setMain("frege.tools.Doc")
+ action.workingDir = sourceDir ?: project.projectDir
+ action.standardInput = System.in
+ action.standardOutput = System.out
+ action.errorOutput = System.err
+ action.setClasspath(project.files(project.configurations.compile) + project.files("$project.buildDir/classes/main"))
+
+ def args = []
+ if (verbose) args << '-v'
+ args << '-d' << targetDir.absolutePath
+ if (exclude) args << '-x' << exclude
+ args << module
+ action.args args
+ action.execute()
+ }
+
+}
+