22 * In order to use ml-gradle, it must be applied. This occurs after the two above blocks for overriding properties so
33 * that those blocks can override properties before ml-gradle initializes itself.
44 */
5- plugins {
6- id " com.marklogic.ml-gradle" version " 2.7.1"
5+ buildscript {
6+ repositories {
7+ mavenLocal()
8+ jcenter()
9+ }
10+ dependencies {
11+ classpath " com.marklogic:ml-gradle:3.0-alpha1"
12+ }
13+ }
714
8- // The following plugins are optional
15+ plugins {
16+ // The following plugins are optional
917
10- // The Java plugin is used to compile and run JUnit tests
11- id " java"
18+ // The Java plugin is used to compile and run JUnit tests
19+ id " java"
1220
13- // These plugins are used to generate IDE files
14- id " eclipse"
15- id " idea"
21+ // These plugins are used to generate IDE files
22+ id " eclipse"
23+ id " idea"
1624}
1725
26+ apply plugin : " com.marklogic.ml-gradle"
1827
1928/*
2029 * Everything below this line is optional and is intended to show different features provided by ml-gradle.
@@ -26,73 +35,70 @@ plugins {
2635 * dependencies expressed below.
2736 */
2837repositories {
29- jcenter()
38+ jcenter()
39+ mavenLocal()
3040}
3141
3242
3343configurations {
34- // This custom Gradle configuration allows us to specify the classpath for running Corb jobs. This is only needed if
35- // you want to run Corb jobs via Gradle tasks. More info on Corb can be found at - http://developer.marklogic.com/code/corb.
36- corb
44+ // This custom Gradle configuration allows us to specify the classpath for running Corb jobs. This is only needed if
45+ // you want to run Corb jobs via Gradle tasks. More info on Corb can be found at - http://developer.marklogic.com/code/corb.
46+ corb
3747}
3848
39-
4049/*
4150 * This expresses dependencies on the ml-java and ml-junit libraries. The former is typically used for application
4251 * code, and the latter supports writing JUnit-based tests. A dependency exists on RestAssured to show an option for
4352 * using that library in tests that must invoke MarkLogic HTTP endpoints.
4453 */
4554dependencies {
46- // Needed to compile and run the JUnit tests
47- testCompile " com.marklogic:ml-junit:2.6.0 "
48- testCompile " com.jayway.restassured:rest-assured:2.4.1"
55+ // Needed to compile and run the JUnit tests
56+ testCompile " com.marklogic:ml-junit:3.0-alpha1 "
57+ testCompile " com.jayway.restassured:rest-assured:2.4.1"
4958
50- // corb jar available from jcenter
51- corb " com.marklogic:marklogic-corb:2.3.2"
59+ // corb jar available from jcenter
60+ corb " com.marklogic:marklogic-corb:2.3.2"
5261}
5362
54-
5563/*
5664 * ml-gradle adds an instance of com.marklogic.appdeployer.AppConfig to the Gradle project under the key "mlAppConfig".
5765 * This instance can be modified to affect the behavior of ml-gradle.
5866 */
5967ext {
60- // mlAppConfig is an instance of com.marklogic.appdeployer.AppConfig
61- mlAppConfig {
62- // Example of adding custom tokens; these will then be replaced in any JSON/XML config files
63- customTokens. put(" sample-key" , " sample-value" )
64- customTokens. put(" %%ODBC_PORT%%" , " 8102" )
65- customTokens. put(" %%XDBC_PORT%%" , " 8103" )
66-
67- // By default, the createTriggersDatabase attribute is set to true, which results in a triggers database being
68- // created, even if a databases/triggers-database.json file isn't present. Un-commenting the line will below
69- // will prevent one from being created (assuming the triggers-database.json file isn't present).
70- // createTriggersDatabase = false
71-
72- // Example of adding a path for modules to the list of module paths, which defaults to src/main/ml-modules
73- // modulePaths.add("src/another-modules-dir")
74- // You can also override the list of module paths
75- // modulePaths = ["src/another-modules-dir"]
76-
77- // You can have multiple config files for your content database. This is useful when you have a dependency on
78- // a package of MarkLogic modules that requires some content database config, and you don't want to duplicate
79- // that in your own content-database.json file. Instead, just add the file from your
80- // build/mlRestApi/(name of dependency)/ml-config/databases directory.
81- configDir. contentDatabaseFiles. add(new File (" src/main/ml-config/databases/more-content-database-config.json" ))
82-
83- // XCC URL for running corb task below and for creating triggers on pre-8.0-4 builds of MarkLogic
84- contentXccUrl = " xcc://${ mlRestAdminUsername} :${ mlRestAdminPassword} @${ mlHost} :${ mlRestPort} "
85- }
68+ // mlAppConfig is an instance of com.marklogic.appdeployer.AppConfig
69+ mlAppConfig {
70+ // Example of adding custom tokens; these will then be replaced in any JSON/XML config files
71+ customTokens. put(" sample-key" , " sample-value" )
72+ customTokens. put(" %%ODBC_PORT%%" , " 8102" )
73+ customTokens. put(" %%XDBC_PORT%%" , " 8103" )
74+
75+ // By default, the createTriggersDatabase attribute is set to true, which results in a triggers database being
76+ // created, even if a databases/triggers-database.json file isn't present. Un-commenting the line will below
77+ // will prevent one from being created (assuming the triggers-database.json file isn't present).
78+ // createTriggersDatabase = false
79+
80+ // Example of adding a path for modules to the list of module paths, which defaults to src/main/ml-modules
81+ // modulePaths.add("src/another-modules-dir")
82+ // You can also override the list of module paths
83+ // modulePaths = ["src/another-modules-dir"]
84+
85+ // You can have multiple config files for your content database. This is useful when you have a dependency on
86+ // a package of MarkLogic modules that requires some content database config, and you don't want to duplicate
87+ // that in your own content-database.json file. Instead, just add the file from your
88+ // build/mlRestApi/(name of dependency)/ml-config/databases directory.
89+ configDir. contentDatabaseFiles. add(new File (" src/main/ml-config/databases/more-content-database-config.json" ))
90+
91+ // XCC URL for running corb task below and for creating triggers on pre-8.0-4 builds of MarkLogic
92+ contentXccUrl = " xcc://${ mlRestAdminUsername} :${ mlRestAdminPassword} @${ mlHost} :${ mlRestPort} "
93+ }
8694}
8795
88-
8996/*
9097 * For tests that reference test files in the test source tree, we need to tell Gradle to copy these to src/test/resources
9198 * so that they can be found when running "gradle test".
9299 */
93100sourceSets. test. resources. srcDir ' src/test/java'
94101
95-
96102/*
97103 * This is an example of both a custom Gradle task and an easy way of invoking Corb. This depends on "mlLoadModules" to
98104 * ensure that the Corb uris/transform modules are loaded. It also uses as a classpath the custom configuration named
@@ -102,20 +108,19 @@ sourceSets.test.resources.srcDir 'src/test/java'
102108 * to invoke corb from Gradle.
103109 */
104110task runCorb (dependsOn : [' mlLoadModules' ], type : JavaExec ) {
105- main = ' com.marklogic.developer.corb.Manager'
106- classpath = configurations. corb
107- args = [contentXccUrl, ' ""' , ' transform.xqy' , ' 4' , ' uris.xqy' , ' /ext/sample-project/corb/' , ' sample-project-modules' , ' false' ]
111+ main = ' com.marklogic.developer.corb.Manager'
112+ classpath = configurations. corb
113+ args = [contentXccUrl, ' ""' , ' transform.xqy' , ' 4' , ' uris.xqy' , ' /ext/sample-project/corb/' , ' sample-project-modules' , ' false' ]
108114}
109115
110-
111116/*
112117 * The management API has an operation for loading the default CPF pipelines -
113118 * http://docs.marklogic.com/REST/POST/manage/v2/databases/[id-or-name]/pipelines. To load these as part of your
114119 * deployment process, just uncomment the line below. These pipelines will be loaded before your custom pipelines and
115120 * domains, which means you can safely reference them in your domain configuration files.
116121 */
117122ext {
118- // mlAppDeployer.commands.add(new com.marklogic.appdeployer.command.cpf.DeployDefaultPipelinesCommand())
123+ // mlAppDeployer.commands.add(new com.marklogic.appdeployer.command.cpf.DeployDefaultPipelinesCommand())
119124}
120125
121126/*
@@ -130,7 +135,6 @@ ext {
130135// mlDatabaseCommands.add(otherDbCommand)
131136// }
132137
133-
134138/*
135139 * Example of a custom command, which in this case performs a merge on a database. The benefit of doing this in a
136140 * command (as opposed to a task) is that a command can be included in the mlDeploy and mlUndeploy tasks by adding it to
@@ -140,41 +144,40 @@ ext {
140144 * Management REST API. Note that this class could also be defined in the Gradle buildSrc directory, which is really a
141145 * better option for keeping your build.gradle file slim.
142146 */
143- import com.marklogic.appdeployer.command.AbstractCommand ;
144- import com.marklogic.appdeployer.command.CommandContext ;
147+ import com.marklogic.appdeployer.command.AbstractCommand
148+ import com.marklogic.appdeployer.command.CommandContext
145149
146150class MergeContentDatabaseCommand extends AbstractCommand {
147- public Integer getExecuteSortOrder () {
148- return Integer . MAX_VALUE ;
149- }
150- public void execute (CommandContext context ) {
151- String dbName = context. getAppConfig(). getContentDatabaseName();
152- logger. info(" Merging database: " + dbName);
153- context. getManageClient(). postJson(" /manage/v2/databases/" + dbName, ' {"operation":"merge-database"}' );
154- logger. info(" Merged database: " + dbName)
155- }
151+ public Integer getExecuteSortOrder () {
152+ return Integer . MAX_VALUE ;
153+ }
154+
155+ public void execute (CommandContext context ) {
156+ String dbName = context. getAppConfig(). getContentDatabaseName();
157+ logger. info(" Merging database: " + dbName);
158+ context. getManageClient(). postJson(" /manage/v2/databases/" + dbName, ' {"operation":"merge-database"}' );
159+ logger. info(" Merged database: " + dbName)
160+ }
156161}
157162
158-
159163/*
160164 * Example of including our custom command in the deployment process. The order in which it's invoked is determined by
161165 * the command's "getExecuteSortOrder" method.
162166 */
163167ext {
164- // mlAppDeployer.commands.add(new MergeContentDatabaseCommand())
168+ // mlAppDeployer.commands.add(new MergeContentDatabaseCommand())
165169}
166170
167-
168171/*
169172 * Below is an example of a custom task that merges a database - just like the command above. The benefit of creating a
170173 * task versus a command is that we can invoke this without running a full mlDeploy. The MarkLogicTask class provides
171174 * access to a number of helpful objects via methods like getAppConfig() and getManageClient().
172175 */
173176task mergeContentDatabase (type : com.marklogic.gradle.task.MarkLogicTask ) {
174- description = " Call this task to initiate a merge on the content database"
175- doLast {
176- getManageClient(). postJson(" /manage/v2/databases/" + getAppConfig(). getContentDatabaseName(), ' {"operation":"merge-database"}' )
177- }
177+ description = " Call this task to initiate a merge on the content database"
178+ doLast {
179+ getManageClient(). postJson(" /manage/v2/databases/" + getAppConfig(). getContentDatabaseName(), ' {"operation":"merge-database"}' )
180+ }
178181}
179182
180183/*
0 commit comments