From 992490f446720cd4cf4fb9aadff463b2328a8287 Mon Sep 17 00:00:00 2001 From: Thibault Gagnaux Date: Mon, 20 Dec 2021 20:48:17 +0100 Subject: feat: adds `replSource` property and command-line option The `replSource` property specifies the frege source file that you want to load into the repl. It is excluded in the `fregeCompile` task so that we don't get two java class files (one from `compileFrege` and one from the fregeRepl `:l` command) that shadow each other on the classpath. As a result, we can make interactive changes to the `replSource` file and use the `:r` reload command to see them. --- .../ch/fhnw/thga/gradleplugins/FregePlugin.java | 28 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'src/main/java/ch/fhnw/thga/gradleplugins/FregePlugin.java') diff --git a/src/main/java/ch/fhnw/thga/gradleplugins/FregePlugin.java b/src/main/java/ch/fhnw/thga/gradleplugins/FregePlugin.java index e00b297..26c52c8 100644 --- a/src/main/java/ch/fhnw/thga/gradleplugins/FregePlugin.java +++ b/src/main/java/ch/fhnw/thga/gradleplugins/FregePlugin.java @@ -20,8 +20,13 @@ public class FregePlugin implements Plugin @Override public void apply(Project project) { - Configuration implementation = project.getConfigurations().create(FREGE_IMPLEMENTATION_SCOPE); - FregeExtension extension = project.getExtensions().create( + Configuration implementation = project + .getConfigurations() + .create(FREGE_IMPLEMENTATION_SCOPE); + + FregeExtension extension = project + .getExtensions() + .create( FREGE_EXTENSION_NAME, FregeExtension.class); @@ -36,7 +41,7 @@ public class FregePlugin implements Plugin task.getDownloadDir().set(extension.getCompilerDownloadDir()); }); - TaskProvider compileFregeTask = + TaskProvider compileFregeTask = project.getTasks().register( COMPILE_FREGE_TASK_NAME, CompileFregeTask.class, @@ -49,6 +54,7 @@ public class FregePlugin implements Plugin task.getFregeOutputDir().set(extension.getOutputDir()); task.getFregeCompilerFlags().set(extension.getCompilerFlags()); task.getFregeDependencies().set(implementation.getAsPath()); + task.getReplSource().set(""); } ); @@ -71,6 +77,13 @@ public class FregePlugin implements Plugin DependencyFregeTask.class, task -> { + task.dependsOn(compileFregeTask.map( + compileTask -> + { + compileTask.getReplSource().set(task.getReplSource()); + return compileTask; + }) + .get()); task.dependsOn(compileFregeTask); task.getFregeCompilerJar().set( setupFregeCompilerTask.get().getFregeCompilerOutputPath()); @@ -84,7 +97,14 @@ public class FregePlugin implements Plugin ReplFregeTask.class, task -> { - task.dependsOn(compileFregeTask); + task.getReplSource().set(extension.getReplModule()); + task.dependsOn(compileFregeTask.map( + compileTask -> + { + compileTask.getReplSource().set(task.getReplSource()); + return compileTask; + }) + .get()); task.getFregeCompilerJar().set( setupFregeCompilerTask.get().getFregeCompilerOutputPath()); task.getFregeOutputDir().set(extension.getOutputDir()); -- cgit