Skip to content

Commit afbc93f

Browse files
committed
Merging in 2.2.0 work
1 parent b544435 commit afbc93f

File tree

15 files changed

+296
-137
lines changed

15 files changed

+296
-137
lines changed

.editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ trim_trailing_whitespace = false
1414

1515
[*.java]
1616
indent_size = 4
17+
18+
[*.groovy]
19+
indent_size = 4

build.gradle

+91-96
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,91 @@
1-
buildscript {
2-
repositories {
3-
maven {
4-
url "https://plugins.gradle.org/m2/"
5-
}
6-
}
7-
dependencies {
8-
classpath "com.gradle.publish:plugin-publish-plugin:0.9.2"
9-
}
10-
}
11-
12-
plugins {
13-
id "groovy"
14-
id "maven-publish"
15-
id "eclipse"
16-
id "idea"
17-
id "com.jfrog.bintray" version "1.5"
18-
}
19-
20-
apply plugin: "com.gradle.plugin-publish"
21-
22-
sourceCompatibility = "1.7"
23-
targetCompatibility = "1.7"
24-
25-
repositories {
26-
jcenter()
27-
mavenLocal() // Used for local development only
28-
}
29-
30-
dependencies {
31-
compile gradleApi()
32-
compile localGroovy()
33-
compile mlAppDeployerDependency
34-
}
35-
36-
task sourcesJar(type: Jar, dependsOn: classes) {
37-
classifier 'sources'
38-
from sourceSets.main.allJava
39-
from sourceSets.main.allGroovy
40-
}
41-
42-
publishing {
43-
publications {
44-
mainJava(MavenPublication) {
45-
from components.java
46-
}
47-
sourcesJava(MavenPublication) {
48-
from components.java
49-
artifact sourcesJar
50-
}
51-
}
52-
repositories {
53-
maven {
54-
url publishUrl
55-
}
56-
}
57-
}
58-
59-
if (project.hasProperty("myBintrayUser")) {
60-
bintray {
61-
user = myBintrayUser
62-
key = myBintrayKey
63-
publications = ['mainJava', 'sourcesJava']
64-
pkg {
65-
repo = 'maven'
66-
name = project.name
67-
licenses = ['Apache-2.0']
68-
vcsUrl = 'https://github.com/rjrudin/' + project.name + '.git'
69-
version {
70-
name = "2.1.0"
71-
released = new Date()
72-
}
73-
}
74-
}
75-
}
76-
77-
pluginBundle {
78-
website = 'http://www.gradle.org/'
79-
vcsUrl = 'https://github.com/rjrudin/' + project.name + '.git'
80-
description = 'Testing ml-gradle publishing'
81-
tags = ['marklogic']
82-
83-
plugins {
84-
mlgradlePlugin {
85-
id = 'com.marklogic.ml-gradle'
86-
displayName = 'ml-gradle for MarkLogic'
87-
description = 'Gradle plugin for configuring and deploying applications to MarkLogic'
88-
tags = ['marklogic']
89-
version = "2.1.0"
90-
}
91-
}
92-
93-
mavenCoordinates {
94-
version = "2.1.0"
95-
}
96-
}
1+
buildscript {
2+
repositories {
3+
maven {
4+
url "https://plugins.gradle.org/m2/"
5+
}
6+
}
7+
dependencies {
8+
classpath "com.gradle.publish:plugin-publish-plugin:0.9.2"
9+
}
10+
}
11+
12+
plugins {
13+
id "groovy"
14+
id "maven-publish"
15+
id "eclipse"
16+
id "idea"
17+
id "com.jfrog.bintray" version "1.5"
18+
}
19+
20+
apply plugin: "com.gradle.plugin-publish"
21+
22+
sourceCompatibility = "1.7"
23+
targetCompatibility = "1.7"
24+
25+
repositories {
26+
jcenter()
27+
mavenLocal() // Used for local development only
28+
}
29+
30+
dependencies {
31+
compile gradleApi()
32+
compile localGroovy()
33+
compile mlAppDeployerDependency
34+
}
35+
36+
task sourcesJar(type: Jar, dependsOn: classes) {
37+
classifier 'sources'
38+
from sourceSets.main.allJava
39+
from sourceSets.main.allGroovy
40+
}
41+
42+
publishing {
43+
publications {
44+
mainJava(MavenPublication) {
45+
from components.java
46+
}
47+
sourcesJava(MavenPublication) {
48+
from components.java
49+
artifact sourcesJar
50+
}
51+
}
52+
}
53+
54+
if (project.hasProperty("myBintrayUser")) {
55+
bintray {
56+
user = myBintrayUser
57+
key = myBintrayKey
58+
publications = ['mainJava', 'sourcesJava']
59+
pkg {
60+
repo = 'maven'
61+
name = project.name
62+
licenses = ['Apache-2.0']
63+
vcsUrl = 'https://github.com/rjrudin/' + project.name + '.git'
64+
version {
65+
name = "2.2.0-RC1"
66+
released = new Date()
67+
}
68+
}
69+
}
70+
}
71+
72+
pluginBundle {
73+
website = 'http://www.gradle.org/'
74+
vcsUrl = 'https://github.com/rjrudin/' + project.name + '.git'
75+
description = 'Testing ml-gradle publishing'
76+
tags = ['marklogic']
77+
78+
plugins {
79+
mlgradlePlugin {
80+
id = 'com.marklogic.ml-gradle'
81+
displayName = 'ml-gradle for MarkLogic'
82+
description = 'Gradle plugin for configuring and deploying applications to MarkLogic'
83+
tags = ['marklogic']
84+
version = "2.2.0-RC1"
85+
}
86+
}
87+
88+
mavenCoordinates {
89+
version = "2.2.0-RC1"
90+
}
91+
}

