Skip to content

Commit 4cac393

Browse files
committed
#242 mlWatch can now ignore existing dirty files
1 parent 8bfd545 commit 4cac393

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/main/groovy/com/marklogic/gradle/MarkLogicPlugin.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class MarkLogicPlugin implements Plugin<Project> {
179179
String modulesGroup = "ml-gradle Modules"
180180
project.task("mlLoadModules", type: LoadModulesTask, group: modulesGroup, dependsOn: "mlPrepareRestApiDependencies", description: "Loads modules from directories defined by mlAppConfig or via a property on this task").mustRunAfter(["mlClearModulesDatabase"])
181181
project.task("mlReloadModules", group: modulesGroup, dependsOn: ["mlClearModulesDatabase", "mlLoadModules"], description: "Reloads modules by first clearing the modules database and then loading modules")
182-
project.task("mlWatch", type: WatchTask, group: modulesGroup, description: "Run a loop that checks for new/modified modules every second and loads any that it finds")
182+
project.task("mlWatch", type: WatchTask, group: modulesGroup, description: "Run a loop that checks for new/modified modules every second and loads any that it finds. To ignore files that are already dirty and only process new changes, include -PignoreDirty=true . ")
183183
project.task("mlDeleteModuleTimestampsFile", type: DeleteModuleTimestampsFileTask, group: modulesGroup, description: "Delete the properties file in the build directory that keeps track of when each module was last loaded")
184184

185185
String qconsoleGroup = "ml-gradle qconsole"

src/main/groovy/com/marklogic/gradle/task/client/WatchTask.groovy

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import com.marklogic.appdeployer.command.modules.LoadModulesCommand
55
import com.marklogic.appdeployer.impl.SimpleAppDeployer
66
import com.marklogic.client.DatabaseClient
77
import com.marklogic.client.ext.modulesloader.ModulesLoader
8+
import com.marklogic.client.ext.modulesloader.ModulesManager
89
import com.marklogic.client.ext.modulesloader.impl.DefaultModulesFinder
910
import com.marklogic.client.ext.modulesloader.impl.DefaultModulesLoader
11+
import com.marklogic.client.ext.modulesloader.impl.PropertiesModuleManager
1012
import com.marklogic.gradle.task.MarkLogicTask
1113
import org.gradle.api.tasks.TaskAction
1214

@@ -39,9 +41,18 @@ class WatchTask extends MarkLogicTask {
3941
}
4042

4143
if (loader instanceof DefaultModulesLoader) {
42-
DefaultModulesLoader dml = (DefaultModulesLoader) loader;
44+
DefaultModulesLoader dml = (DefaultModulesLoader) loader
4345
dml.setCatchExceptions(true)
4446
dml.setShutdownTaskExecutorAfterLoadingModules(false)
47+
if (project.hasProperty("ignoreDirty") && "true".equals(project.property("ignoreDirty"))) {
48+
ModulesManager mgr = dml.getModulesManager()
49+
if (mgr instanceof PropertiesModuleManager) {
50+
println "Ignoring modules that need loading, will only load modules that are created/modified after this starts"
51+
((PropertiesModuleManager)mgr).setMinimumFileTimestampToLoad(System.currentTimeMillis())
52+
} else {
53+
println "Unable to apply ignoreDirty property; the underlying modules loader implementation does not support this feature."
54+
}
55+
}
4556
}
4657

4758
List<String> paths = getAppConfig().getModulePaths()

0 commit comments

Comments
 (0)