forked from mhavey/marklogic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
executable file
·145 lines (120 loc) · 4.72 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
buildscript {
repositories {
jcenter{url "http://jcenter.bintray.com/"}
mavenLocal()
maven { url "http://plugins.gradle.org/m2" }
}
dependencies {
classpath "com.marklogic:ml-gradle:3.4.0"
classpath "net.saliman:gradle-properties-plugin:1.4.6"
}
}
apply plugin: "net.saliman.properties"
apply plugin: "com.marklogic.ml-gradle"
repositories {
jcenter{url "http://jcenter.bintray.com/"}
// Needed for mlcp dependencies
maven { url "http://plugins.gradle.org/m2" }
maven { url "http://developer.marklogic.com/maven2/" }
// Needed for hadoop dependencies for mlcp
maven { url "http://repository.cloudera.com/artifactory/cloudera-repos/" }
}
configurations {
// This configuration captures the dependencies for running mlcp (Content Pump). This is only needed if you want
// to run mlcp via Gradle tasks. If you do, using com.marklogic.gradle.task.MlcpTask is a useful starting point, as
// shown below. Need to force to use certain version of xml-apis library.
mlcp {
resolutionStrategy {
force "xml-apis:xml-apis:1.4.01"
}
}
}
dependencies {
mlcp "com.marklogic:mlcp:9.0.6"
mlcp "org.apache.commons:commons-csv:1.2"
mlcp files("lib")
}
task includeXMI2ESTransform(type: Copy) {
from "../../uml2esTransform/src/main/ml-modules/root/xmi2es"
into "src/main/ml-modules/root/xmi2es"
}
task includeModel(type: Copy) {
def xmiDir = new File("${projectDir}").getParentFile().getAbsolutePath() + "/umlModels"
from xmiDir + "/IMDBMovie.xml"
into "data/model"
}
task includeUGradle() {
// Don't use Copy task bcuz file locking into gradle project dir on Windows
doLast {
copy {
from "../../uml2esTransform/uml2es.gradle"
into "."
}
}
}
task setup() {
dependsOn('includeXMI2ESTransform')
dependsOn('includeModel')
dependsOn('includeUGradle')
}
task ingestMovieData
["role", "bio", "movieDoc", "company","person", "movie"].toList().each { entityType ->
task "ingestEntity${entityType}"(type: com.marklogic.gradle.task.MlcpTask) {
def dataDir = "${projectDir}";
def unixDir = dataDir.replace('\\', '/');
def regexDir = unixDir+"/data/movie/${entityType}"
def regex = '"' + regexDir + ",'',/,'',.json,''" + '"'
classpath = configurations.mlcp
command = "IMPORT"
database = mlAppConfig.contentDatabaseName
document_type = "xml"
input_file_path = "data/movie/${entityType}"
input_file_type = "documents"
output_uri_replace = regex
output_uri_prefix = "/xmi2es/imdb/${entityType}/"
output_uri_suffix = ".xml"
output_collections = "xmi2es,imdb,${entityType}"
output_permissions = "rest-reader,read,rest-writer,update"
host = mlAppServicesHost
port = mlAppServicesPort.toInteger()
transform_module = "/xmi2es/loadMovieTransformation.xqy"
transform_namespace ="http://marklogic.com/xmi2es/movie"
transform_param = "${entityType}"
}
ingestMovieData.dependsOn "ingestEntity${entityType}"
}
tasks.findByName('ingestEntitymovie').mustRunAfter 'ingestEntityrole'
tasks.findByName('ingestEntityperson').mustRunAfter 'ingestEntityrole'
tasks.findByName('ingestEntitycompany').mustRunAfter 'ingestEntityrole'
/*
And now a few tasks to manage generated vs real:
src/main/ml-schemas/MovieModel-0.0.1.tdex is a tweaked TDE template.
src/main/ml-schemas/tde/MovieModel-0.0.1.tdex is generated; we don't want to use it
src/main/ml-schemas/tde/MovieModel-0.0.1-GENERATED.tdex is generated; we don't want to use it
src/main/ml-schemas/MovieModel-0.0.1-GENERATED.tdex is generated; we don't want to use it
src/main/ml-config/databases/initial/content-database-INITIAL.json is the starting-point DB with no indexes based on model
src/main/ml-config/databases/content-database-GENERATED.json is generated by ES; we want to use it once ES has run
src/main/ml-config/databases/content-database.json is equal to either INITIAL or GENERATED
*/
task useInitialDBConfig(type: Copy) {
from "src/main/ml-config/databases/initial/content-database-INITIAL.json"
into "src/main/ml-config/databases"
rename { String fileName ->
fileName.replace('-INITIAL', '')
}
}
task useGeneratedDBConfig(type: Copy) {
from "src/main/ml-config/databases/content-database-GENERATED.json"
into "src/main/ml-config/databases"
rename { String fileName ->
fileName.replace('-GENERATED', '')
}
}
task deleteGenerated(type: Delete) {
delete "src/main/ml-schemas/tde/MovieModel-0.0.1.tdex"
delete "src/main/ml-schemas/tde/MovieModel-0.0.1-GENERATED.tdex"
delete "src/main/ml-schemas/MovieModel-0.0.1-GENERATED.tdex"
delete "src/main/ml-config/databases/content-database-GENERATED.json"
delete "src/main/ml-modules/ext/entity-services/MovieModel-0.0.1-GENERATED.xqy"
delete "src/main/ml-modules/options/MovieModel.xml"
}