summaryrefslogtreecommitdiff
path: root/src/main/groovy
diff options
context:
space:
mode:
authorRene Groeschke <rene@gradle.com>2015-11-22 00:50:45 +0000
committerRene Groeschke <rene@gradle.com>2015-11-22 00:50:45 +0000
commitfdc7b27d69b22e0ffa151d56c8f3812dcd229555 (patch)
treef67fb55cdf48e05596f6d71e2b7f11e6853f5f28 /src/main/groovy
parenta676a61ddf3478356b43b4b7f947e6f769cde50e (diff)
downloadfrege-gradle-plugin-fdc7b27d69b22e0ffa151d56c8f3812dcd229555.tar.gz
frege-gradle-plugin-fdc7b27d69b22e0ffa151d56c8f3812dcd229555.tar.bz2
frege-gradle-plugin-fdc7b27d69b22e0ffa151d56c8f3812dcd229555.zip
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
Diffstat (limited to 'src/main/groovy')
-rw-r--r--src/main/groovy/frege/gradle/plugins/FregeBasePlugin.java9
-rw-r--r--src/main/groovy/frege/gradle/tasks/FregeCompile.groovy20
2 files changed, 22 insertions, 7 deletions
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<Project> {
private FileResolver fileResolver;
@@ -42,7 +43,7 @@ public class FregeBasePlugin implements Plugin<Project> {
private void configureSourceSetDefaults(final JavaBasePlugin javaBasePlugin) {
project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() {
- 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<Project> {
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<File> 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<JavaExecSpec>() {
@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'"