Skip to content

Commit 8fdceb4

Browse files
committed
#122 Ensuring connection properties are always present
1 parent 012295d commit 8fdceb4

File tree

4 files changed

+39
-22
lines changed

4 files changed

+39
-22
lines changed

build.gradle

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ targetCompatibility = "1.7"
2424

2525
repositories {
2626
jcenter()
27-
28-
// Needed for mlcp and its Hadoop dependencies
29-
maven {url "http://developer.marklogic.com/maven2/"}
30-
maven {url "http://repository.cloudera.com/artifactory/cloudera-repos/" }
31-
3227
mavenLocal() // Used for local development only
3328
}
3429

@@ -87,11 +82,11 @@ pluginBundle {
8782
displayName = 'ml-gradle for MarkLogic'
8883
description = 'Gradle plugin for configuring and deploying applications to MarkLogic'
8984
tags = ['marklogic']
90-
version = "2.3.2"
85+
version = "2.3.3"
9186
}
9287
}
9388

9489
mavenCoordinates {
95-
version = "2.3.2"
90+
version = "2.3.3"
9691
}
9792
}

examples/mlcp-project/build.gradle

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,18 @@
44
* JavaExec task that exposes a number of mlcp arguments as task attributes.
55
*/
66

7-
plugins {
8-
id "com.marklogic.ml-gradle" version "2.3.0"
7+
buildscript {
8+
repositories {
9+
jcenter()
10+
mavenLocal()
11+
}
12+
dependencies {
13+
classpath "com.marklogic:ml-gradle:2.3.3"
14+
}
915
}
1016

17+
apply plugin: "com.marklogic.ml-gradle"
18+
1119
repositories {
1220
jcenter()
1321

@@ -92,7 +100,7 @@ task importSemicolonDelimitedText(type: com.marklogic.gradle.task.MlcpTask) {
92100
input_file_type = "delimited_text"
93101
output_uri_replace = ".*data,'/'"
94102
output_permissions = "rest-reader,read,rest-writer,update"
95-
args = ["-delimiter", ";"]
103+
delimiter = ";"
96104
}
97105

98106
/**
@@ -109,5 +117,5 @@ task exportSampleData(type: com.marklogic.gradle.task.MlcpTask) {
109117
password = "admin" // defaults to mlRestAdminPassword, which defaults to mlPassword
110118
database = mlAppConfig.contentDatabaseName
111119
output_file_path = "data/export"
112-
args = ["-collection_filter", "sample-import"]
120+
collection_filter = "sample-import"
113121
}

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=2.3.2
2+
version=2.3.3
33
mlAppDeployerDependency=com.marklogic:ml-app-deployer:2.3.0
4-
mlcpUtilDependency=com.marklogic:mlcp-util:0.2.0
4+
mlcpUtilDependency=com.marklogic:mlcp-util:0.3.0
55

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

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import com.marklogic.appdeployer.AppConfig
1010

1111

1212
/**
13-
* Provides parameters for some, but not all, mlcp arguments. Arguments that aren't supported can be passed in
14-
* via JavaExec's "args" property. The main benefit of using this class is that it assumes usage of the connection
15-
* properties found in the mlAppConfig project property.
16-
*
17-
* Note that this defaults to using appConfig.restAdminUsername and appConfig.restAdminPassword. That user may not
13+
* Delegates properties to an instance of MlcpBean, which has properties for all MLCP arguments (and if it's out of date
14+
* and missing one, you can pass them via this class's args property that's inherited from JavaExec). This task
15+
* will also default the host/port to the values defined in the mlAppConfig instance populated by the plugin.
16+
*
17+
* Note that this defaults to using appConfig.restAdminUsername and appConfig.restAdminPassword. That user may not
1818
* have permission to perform the mlcp operation you wish to perform. In that case, just set the username/password
19-
* parameters of this task for the appropriate user.
19+
* parameters of this task for the appropriate user.
2020
*/
2121
class MlcpTask extends JavaExec {
2222

@@ -61,11 +61,25 @@ class MlcpTask extends JavaExec {
6161
}
6262
}
6363

64-
println "mlcp arguments, excluding password: " + newArgs
65-
64+
// Ensure connection arguments are present
65+
if (!newArgs.contains("-host")) {
66+
newArgs.add("-host")
67+
newArgs.add(config.getHost())
68+
}
69+
if (!newArgs.contains("-port")) {
70+
newArgs.add("-port")
71+
newArgs.add("8000")
72+
}
73+
if (!newArgs.contains("-username")) {
74+
newArgs.add("-username")
75+
newArgs.add(config.getRestAdminUsername())
76+
}
77+
78+
println "mlcp arguments, excluding password: " + newArgs
79+
6680
newArgs.add("-password")
6781
newArgs.add(password ? password : config.getRestAdminPassword())
68-
82+
6983
setArgs(newArgs)
7084

7185
super.exec()

0 commit comments

Comments
 (0)