Skip to content

Commit 7ce8391

Browse files
author
Rob Rudin
committed
Not shutting down the new task executor after loading modules
1 parent 92e71c9 commit 7ce8391

File tree

4 files changed

+38
-36
lines changed

4 files changed

+38
-36
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ sourceCompatibility = "1.7"
2323
targetCompatibility = "1.7"
2424

2525
repositories {
26-
jcenter()
2726
mavenLocal() // Used for local development only
27+
jcenter()
2828
}
2929

3030
dependencies {

examples/local-testing-project/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Set this to the version you used when running
22
# "gradle -Pversion=(something) publishToMavenLocal" on your local ml-gradle repo
3-
mlGradleVersion=DEV
3+
mlGradleVersion=2.6.DEV
44

55
mlHost=localhost
66
mlAppName=example

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group=com.marklogic
2-
version=DEV
3-
mlAppDeployerDependency=com.marklogic:ml-app-deployer:DEV
2+
version=2.6.DEV
3+
mlAppDeployerDependency=com.marklogic:ml-app-deployer:2.6.DEV
44
mlcpUtilDependency=com.marklogic:mlcp-util:0.3.0
55

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

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,43 @@ import com.marklogic.gradle.task.MarkLogicTask
1212
/**
1313
* Runs an infinite loop, and each second, it loads any new/modified modules. Often useful to run with the Gradle "-i" flag
1414
* so you can see which modules are loaded.
15-
*
15+
*
1616
* Depends on an instance of LoadModulesCommand being in the Gradle Project, which should have been placed there by
1717
* MarkLogicPlugin. This prevents this class from having to know how to construct a ModulesLoader.
1818
*/
1919
class WatchTask extends MarkLogicTask {
2020

21-
long sleepTime = 1000
22-
23-
@TaskAction
24-
public void watchModules() {
25-
LoadModulesCommand command = getProject().property("mlLoadModulesCommand")
26-
27-
// Adjust the loader to catch exceptions by default
28-
ModulesLoader loader = command.getModulesLoader()
29-
if (loader == null) {
30-
command.initializeDefaultModulesLoader(getCommandContext())
31-
loader = command.getModulesLoader()
32-
}
33-
if (loader instanceof DefaultModulesLoader) {
34-
((DefaultModulesLoader)loader).setCatchExceptions(true)
35-
}
36-
37-
List<String> paths = getAppConfig().getModulePaths()
38-
println "Watching modules in paths: " + paths
39-
40-
DatabaseClient client = newClient()
41-
while (true) {
42-
for (String path : paths) {
43-
loader.loadModules(new File(path), new DefaultModulesFinder(), client);
44-
}
45-
try {
46-
Thread.sleep(sleepTime);
47-
} catch (InterruptedException ie) {
48-
// Ignore
49-
}
50-
}
51-
}
21+
long sleepTime = 1000
22+
23+
@TaskAction
24+
void watchModules() {
25+
LoadModulesCommand command = getProject().property("mlLoadModulesCommand")
26+
27+
ModulesLoader loader = command.getModulesLoader()
28+
if (loader == null) {
29+
command.initializeDefaultModulesLoader(getCommandContext())
30+
loader = command.getModulesLoader()
31+
}
32+
33+
if (loader instanceof DefaultModulesLoader) {
34+
DefaultModulesLoader dml = (DefaultModulesLoader) loader;
35+
dml.setCatchExceptions(true)
36+
dml.setShutdownTaskExecutorAfterLoadingModules(false)
37+
}
38+
39+
List<String> paths = getAppConfig().getModulePaths()
40+
println "Watching modules in paths: " + paths
41+
42+
DatabaseClient client = newClient()
43+
while (true) {
44+
for (String path : paths) {
45+
loader.loadModules(new File(path), new DefaultModulesFinder(), client);
46+
}
47+
try {
48+
Thread.sleep(sleepTime);
49+
} catch (InterruptedException ie) {
50+
// Ignore
51+
}
52+
}
53+
}
5254
}

0 commit comments

Comments
 (0)