examples/local-testing-project/build.gradle

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@ buildscript {
33
jcenter()
44
mavenLocal()
55
}
6-
dependencies {
6+
dependencies {
77
classpath "com.marklogic:ml-gradle:${mlGradleVersion}"
88
}
99
}
1010

1111
apply plugin: "com.marklogic.ml-gradle"
12+
13+
ext {
14+
mlAppConfig {
15+
customTokens.put("CUSTOM_TOKEN", "testing")
16+
}
17+
}

examples/local-testing-project/gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Set this to the version you used when running
1+
# Set this to the version you used when running
22
# "gradle -Pversion=(something) publishToMavenLocal" on your local ml-gradle repo
33
mlGradleVersion=DEV
44

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
xquery version "1.0-ml";
2+
3+
module namespace sample = "urn:sampleapp";
4+
5+
declare function echo($str as xs:string?) as xs:string
6+
{
7+
"You said: " || $str
8+
};

examples/sample-project/src/main/ml-modules/services/echo.xqy

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ xquery version "1.0-ml";
22

33
module namespace service = "http://marklogic.com/rest-api/resource/echo";
44

5+
import module namespace sample = "urn:sampleapp" at "/ext/sample-project/lib/sample-lib.xqy";
6+
57
declare function get(
68
$context as map:map,
79
$params as map:map
810
) as document-node()*
911
{
1012
document {
1113
text {
12-
"You said:",
13-
map:get($params, "text")
14+
sample:echo(map:get($params, "text"))
1415
}
1516
}
1617
};

src/main/groovy/com/marklogic/gradle/MarkLogicPlugin.groovy

