Skip to content

Commit

Permalink
#122 Ensuring connection properties are always present
Browse files Browse the repository at this point in the history
  • Loading branch information
rjrudin committed Aug 21, 2016
1 parent 012295d commit 8fdceb4
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 22 deletions.
9 changes: 2 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ targetCompatibility = "1.7"

repositories {
jcenter()

// Needed for mlcp and its Hadoop dependencies
maven {url "http://developer.marklogic.com/maven2/"}
maven {url "http://repository.cloudera.com/artifactory/cloudera-repos/" }

mavenLocal() // Used for local development only
}

Expand Down Expand Up @@ -87,11 +82,11 @@ pluginBundle {
displayName = 'ml-gradle for MarkLogic'
description = 'Gradle plugin for configuring and deploying applications to MarkLogic'
tags = ['marklogic']
version = "2.3.2"
version = "2.3.3"
}
}

mavenCoordinates {
version = "2.3.2"
version = "2.3.3"
}
}
16 changes: 12 additions & 4 deletions examples/mlcp-project/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@
* JavaExec task that exposes a number of mlcp arguments as task attributes.
*/

plugins {
id "com.marklogic.ml-gradle" version "2.3.0"
buildscript {
repositories {
jcenter()
mavenLocal()
}
dependencies {
classpath "com.marklogic:ml-gradle:2.3.3"
}
}

apply plugin: "com.marklogic.ml-gradle"

repositories {
jcenter()

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

/**
Expand All @@ -109,5 +117,5 @@ task exportSampleData(type: com.marklogic.gradle.task.MlcpTask) {
password = "admin" // defaults to mlRestAdminPassword, which defaults to mlPassword
database = mlAppConfig.contentDatabaseName
output_file_path = "data/export"
args = ["-collection_filter", "sample-import"]
collection_filter = "sample-import"
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group=com.marklogic
version=2.3.2
version=2.3.3
mlAppDeployerDependency=com.marklogic:ml-app-deployer:2.3.0
mlcpUtilDependency=com.marklogic:mlcp-util:0.2.0
mlcpUtilDependency=com.marklogic:mlcp-util:0.3.0

32 changes: 23 additions & 9 deletions src/main/groovy/com/marklogic/gradle/task/MlcpTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import com.marklogic.appdeployer.AppConfig


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

Expand Down Expand Up @@ -61,11 +61,25 @@ class MlcpTask extends JavaExec {
}
}

println "mlcp arguments, excluding password: " + newArgs

// Ensure connection arguments are present
if (!newArgs.contains("-host")) {
newArgs.add("-host")
newArgs.add(config.getHost())
}
if (!newArgs.contains("-port")) {
newArgs.add("-port")
newArgs.add("8000")
}
if (!newArgs.contains("-username")) {
newArgs.add("-username")
newArgs.add(config.getRestAdminUsername())
}

println "mlcp arguments, excluding password: " + newArgs

newArgs.add("-password")
newArgs.add(password ? password : config.getRestAdminPassword())

setArgs(newArgs)

super.exec()
Expand Down

0 comments on commit 8fdceb4

Please sign in to comment.