forked from marklogic-community/smart-mastering-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
145 lines (124 loc) · 3.43 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
142
143
144
145
buildscript {
repositories {
jcenter()
// Needed for marklogic-unit-test-client dependency until it's available via jcenter()
maven {
url {"https://dl.bintray.com/marklogic-community/Maven"}
}
}
dependencies {
classpath "com.marklogic:marklogic-unit-test-client:0.12.0"
classpath "com.marklogic:ml-gradle:${mlGradleVersion}"
}
}
plugins {
id "java"
id "maven-publish"
id "com.jfrog.bintray" version "1.8.4"
id 'net.saliman.properties' version '1.4.6'
id "com.marklogic.ml-gradle" version "3.10.0"
}
repositories {
mavenLocal()
jcenter()
// Needed for marklogic-unit-test and marklogic-unit-test-client dependencies until they're available via jcenter()
maven {
url {"https://dl.bintray.com/marklogic-community/Maven"}
}
}
dependencies {
mlRestApi "com.marklogic:marklogic-unit-test-modules:0.12.0"
// For running marklogic-unit-test tests via JUnit
testCompile "com.marklogic:marklogic-unit-test-client:0.12.0"
testCompile "junit:junit:4+"
}
bintray {
user = bintray_user
key = bintray_key
publications = ['mainModules', 'sourcesModules']
pkg {
repo = 'Maven'
name = "smart-mastering-core"
userOrg = 'marklogic-community'
licenses = ["Apache-2.0"]
vcsUrl = "https://github.com/marklogic-community/smart-mastering-core.git"
version {
name = project.version
released = new Date()
}
}
}
// Defines a configuration for the MarkLogic modules; used by the modulesZip task below
configurations {
modules
sources
}
task modulesJar(type: Jar) {
description = "Jar up the smart-mastering-core MarkLogic modules into a package that can be published"
from("src/main/ml-modules") {
into("smart-mastering-core/ml-modules")
}
baseName "smart-mastering-core"
}
task sourcesJar(type: Jar, dependsOn: classes) {
description = "A sources jar is needed for publishing to jcenter; it has the same contents as the modulesJar"
from("src/main/ml-modules")
baseName "smart-mastering-core"
classifier "sources"
}
artifacts {
modules modulesJar
sources sourcesJar
}
publishing {
publications {
mainModules(MavenPublication) {
artifactId "smart-mastering-core"
artifact modulesJar
}
sourcesModules(MavenPublication) {
artifactId "smart-mastering-core"
artifact sourcesJar
}
}
repositories {
mavenCentral()
}
}
task createHttpCredentials(type: com.marklogic.gradle.task.MarkLogicTask) {
def client = getAppConfig().newAppServicesDatabaseClient("Security")
String xquery = """
xquery version "1.0-ml";
import module namespace sec = "http://marklogic.com/xdmp/security"
at "/MarkLogic/security.xqy";
declare option xdmp:mapping "false";
try {
sec:remove-credential("marklogic-unit-test-credentials")
} catch (\$e) {()};
xquery version "1.0-ml";
import module namespace sec = "http://marklogic.com/xdmp/security"
at "/MarkLogic/security.xqy";
declare option xdmp:mapping "false";
sec:create-credential(
"marklogic-unit-test-credentials",
"Credentials for ML Rest Helper Calls",
"${mlUsername}",
"${mlPassword}",
(),
(),
fn:false(),
sec:uri-credential-target("http://localhost:${mlTestRestPort}/.*","digest"),
xdmp:default-permissions()
)
""";
try {
String result
result = client.newServerEval().xquery(xquery).evalAs(String.class);
if (result != null) {
println result
}
} finally {
client.release()
}
}
mlPostDeploy.dependsOn createHttpCredentials