- copy stuff from example build.gradle to your own build.gradle
- define mlcpVersion in your gradle.properties (for example:
10.0.8.2
) - Download MLCP binaries, and extract into a folder names
mlcp/
in your project - Remove bin/*.sh, bin/*.bat, lib/*.jar, lib/*.txt, src/*, docs/*
Last active
January 11, 2022 17:31
-
-
Save grtjn/6258e573ec61e92e802354ad4f091074 to your computer and use it in GitHub Desktop.
Configuring Gradle for use with MLCP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
repositories { | |
mavenLocal() | |
mavenCentral() | |
maven { url "https://plugins.gradle.org/m2/" } | |
maven { url "https://developer.marklogic.com/maven2/" } | |
} | |
} | |
repositories { | |
mavenLocal() | |
mavenCentral() | |
maven { url "https://plugins.gradle.org/m2/" } | |
maven { url "https://developer.marklogic.com/maven2/" } | |
} | |
configurations { | |
all { | |
resolutionStrategy { | |
// Temporary fix to make current MLCP work with Java 9+ | |
// See: https://github.com/marklogic/marklogic-contentpump/issues/169 | |
force 'org.apache.hadoop:hadoop-common:2.7.7' | |
} | |
} | |
mlcp { | |
// stop Gradle from complaining about "SLF4J: Class path contains multiple SLF4J bindings." | |
exclude group: 'ch.qos.logback', module: 'logback-classic' | |
exclude group: 'org.apache.avro', module: 'avro-tools' | |
exclude group: 'org.slf4j', module: 'slf4j-log4j12' | |
} | |
} | |
dependencies { | |
mlcp "com.marklogic:mlcp:${mlcpVersion}" | |
/** | |
* mlcp uses Log4j for logging, and if Log4j can't find a configuration file, it will complain and you'll | |
* get none of mlcp's usually-useful logging. It is recommended then that your Gradle configuration for | |
* mlcp include a directory or some other resource that provides a log4j.properties file. | |
*/ | |
mlcp files("mlcp/conf") | |
mlcp files("mlcp/lib") | |
} | |
class DhfMlcpTask extends com.marklogic.gradle.task.MlcpTask { | |
DhfMlcpTask() { | |
classpath = project.configurations.mlcp | |
systemProperty "java.library.path", "$project.rootDir/mlcp/lib/native" | |
systemProperty "hadoop.home.dir", "$project.rootDir/mlcp" | |
systemProperty "CONTENTPUMP_HOME", "$project.rootDir/mlcp/lib" | |
systemProperty "BUNDLE_ARTIFACT", "apache" | |
systemProperty "xcc.txn.compatible", "true" | |
systemProperty "file.encoding", "UTF-8" | |
} | |
} | |
task mlcpImportExample(type: DhfMlcpTask, group: project.name) { | |
command = "IMPORT" | |
port = mlAppServicesPort.toInteger() | |
database = mlAppConfig.contentDatabaseName | |
input_file_path = "example-data/" | |
document_type "json" | |
output_collections = "data/examples" | |
output_permissions = "rest-reader,read,rest-writer,update" | |
output_uri_replace = ".*example-data/,'/data/examples/'" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment