Skip to content

Commit 3404a77

Browse files
committed
#421 MlcpTask now supports a custom DatabaseClient for logging output
1 parent 70090de commit 3404a77

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/main/groovy/com/marklogic/gradle/task/MlcpTask.groovy

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class MlcpTask extends JavaExec {
2828
// Set this to define a URI in your content database for mlcp output to be written to as a text document
2929
String logOutputUri
3030

31+
// Allow the user to provide a custom DatabaseClient for logging mlcp output
32+
DatabaseClient logClient
33+
3134
Logger getLogger() {
3235
return Logging.getLogger(MlcpTask.class)
3336
}
@@ -109,9 +112,13 @@ class MlcpTask extends JavaExec {
109112
super.exec()
110113

111114
if (logOutputFile != null) {
112-
AppConfig appConfig = project.property("mlAppConfig")
113-
DatabaseClient client = appConfig.newDatabaseClient()
114-
client.newDocumentManager().write(logOutputUri, new FileHandle(logOutputFile))
115+
DatabaseClient databaseClient
116+
if (logClient != null) {
117+
databaseClient = logClient
118+
} else {
119+
databaseClient = project.property("mlAppConfig").newDatabaseClient()
120+
}
121+
databaseClient.newDocumentManager().write(logOutputUri, new FileHandle(logOutputFile))
115122
println "Wrote mlcp log output to URI: " + logOutputUri
116123
}
117124
}

0 commit comments

Comments
 (0)