diff options
Diffstat (limited to 'src/main/groovy/frege/gradle/tasks/FregeCompile.groovy')
-rw-r--r-- | src/main/groovy/frege/gradle/tasks/FregeCompile.groovy | 56 |
1 files changed, 15 insertions, 41 deletions
diff --git a/src/main/groovy/frege/gradle/tasks/FregeCompile.groovy b/src/main/groovy/frege/gradle/tasks/FregeCompile.groovy index 13b617c..290f750 100644 --- a/src/main/groovy/frege/gradle/tasks/FregeCompile.groovy +++ b/src/main/groovy/frege/gradle/tasks/FregeCompile.groovy @@ -1,10 +1,10 @@ package frege.gradle.tasks + import groovy.transform.TypeChecked -import groovy.transform.TypeCheckingMode import org.gradle.api.Action -import org.gradle.api.artifacts.Configuration import org.gradle.api.file.FileCollection import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputFiles import org.gradle.api.tasks.Optional import org.gradle.api.tasks.TaskAction import org.gradle.api.tasks.compile.AbstractCompile @@ -13,67 +13,51 @@ import org.gradle.process.JavaExecSpec @TypeChecked class FregeCompile extends AbstractCompile { - FileCollection fregeClasspath FileCollection classpath @Input String stackSize = "4m" - @Optional @Input boolean hints = false - @Optional @Input boolean optimize = false - @Optional - @Input boolean verbose = false - @Optional @Input boolean inline = true - @Optional @Input boolean make = true - @Optional @Input boolean compileGeneratedJava = true - @Optional @Input String target = "" - @Optional @Input boolean comments = false - @Optional @Input boolean suppressWarnings = false - @Optional @Input String explain = "" - @Optional @Input String extraArgs = "" - @Optional @Input String allArgs = "" // this is an option to overrule all other settings - @Optional @Input String module = "" - @Optional - @Input - List<File> fregePaths = [] + @Optional @InputFiles + FileCollection fregepath @Input String mainClass = "frege.compiler.Main" @@ -82,11 +66,9 @@ class FregeCompile extends AbstractCompile { @Input List<String> allJvmArgs = [] - @Optional @Input String encoding = "" - @Optional @Input String prefix = "" @@ -95,8 +77,6 @@ class FregeCompile extends AbstractCompile { @Override @TaskAction protected void compile() { - logConfigurationInfo() - def jvmArgs = allJvmArgs if (jvmArgs.isEmpty()) { jvmArgs << "-Xss$stackSize".toString() @@ -106,14 +86,20 @@ class FregeCompile extends AbstractCompile { logger.info("Calling Frege compiler with compilerArgs: '$compilerArgs'") //TODO integrate with gradle compiler daemon infrastructure and skip internal execution + + def errOutputStream = new ByteArrayOutputStream(); + def outOutputStream = new ByteArrayOutputStream(); project.javaexec(new Action<JavaExecSpec>() { @Override void execute(JavaExecSpec javaExecSpec) { javaExecSpec.args = compilerArgs - javaExecSpec.classpath = FregeCompile.this.classpath + FregeCompile.this.fregeClasspath + javaExecSpec.classpath = FregeCompile.this.classpath javaExecSpec.main = mainClass + javaExecSpec.errorOutput = System.err; + javaExecSpec.standardOutput = System.out; } }); + } public FregeCompile source(Object... sources) { @@ -125,16 +111,6 @@ class FregeCompile extends AbstractCompile { return this; } - void logConfigurationInfo() { - def path = project.files(compileConfig()).getAsPath() - logger.info("Compile configuation as path: $path") - } - - @TypeChecked(TypeCheckingMode.SKIP) - Configuration compileConfig() { - project.configurations.compile - } - protected List<String> assembleArguments() { List args = [] if (hints) @@ -161,10 +137,10 @@ class FregeCompile extends AbstractCompile { if (verbose) args << "-v" - def fp = fregePaths - if (!fp.isEmpty()) { + + if (fregepath != null && !fregepath.isEmpty()) { args << "-fp" - args << fp.collect { f -> f.absolutePath }.join(File.pathSeparator) + args << fregepath.files.collect { f -> f.absolutePath }.join(File.pathSeparator) } if (sourcePaths != null && !sourcePaths.isEmpty()) { @@ -183,7 +159,7 @@ class FregeCompile extends AbstractCompile { } args << "-d" - args << getDestinationDir() + args << getDestinationDir().absolutePath if (!module.isEmpty()) { logger.info "compiling module '$module'" @@ -191,8 +167,6 @@ class FregeCompile extends AbstractCompile { } else { args = (args + extraArgs.split().toList()).toList() } - args } - } |