|
1 | | -What is Gradle? |
2 | | -=============== |
| 1 | +Automate everything involving MarkLogic with Gradle |
| 2 | +========= |
3 | 3 |
|
4 | | -Gradle is a standard build tool that is used for building and deploying primarily Java applications, but it can be used for any codebase. Check out the [Gradle user guide](http://www.gradle.org/docs/current/userguide/userguide.html) for more information. |
| 4 | +ml-gradle is a [Gradle](https://gradle.org/) [plugin](https://docs.gradle.org/current/userguide/plugins.html) that can automate everything |
| 5 | +you do with [MarkLogic](https://www.marklogic.com/). Deploy an application, add a host, backup a database, stub out a new project, load modules as you modify them, |
| 6 | +run an [MLCP](https://developer.marklogic.com/products/mlcp) or [CoRB](https://developer.marklogic.com/code/corb) |
| 7 | +or [Data Movement](http://docs.marklogic.com/guide/java/data-movement) job - if it involves MarkLogic, |
| 8 | +ml-gradle either automates it already or can be extended to do so. |
5 | 9 |
|
6 | | -What is ml-gradle? |
7 | | -========= |
8 | | -ml-gradle is a [Gradle plugin](https://plugins.gradle.org/ "") that supports a number of tasks pertaining to deploying an |
9 | | -application to MarkLogic and interacting with other features of MarkLogic via a Gradle build file. The bulk of the |
10 | | -functionality provided by ml-gradle is actually in [ml-app-deployer](https://github.com/rjrudin/ml-app-deployer) - ml-gradle |
11 | | -is just intended to be a thin wrapper around this library, exposing its functionality via Gradle tasks and properties. |
| 10 | +You can use ml-gradle right away with the simple tutorial below, or learn more: |
12 | 11 |
|
13 | | -Why use ml-gradle? |
| 12 | +- The [ml-gradle Wiki](https://github.com/marklogic-community/ml-gradle/wiki) guides you through all of the ml-gradle documentation |
| 13 | +- Read the [Getting Started guide](https://github.com/marklogic-community/ml-gradle/wiki/Getting-started) for more details on setting up a new project |
| 14 | +- Browse the [example projects](https://github.com/marklogic-community/ml-gradle/tree/master/examples) for working examples of different ml-gradle features |
| 15 | + |
| 16 | +Start using ml-gradle |
14 | 17 | ========= |
15 | | -ml-gradle is a good fit for you and your team if: |
16 | 18 |
|
17 | | -1. You're using MarkLogic 8 or 9 |
18 | | -2. You're using Gradle, or you're considering moving away from Ant/Maven/etc to Gradle to manage all of your build processes |
19 | | -3. You'd like to use a build tool that can manage the dependencies and execution of MarkLogic tools such as the Java Client API, mlcp, corb, recordloader, xqsync |
20 | | -4. You'd like to have a single all-purpose tool that allows you to define tasks to do anything you need to on your MarkLogic project, |
21 | | -including tasks that have nothing to do with MarkLogic. |
| 19 | +ml-gradle depends on at least [Java 8](https://java.com/en/download/) and [MarkLogic 8 or 9](https://developer.marklogic.com/products), |
| 20 | +so if you have those installed, you're just a couple minutes away from using ml-gradle to start a new project and deploy an |
| 21 | +application from it. |
22 | 22 |
|
23 | | -If you're currently using Ant or Maven and are wondering about Gradle, there are many comparisons of these tools on |
24 | | -the Internet; I recommend making this shift. If you are using Ant, it's easy to invoke Ant tasks from Gradle. And if |
25 | | -you can't move away from Maven, you can try [this Maven plugin for invoking Gradle](https://github.com/if6was9/gradle-maven-plugin). |
| 23 | +First, [install Gradle](https://gradle.org/install/). |
26 | 24 |
|
27 | | -What are the main features of ml-gradle? |
28 | | -========= |
29 | | -1. Utilizes the new [Management REST API](http://docs.marklogic.com/REST/management) in MarkLogic 8 to configure and deploy all aspects of an application. |
30 | | -1. Can [watch for new/modified modules](https://github.com/rjrudin/ml-gradle/wiki/Watching-for-module-changes) and automatically |
31 | | -load them for you, thus speeding up the code/build/test cycle |
32 | | -1. Can run Content Pump, Corb, and other Java-based MarkLogic tools without having to copy jars around and worry about a classpath |
33 | | -1. Can treat packages of MarkLogic code as [true third-party dependencies](https://github.com/rjrudin/ml-gradle/wiki/Preparing-REST-API-dependencies), |
34 | | -resolving them just like you would a dependency on a jar, as well as automatically loading such code into your modules database |
35 | | -1. Can take advantage of [all the features of Gradle](https://docs.gradle.org/current/userguide/overview.html) |
36 | | - |
37 | | -How can I start using ml-gradle? |
38 | | -========= |
39 | | -First, check out the [new Getting Started Wiki page](https://github.com/rjrudin/ml-gradle/wiki/Getting-started). |
| 25 | +Then, in an empty directory, create a file named "build.gradle" with your favorite text editor and enter the following: |
| 26 | + |
| 27 | + plugins { id "com.marklogic.ml-gradle" version "3.4.0" } |
| 28 | + |
| 29 | +Then run: |
| 30 | + |
| 31 | + gradle mlNew |
| 32 | + |
| 33 | +This starts a project wizard to stub out files for your new application. You can accept all the defaults, but be sure to |
| 34 | +enter a valid port number for the "REST API port" question. ml-gradle will then print the following logging: |
| 35 | + |
| 36 | + Updating build.gradle so that the Gradle properties plugin can be applied |
| 37 | + Writing: build.gradle |
| 38 | + Writing: gradle.properties |
| 39 | + Writing: gradle-dev.properties |
| 40 | + Writing: gradle-local.properties |
| 41 | + Writing: gradle-qa.properties |
| 42 | + Writing: gradle-prod.properties |
| 43 | + Making directory: src/main/ml-config |
| 44 | + Making directory: src/main/ml-modules |
| 45 | + Writing project scaffolding files |
| 46 | + |
| 47 | +You now have an ml-gradle project stubbed out with support for deploying to multiple environments via the |
| 48 | +[Gradle properties plugin](https://github.com/stevesaliman/gradle-properties-plugin). |
| 49 | + |
| 50 | +Now deploy it! |
| 51 | + |
| 52 | + gradle mlDeploy |
| 53 | + |
| 54 | +And you should see more ml-gradle logging like this: |
| 55 | + |
| 56 | + :mlDeleteModuleTimestampsFile |
| 57 | + :mlPrepareRestApiDependencies |
| 58 | + :mlDeployApp |
| 59 | + :mlPostDeploy UP-TO-DATE |
| 60 | + :mlDeploy |
| 61 | + BUILD SUCCESSFUL |
40 | 62 |
|
41 | | -Next, you may want to browse the rest of the [Wiki and FAQ](https://github.com/rjrudin/ml-gradle/wiki). |
| 63 | +And once that's complete, you can go to the MarkLogic Admin UI on port 8001 to see the resources that have been created |
| 64 | +(the names of these resources start with the application name you selected in the project wizard, which defaults to myApp): |
42 | 65 |
|
43 | | -Then, have a look around the various [example projects](https://github.com/rjrudin/ml-gradle/tree/master/examples) to see |
44 | | -how different resources can be configured. |
| 66 | +- Under App Servers, a new REST server named myApp on the port you chose |
| 67 | +- Under Databases, a new content datase named myApp-content and a new modules database named myApp-modules |
| 68 | +- Under Forests, 3 new forests for myApp-content and 1 new forest for myApp-modules |
| 69 | +- Under Security/Users, 3 new users, each prefixed with myApp |
| 70 | +- Under Security/Roles, 5 new roles, each prefixed with myApp |
45 | 71 |
|
46 | | -Finally, if you run into trouble, you can either submit an issue to this project or try asking a question |
47 | | -[on stackoverflow with marklogic as a tag](http://stackoverflow.com/questions/tagged/marklogic). |
| 72 | +Congratulations! You've used ml-gradle to stub out a new project and deploy its application to MarkLogic. You're now |
| 73 | +ready to start adding more resources and modules to your project. See the links above this tutorial to learn |
| 74 | +more about using ml-gradle. |
0 commit comments