From fdc7b27d69b22e0ffa151d56c8f3812dcd229555 Mon Sep 17 00:00:00 2001 From: Rene Groeschke Date: Sun, 22 Nov 2015 00:50:45 +0000 Subject: some more work on coverage and some cleanup - get packages for integ tests right - introduce common AbstractFregeIntegrationSpec - first stab of unit test coverage for FregeCompile - minor cleanup on FregeCompile - configure fregePath as part as part of base plugin convention --- .../groovy/frege/gradle/plugins/FregeBasePlugin.java | 9 ++++++++- .../groovy/frege/gradle/tasks/FregeCompile.groovy | 20 ++++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) (limited to 'src/main') diff --git a/src/main/groovy/frege/gradle/plugins/FregeBasePlugin.java b/src/main/groovy/frege/gradle/plugins/FregeBasePlugin.java index 9f8ebd9..7ced11b 100644 --- a/src/main/groovy/frege/gradle/plugins/FregeBasePlugin.java +++ b/src/main/groovy/frege/gradle/plugins/FregeBasePlugin.java @@ -15,6 +15,7 @@ import org.gradle.api.specs.Spec; import org.gradle.api.tasks.SourceSet; import javax.inject.Inject; +import java.util.concurrent.Callable; public class FregeBasePlugin implements Plugin { private FileResolver fileResolver; @@ -42,7 +43,7 @@ public class FregeBasePlugin implements Plugin { private void configureSourceSetDefaults(final JavaBasePlugin javaBasePlugin) { project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action() { - public void execute(SourceSet sourceSet) { + public void execute(final SourceSet sourceSet) { final DefaultFregeSourceSet fregeSourceSet = new DefaultFregeSourceSet(((DefaultSourceSet) sourceSet).getDisplayName(), fileResolver); new DslObject(sourceSet).getConvention().getPlugins().put("frege", fregeSourceSet); @@ -60,6 +61,12 @@ public class FregeBasePlugin implements Plugin { FregeCompile compile = project.getTasks().create(compileTaskName, FregeCompile.class); compile.setModule(project.file(defaultSourcePath).getAbsolutePath()); javaBasePlugin.configureForSourceSet(sourceSet, compile); + compile.getConventionMapping().map("classpath", new Callable() { + public Object call() throws Exception { + return sourceSet.getCompileClasspath(); + } + }); + compile.dependsOn(sourceSet.getCompileJavaTaskName()); compile.setDescription(String.format("Compiles the %s Frege source.", sourceSet.getName())); compile.setSource(fregeSourceSet.getFrege()); diff --git a/src/main/groovy/frege/gradle/tasks/FregeCompile.groovy b/src/main/groovy/frege/gradle/tasks/FregeCompile.groovy index 3da2b34..8c63df6 100644 --- a/src/main/groovy/frege/gradle/tasks/FregeCompile.groovy +++ b/src/main/groovy/frege/gradle/tasks/FregeCompile.groovy @@ -1,8 +1,10 @@ package frege.gradle.tasks + import groovy.transform.TypeChecked import org.gradle.api.Action 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 @@ -54,8 +56,8 @@ class FregeCompile extends AbstractCompile { @Input String module = "" - @Input - List fregePaths = [] + @Optional @InputFiles + FileCollection fregePath @Input String mainClass = "frege.compiler.Main" @@ -84,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() { @Override void execute(JavaExecSpec javaExecSpec) { javaExecSpec.args = compilerArgs javaExecSpec.classpath = FregeCompile.this.classpath javaExecSpec.main = mainClass + javaExecSpec.errorOutput = System.err; + javaExecSpec.standardOutput = System.out; } }); + } public FregeCompile source(Object... sources) { @@ -129,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()) { @@ -151,7 +159,7 @@ class FregeCompile extends AbstractCompile { } args << "-d" - args << getDestinationDir() + args << getDestinationDir().absolutePath if (!module.isEmpty()) { logger.info "compiling module '$module'" -- cgit