11package com.marklogic.gradle.task
22
3+ import com.marklogic.contentpump.bean.MlcpBean
4+ import org.gradle.api.logging.Logger
5+ import org.gradle.api.logging.Logging
36import org.gradle.api.tasks.JavaExec
47import org.gradle.api.tasks.TaskAction
58
69import com.marklogic.appdeployer.AppConfig
710
11+
812/**
913 * Provides parameters for some, but not all, mlcp arguments. Arguments that aren't supported can be passed in
1014 * via JavaExec's "args" property. The main benefit of using this class is that it assumes usage of the connection
@@ -16,33 +20,12 @@ import com.marklogic.appdeployer.AppConfig
1620 */
1721class MlcpTask extends JavaExec {
1822
19- String host
20- Integer port = 8000
21- String username
22- String password
23- String database
24-
25- String command
26- String input_file_path
27- String input_file_type
28- String input_file_pattern
29- String input_compressed
30- String document_type
31- String output_collections
32- String delimited_root_name
33- String delimited_uri_id
34- String namespace
35- String options_file
36- String output_file_path
37- String output_type
38- String output_uri_prefix
39- String output_uri_replace
40- String output_permissions
41- String transform_module
42- String transform_namespace
43- String transform_param
44- String thread_count
45-
23+ @Delegate MlcpBean mlcpBean = new MlcpBean ();
24+
25+ public Logger getLogger () {
26+ return Logging . getLogger(MlcpTask . class)
27+ }
28+
4629 @TaskAction
4730 @Override
4831 public void exec () {
@@ -51,96 +34,33 @@ class MlcpTask extends JavaExec {
5134
5235 List<String > newArgs = new ArrayList<> ()
5336 newArgs. add(command)
54- newArgs. add(" -host" )
55- newArgs. add(host ? host : config. getHost())
56- newArgs. add(" -port" )
57- newArgs. add(port)
58- newArgs. add(" -username" )
59- newArgs. add(username ? username : config. getRestAdminUsername())
60-
61- if (database) {
62- newArgs. add(" -database" )
63- newArgs. add(database)
64- }
65- if (input_file_path) {
66- newArgs. add(" -input_file_path" )
67- newArgs. add(input_file_path)
68- }
69- if (input_file_type) {
70- newArgs. add(" -input_file_type" )
71- newArgs. add(input_file_type)
72- }
73- if (input_file_pattern) {
74- newArgs. add(" -input_file_pattern" )
75- newArgs. add(input_file_pattern)
76- }
77- if (input_compressed) {
78- newArgs. add(" -input_compressed" )
79- newArgs. add(input_compressed)
80- }
81- if (document_type) {
82- newArgs. add(" -document_type" )
83- newArgs. add(document_type)
84- }
85- if (output_collections) {
86- newArgs. add(" -output_collections" )
87- newArgs. add(output_collections)
88- }
89- if (delimited_root_name) {
90- newArgs. add(" -delimited_root_name" )
91- newArgs. add(delimited_root_name)
92- }
93- if (delimited_uri_id) {
94- newArgs. add(" -delimited_uri_id" )
95- newArgs. add(delimited_uri_id)
96- }
97- if (namespace) {
98- newArgs. add(" -namespace" )
99- newArgs. add(namespace)
100- }
101- if (options_file) {
102- newArgs. add(" -options_file" )
103- newArgs. add(options_file)
104- }
105- if (output_file_path) {
106- newArgs. add(" -output_file_path" )
107- newArgs. add(output_file_path)
108- }
109- if (output_uri_prefix) {
110- newArgs. add(" -output_uri_prefix" )
111- newArgs. add(output_uri_prefix)
112- }
113- if (output_uri_replace) {
114- newArgs. add(" -output_uri_replace" )
115- newArgs. add(output_uri_replace)
116- }
117- if (output_permissions) {
118- newArgs. add(" -output_permissions" )
119- newArgs. add(output_permissions)
120- }
121- if (output_type) {
122- newArgs. add(" -output_type" )
123- newArgs. add(output_type)
124- }
125- if (transform_module) {
126- newArgs. add(" -transform_module" )
127- newArgs. add(transform_module)
128- }
129- if (transform_namespace) {
130- newArgs. add(" -transform_namespace" )
131- newArgs. add(transform_namespace)
132- }
133- if (transform_param) {
134- newArgs. add(" -transform_param" )
135- newArgs. add(transform_param)
136- }
137- if (thread_count) {
138- newArgs. add(" -thread_count" )
139- newArgs. add(thread_count)
37+
38+ mlcpBean. properties. each { prop , val ->
39+ def propVal
40+ if (val) {
41+ switch (prop) {
42+ case " host" :
43+ propVal = (val ? val : config. getHost())
44+ break
45+ case " port" :
46+ propVal = (val ? val : 8000 )
47+ break
48+ case " username" :
49+ propVal = (val ? val : config. getRestAdminUsername())
50+ break
51+ case [" class" , " logger" , " command" , " password" ]:
52+ // skip for now
53+ return
54+ default :
55+ propVal = val
56+ break
57+ }
58+
59+ newArgs. add(" -" + prop);
60+ newArgs. add(String . valueOf(propVal));
61+ }
14062 }
141-
142- newArgs. addAll(getArgs())
143-
63+
14464 println " mlcp arguments, excluding password: " + newArgs
14565
14666 newArgs. add(" -password" )
0 commit comments