+21-10
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ import com.marklogic.gradle.task.databases.ClearModulesDatabaseTask
6464
import com.marklogic.gradle.task.databases.ClearSchemasDatabaseTask
6565
import com.marklogic.gradle.task.databases.ClearTriggersDatabaseTask
6666
import com.marklogic.gradle.task.databases.DeployDatabasesTask
67+
import com.marklogic.gradle.task.databases.MergeContentDatabaseTask
68+
import com.marklogic.gradle.task.databases.MergeDatabaseTask
69+
import com.marklogic.gradle.task.databases.ReindexContentDatabaseTask
70+
import com.marklogic.gradle.task.databases.ReindexDatabaseTask
6771
import com.marklogic.gradle.task.databases.SetContentUpdatesAllowedTask
6872
import com.marklogic.gradle.task.flexrep.DeleteAllFlexrepConfigsTask
6973
import com.marklogic.gradle.task.flexrep.DeployFlexrepAtPathTask
@@ -156,8 +160,12 @@ class MarkLogicPlugin implements Plugin<Project> {
156160
project.task("mlClearSchemasDatabase", type: ClearSchemasDatabaseTask, group: dbGroup, description: "Deletes all documents in the schemas database")
157161
project.task("mlClearTriggersDatabase", type: ClearTriggersDatabaseTask, group: dbGroup, description: "Deletes all documents in the triggers database")
158162
project.task("mlDeployDatabases", type: DeployDatabasesTask, group: dbGroup, dependsOn: "mlPrepareRestApiDependencies", description: "Deploy each database, updating it if it exists, in the configuration directory")
163+
project.task("mlMergeContentDatabase", type: MergeContentDatabaseTask, group: dbGroup, description: "Merge the database named by mlAppConfig.contentDatabaseName")
164+
project.task("mlMergeDatabase", type: MergeDatabaseTask, group: dbGroup, description: "Merge the database named by the project property dbName; e.g. gradle mlMergeDatabase -PdbName=my-database")
165+
project.task("mlReindexContentDatabase", type: ReindexContentDatabaseTask, group: dbGroup, description: "Reindex the database named by mlAppConfig.contentDatabaseName")
166+
project.task("mlReindexDatabase", type: ReindexDatabaseTask, group: dbGroup, description: "Reindex the database named by the project property dbName; e.g. gradle mlReindexDatabase -PdbName=my-database")
159167
project.task("mlSetContentUpdatesAllowed", type: SetContentUpdatesAllowedTask, group: dbGroup, description: "Sets updated-allowed on each primary forest for the content database; must set the mode via e.g. -Pmode=flash-backup")
160-
168+
161169
String devGroup = "ml-gradle Development"
162170
project.task("mlScaffold", type: GenerateScaffoldTask, group: devGroup, description: "Generate project scaffold for a new project")
163171
project.task("mlCreateResource", type: CreateResourceTask, group: devGroup, description: "Create a new resource extension in the modules services directory")
@@ -178,10 +186,10 @@ class MarkLogicPlugin implements Plugin<Project> {
178186

179187
String groupsGroup = "ml-gradle Group"
180188
project.task("mlDeployGroups", type: DeployGroupsTask, group: groupsGroup, description: "Deploy each group, updating it if it exists, in the configuration directory")
181-
189+
182190
String mimetypesGroup = "ml-gradle Mimetypes"
183191
project.task("mlDeployMimetypes", type: DeployMimetypesTask, group: mimetypesGroup, description: "Deploy each mimetype, updating it if it exists, in the configuration directory")
184-
192+
185193
String modulesGroup = "ml-gradle Modules"
186194
project.task("mlLoadModules", type: LoadModulesTask, group: modulesGroup, dependsOn: "mlPrepareRestApiDependencies", description: "Loads modules from directories defined by mlAppConfig or via a property on this task").mustRunAfter(["mlClearModulesDatabase"])
187195
project.task("mlReloadModules", group: modulesGroup, dependsOn: ["mlClearModulesDatabase", "mlLoadModules"], description: "Reloads modules by first clearing the modules database and then loading modules")
@@ -191,11 +199,11 @@ class MarkLogicPlugin implements Plugin<Project> {
191199
String schemasGroup = "ml-gradle Schemas"
192200
project.task("mlLoadSchemas", type: LoadSchemasTask, group: schemasGroup, description: "Loads special-purpose data into the schemas database (XSD schemas, Inference rules, and [MarkLogic 9] Extraction Templates)").mustRunAfter("mlClearSchemasDatabase")
193201
project.task("mlReloadSchemas", dependsOn: ["mlClearSchemasDatabase", "mlLoadSchemas"], group: schemasGroup, description: "Clears schemas database then loads special-purpose data into the schemas database (XSD schemas, Inference rules, and [MarkLogic 9] Extraction Templates)")
194-
202+
195203
String serverGroup = "ml-gradle Server"
196204
project.task("mlDeployServers", type: DeployServersTask, group: serverGroup, dependsOn: "mlPrepareRestApiDependencies", description: "Updates the REST API server (if it exists) and deploys each other server, updating it if it exists, in the configuration directory ")
197205
project.task("mlUndeployOtherServers", type: UndeployOtherServersTask, group: serverGroup, description: "Delete any non-REST API servers (e.g. ODBC and XBC servers) defined by server files in the configuration directory")
198-
206+
199207
String securityGroup = "ml-gradle Security"
200208
project.task("mlDeployAmps", type: DeployAmpsTask, group: securityGroup, description: "Deploy each amp, updating it if it exists, in the configuration directory")
201209
project.task("mlDeployCertificateAuthorities", type: DeployCertificateAuthoritiesTask, group: securityGroup, description: "Deploy each certificate authority, updating it if it exists, in the configuration directory")
@@ -236,7 +244,11 @@ class MarkLogicPlugin implements Plugin<Project> {
236244
AdminConfig adminConfig = new DefaultAdminConfigFactory(new ProjectPropertySource(project)).newAdminConfig()
237245
project.extensions.add("mlAdminConfig", adminConfig)
238246

239-
AppConfig appConfig = new DefaultAppConfigFactory(new ProjectPropertySource(project)).newAppConfig()
247+
ProjectPropertySource propertySource = new ProjectPropertySource(project);
248+
AppConfig appConfig = new DefaultAppConfigFactory(propertySource).newAppConfig()
249+
if (appConfig.isReplaceTokensInModules()) {
250+
appConfig.getModuleTokensPropertiesSources().add(propertySource);
251+
}
240252
project.extensions.add("mlAppConfig", appConfig)
241253

242254
ManageConfig manageConfig = new DefaultManageConfigFactory(new ProjectPropertySource(project)).newManageConfig()
@@ -278,7 +290,7 @@ class MarkLogicPlugin implements Plugin<Project> {
278290

279291
/**
280292
* If the groovysh plugin has already been applied, then we can jvmArgs and args on the shell task automatically.
281-
* Otherwise, the shell task needs to be configured in the Gradle file.
293+
* Otherwise, the shell task needs to be configured in the Gradle file.
282294
*/
283295
if (project.getExtensions().findByName("groovysh")) {
284296
project.afterEvaluate {
@@ -321,7 +333,7 @@ class MarkLogicPlugin implements Plugin<Project> {
321333
LoadSchemasCommand lsc = new LoadSchemasCommand()
322334
project.extensions.add("mlLoadSchemasCommand", lsc)
323335
commands.add(lsc)
324-
336+
325337
// REST API instance creation
326338
commands.add(new DeployRestApiServersCommand())
327339

@@ -334,7 +346,6 @@ class MarkLogicPlugin implements Plugin<Project> {
334346

335347
// Modules
336348
LoadModulesCommand lmc = new LoadModulesCommand()
337-
lmc.initializeDefaultModulesLoader(context)
338349
project.extensions.add("mlLoadModulesCommand", lmc)
339350
commands.add(lmc)
340351

@@ -372,7 +383,7 @@ class MarkLogicPlugin implements Plugin<Project> {
372383
mimetypeCommands.add(new DeployMimetypesCommand())
373384
project.extensions.add("mlMimetypeCommands", mimetypeCommands)
374385
commands.addAll(mimetypeCommands)
375-
386+
376387
// Forest replicas
377388
List<Command> replicaCommands = new ArrayList<Command>()
378389
replicaCommands.add(new ConfigureForestReplicasCommand())

0 commit comments

Comments
 (0)