File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
src/main/groovy/com/marklogic/gradle/task/client Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ import com.marklogic.client.ext.modulesloader.impl.DefaultModulesLoader
1111import com.marklogic.client.ext.modulesloader.impl.PropertiesModuleManager
1212import com.marklogic.gradle.task.MarkLogicTask
1313import org.gradle.api.tasks.TaskAction
14+ import org.springframework.core.io.Resource
15+
16+ import java.util.function.Consumer
1417
1518/**
1619 * Runs an infinite loop, and each second, it loads any new/modified modules. Often useful to run with the Gradle "-i" flag
@@ -23,6 +26,8 @@ class WatchTask extends MarkLogicTask {
2326
2427 long sleepTime = 1000
2528
29+ Consumer<Set<Resource > > onModulesLoaded
30+
2631 @TaskAction
2732 void watchModules () {
2833 LoadModulesCommand command = null
@@ -72,7 +77,10 @@ class WatchTask extends MarkLogicTask {
7277 DatabaseClient client = newClient()
7378 while (true ) {
7479 for (String path : paths) {
75- loader. loadModules(path, new DefaultModulesFinder (), client);
80+ Set<Resource > loadedModules = loader. loadModules(path, new DefaultModulesFinder (), client);
81+ if (onModulesLoaded != null && loadedModules != null && ! loadedModules. isEmpty()) {
82+ onModulesLoaded. accept(loadedModules)
83+ }
7684 }
7785 try {
7886 Thread . sleep(sleepTime);
You can’t perform that action at this time.
0 commit comments