Skip to content

Commit c82c408

Browse files
committed
Merge branch 'dev'
2 parents cba9e2d + 40fbfba commit c82c408

File tree

8 files changed

+87
-5
lines changed

8 files changed

+87
-5
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ if (project.hasProperty("myBintrayUser")) {
7070
bintray {
7171
user = myBintrayUser
7272
key = myBintrayKey
73-
publications = ['mainJava', 'sourcesJava', 'mavenJavadoc']
73+
publications = ['mainJava', 'sourcesJava']
7474
pkg {
7575
repo = 'maven'
7676
name = project.name

examples/local-testing-project/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Set this to the version you used when running
22
# "gradle -Pversion=(something) publishToMavenLocal" on your local ml-gradle repo
3-
mlGradleVersion=3.6.1
3+
mlGradleVersion=3.7.0-rc1
44

55
mlHost=localhost
66
mlAppName=example

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
group=com.marklogic
2-
version=3.6.3
2+
version=3.7.0
33
javadocsDir=../gh-pages-marklogic-java/javadocs
44

5-
mlAppDeployerDependency=com.marklogic:ml-app-deployer:3.6.3
5+
mlAppDeployerDependency=com.marklogic:ml-app-deployer:3.7.0
66
mlcpUtilDependency=com.marklogic:mlcp-util:0.9.0
77
mlDataMovementDependency=com.marklogic:marklogic-data-movement-components:1.0
88
mlUnitTestDependency=com.marklogic:ml-unit-test-client:0.10.0

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import com.marklogic.gradle.task.alert.DeleteAllAlertConfigsTask
1515
import com.marklogic.gradle.task.alert.DeployAlertingTask
1616
import com.marklogic.gradle.task.client.*
1717
import com.marklogic.gradle.task.cluster.*
18+
import com.marklogic.gradle.task.configuration.DeployConfigurationsTask
1819
import com.marklogic.gradle.task.cpf.DeployCpfTask
1920
import com.marklogic.gradle.task.cpf.LoadDefaultPipelinesTask
2021
import com.marklogic.gradle.task.databases.*
@@ -26,6 +27,7 @@ import com.marklogic.gradle.task.forests.ConfigureForestReplicasTask
2627
import com.marklogic.gradle.task.forests.DeleteForestReplicasTask
2728
import com.marklogic.gradle.task.forests.DeployCustomForestsTask
2829
import com.marklogic.gradle.task.forests.DeployForestReplicasTask
30+
import com.marklogic.gradle.task.forests.PrintForestPlanTask
2931
import com.marklogic.gradle.task.groups.DeployGroupsTask
3032
import com.marklogic.gradle.task.groups.SetTraceEventsTask
3133
import com.marklogic.gradle.task.hosts.AssignHostsToGroupsTask
@@ -106,6 +108,9 @@ class MarkLogicPlugin implements Plugin<Project> {
106108
project.task("mlDeleteAllAlertConfigs", type: DeleteAllAlertConfigsTask, group: alertGroup, description: "Delete all alert configs, which also deletes all of the actions rules associated with them")
107109
project.task("mlDeployAlerting", type: DeployAlertingTask, group: alertGroup, description: "Deploy each alerting resource - configs, actions, and rules - in the configuration directory")
108110

111+
String configurationGroup = "ml-gradle Configuration"
112+
project.task("mlDeployConfigurations", type: DeployConfigurationsTask, group: configurationGroup, description: "Deploy each configuration (requires at least MarkLogic 9.0-5) in the configuration directory")
113+
109114
String cpfGroup = "ml-gradle CPF"
110115
project.task("mlDeployCpf", type: DeployCpfTask, group: cpfGroup, description: "Deploy each CPF resource - domains, pipelines, and CPF configs - in the configuration directory").mustRunAfter("mlClearTriggersDatabase")
111116
project.task("mlRedeployCpf", group: cpfGroup, dependsOn: ["mlClearTriggersDatabase", "mlDeployCpf"], description: "Clears the triggers database and then calls mlDeployCpf; be sure to reload custom triggers after doing this, as they will be deleted as well")
@@ -187,6 +192,7 @@ class MarkLogicPlugin implements Plugin<Project> {
187192
project.task("mlDeleteForestReplicas", type: DeleteForestReplicasTask, group: forestGroup, description: "Deprecated - delete forest replicas via the command.forestNamesAndReplicaCounts map")
188193
project.task("mlDeployCustomForests", type: DeployCustomForestsTask, group: forestGroup, description: "Deploy custom forests as defined in subdirectories of the forests configuration directory")
189194
project.task("mlDeployForestReplicas", type: DeployForestReplicasTask, group: forestGroup, description: "Prefer this over mlConfigureForestReplicas; it does the same thing, but uses the ConfigureForestReplicasCommand that is used by mlDeploy")
195+
project.task("mlPrintForestPlan", type: PrintForestPlanTask, group: forestGroup, description: "Print a list of primary forests to be created for a database specified by -Pdatabase=(name of database) when the database is next deployed")
190196

191197
String groupsGroup = "ml-gradle Group"
192198
project.task("mlDeployGroups", type: DeployGroupsTask, group: groupsGroup, description: "Deploy each group, updating it if it exists, in the configuration directory")

src/main/groovy/com/marklogic/gradle/ProjectPropertySource.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public String getProperty(String name) {
3030
*
3131
* This currently only includes properties that start with "ml". This is to avoid picking up very generically-named
3232
* properties in Gradle, such as "name" and "version", which may conflict with properties from other sources.
33-
* @return
3433
*/
3534
@Override
3635
public Properties getProperties() {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.marklogic.gradle.task.configuration
2+
3+
import com.marklogic.gradle.task.MarkLogicTask
4+
import org.gradle.api.tasks.TaskAction
5+
6+
class DeployConfigurationsTask extends MarkLogicTask {
7+
8+
@TaskAction
9+
void deployConfigurations() {
10+
deployWithCommandListProperty("mlConfigurationCommands")
11+
}
12+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.marklogic.gradle.task.forests
2+
3+
import com.marklogic.appdeployer.AppConfig
4+
import com.marklogic.appdeployer.command.databases.DeployContentDatabasesCommand
5+
import com.marklogic.appdeployer.command.databases.DeployDatabaseCommand
6+
import com.marklogic.appdeployer.command.databases.DeploySchemasDatabaseCommand
7+
import com.marklogic.appdeployer.command.databases.DeployTriggersDatabaseCommand
8+
import com.marklogic.appdeployer.impl.SimpleAppDeployer
9+
import com.marklogic.gradle.task.MarkLogicTask
10+
import com.marklogic.mgmt.api.forest.Forest
11+
import org.gradle.api.tasks.TaskAction
12+
13+
class PrintForestPlanTask extends MarkLogicTask {
14+
15+
@TaskAction
16+
void printForestPlan() {
17+
if (!project.hasProperty("database")) {
18+
println "Please specify a database via the 'database' property"
19+
return
20+
}
21+
22+
String database = project.property("database")
23+
24+
/**
25+
* We unfortunately have to do a little work here to determine what command object to use based on the database
26+
* name. That's to account for the "special" stuff that's done for the content database (mlContentForestsPerHost)
27+
* and for the schema/triggers databases (those commands default to only having forests on one host).
28+
*/
29+
AppConfig appConfig = getAppConfig()
30+
SimpleAppDeployer appDeployer = getAppDeployer()
31+
DeployDatabaseCommand command
32+
if (database.equals(appConfig.getContentDatabaseName()) || database.equals(appConfig.getTestContentDatabaseName())) {
33+
command = appDeployer.getCommandOfType(DeployContentDatabasesCommand.class)
34+
} else if (database.equals(appConfig.getSchemasDatabaseName())) {
35+
command = appDeployer.getCommandOfType(DeploySchemasDatabaseCommand.class)
36+
} else if (database.equals(appConfig.getTriggersDatabaseName())) {
37+
command = appDeployer.getCommandOfType(DeployTriggersDatabaseCommand.class)
38+
} else {
39+
command = new DeployDatabaseCommand()
40+
}
41+
42+
/**
43+
* Now that we have a command, use it to build its command for deploying forests, and then use that to build
44+
* the list of forests that will be created.
45+
*/
46+
List<Forest> forests = command.buildDeployForestsCommand(database, getCommandContext()).buildForests(getCommandContext(), true)
47+
48+
49+
if (forests.isEmpty()) {
50+
println "\nNo primary forests will be created the next time the database '" + database + "' is deployed; this is likely because it already has all of the primary desired forests based on the configuration settings."
51+
println "\nIf replicas have been configured for the database - e.g. via mlDatabaseNamesAndReplicaCounts - and these do not exist yet, " +
52+
"then replicas will be created the next time either the mlDeploy task or mlConfigureForestReplicas task is run."
53+
} else {
54+
for (Forest f : forests) {
55+
println f.getJson()
56+
}
57+
println "\nThe " + forests.size() + " forests (and replicas if applicable) that will be created the next time the database '" + database + "' is deployed (e.g. via the mlDeploy task) are listed above."
58+
}
59+
}
60+
}

src/main/groovy/com/marklogic/gradle/task/tasks/DeleteAllTasksTask.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ class DeleteAllTasksTask extends MarkLogicTask {
88

99
@TaskAction
1010
void deleteAllTasks() {
11+
String group = "Default"
12+
if (project.hasProperty("mlGroupName")) {
13+
group = project.property("mlGroupName")
14+
}
15+
println "Deleting all scheduled tasks in group: " + group
1116
new TaskManager(getManageClient()).deleteAllScheduledTasks()
1217
}
1318
}

0 commit comments

Comments
 (0)