-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing Issue #440: Adding example w/ gradle props
Adding a new example that utilizes gradle properties within deployment configuration files for substitutions for variables. This eliminates the need to utilize the mlAppConfig extension in build.gradle files
- Loading branch information
Showing
4 changed files
with
159 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Custom Tokens Example | ||
|
||
This example demonstrates how to utilize gradle environment properties that are substituted in configuraton files within the MarkLogic deployment process. We are basing this example off of the [barebones example](https://github.com/marklogic/marklogic-data-hub/tree/master/examples/barebones). | ||
|
||
This example utilizes gradle environment properties that are substituted in the configuration files for a user defined database and application server. You can see the environment properties that are defined at the bottom of the `gradle.properties` file. | ||
|
||
Inside of the `gradle.properties` file, you can see the following information: | ||
|
||
``` | ||
# Custom properties defined here | ||
TEST_DATABASE_NAME=custom-tokens-test-database | ||
TEST_SERVER_NAME=custom-tokens-test-database-server | ||
TEST_SERVER_PORT=8014 | ||
TEST_TRACE_AUTH=digest | ||
``` | ||
|
||
To utilize the custom tokens, then you will need to refer to them as `%%TEST_DATABASE_NAME%%` if you want to reference the `TEST_DATABASE_NAME` name token within your gradle deployment. You can change the default token prefix and suffix from "%%" by utilizing the following tokens in your `gradle.properties` file by setting the appropriate prefix and suffix values according: | ||
|
||
``` | ||
mlTokenPrefix= | ||
mlTokenSuffix= | ||
``` | ||
For more information regarding this, then you can refer to the [ml-gradle wiki](https://github.com/marklogic-community/ml-gradle/wiki/Configuring-resources) | ||
|
||
You can see that we are referencing the new custom tokens within the `custom-tokens-test-server.json` file. We are utilizing the four (4) custom tokens that we defined in our properties file which are the following: `%%TEST_SERVER_NAME%%`, `%%TEST_SERVER_PORT%%`, `%%TEST_DATABASE_NAME%%`, and `%%TEST_TRACE_AUTH%%`. | ||
|
||
```json | ||
{ | ||
"server-name": "%%TEST_SERVER_NAME%%", | ||
"server-type": "http", | ||
"root": "/", | ||
"group-name": "%%GROUP%%", | ||
"port": "%%TEST_SERVER_PORT%%", | ||
"modules-database": "%%mlModulesDbName%%", | ||
"content-database": "%%TEST_DATABASE_NAME%%", | ||
"authentication": "%%TEST_TRACE_AUTH%%", | ||
"default-error-format": "json", | ||
"error-handler": "/MarkLogic/rest-api/error-handler.xqy", | ||
"url-rewriter": "/MarkLogic/rest-api/rewriter.xml", | ||
"rewrite-resolves-globally": true | ||
} | ||
``` | ||
|
||
Next, Initialize your DHF app: | ||
|
||
```bash | ||
gradle hubInit | ||
``` | ||
|
||
Then Bootstrap your DHF app with the user defined database and application that utilized custom tokens: | ||
|
||
```bash | ||
gradle mlDeploy | ||
``` | ||
Once the deployment is complete, then you can login to the admin console and see the new test database and test database application server that were created with the values that were specified from our properties file. Now that you've mastered utilizing custom tokens for your gradle deployment, you can continue on with your DHF app development. | ||
|
||
For a complete list of gradle tasks, check here: [https://github.com/marklogic/marklogic-data-hub/wiki/Gradle-Tasks](https://github.com/marklogic/marklogic-data-hub/wiki/Gradle-Tasks) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
plugins { | ||
// this plugin lets you create properties files | ||
// for multiple environments... like dev, qa, prod | ||
id 'net.saliman.properties' version '1.4.6' | ||
|
||
// this is the data hub framework gradle plugin | ||
// it includes ml-gradle. This plugin is what lets you | ||
// run DHF (Data Hub Framework) tasks from the | ||
// command line | ||
id 'com.marklogic.ml-data-hub' version '2.0.4' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# These settings are used by the Data Hub Framework when | ||
# communicating with MarkLogic. | ||
# The values in this file are meant as project-wide settings. | ||
# You can override these properties for a specific environment | ||
# by creating a gradle-{environment}.properties file. | ||
# For example, to create a properties file for your prod environment create a file | ||
# named gradle-prod.properties. | ||
# | ||
# .... | ||
mlHost=localhost | ||
|
||
# Your MarkLogic Username and Password | ||
mlUsername=admin | ||
mlPassword=admin | ||
|
||
# If specified, the manage username/password combo is used with the ML Management REST API for managing application | ||
# resources; this user must have the manage-admin and rest-admin roles. | ||
# | ||
# If these are not set, then mlUsername/mlPassword is used for managing application resources. | ||
# mlManageUsername= | ||
# mlManagePassword= | ||
|
||
# If specified, the admin username/password combo is used with the ML Management REST API for creating users and roles. This | ||
# user must have the manage-admin or admin role. A good practice is to use your admin account here to create app-specific | ||
# users and roles, which can then be used as mlManageUsername/mlManagePassword and mlUsername/mlPassword. | ||
# | ||
# These properties are also used for connecting to the admin application on port 8001 - e.g. for initializing ML and for | ||
# waiting for ML to restart. | ||
# | ||
# If these properties are not set, then mlUsername/mlPassword will be used. | ||
# mlAdminUsername= | ||
# mlAdminPassword= | ||
|
||
# If specified, these values can override where the DHF thinks | ||
# MarkLogic default ports are at. You would only use this if you | ||
# have changed the ports on which MarkLogic listens | ||
# | ||
# mlAppServicesPort=8000 | ||
# mlAdminPort=8001 | ||
# mlManagePort=8002 | ||
|
||
mlStagingAppserverName=data-hub-STAGING-custom-tokens-test-database | ||
mlStagingPort=8010 | ||
mlStagingDbName=data-hub-STAGING-custom-tokens-test-database | ||
mlStagingForestsPerHost=4 | ||
mlStagingAuth=digest | ||
|
||
mlFinalAppserverName=data-hub-FINAL-custom-tokens-test-database | ||
mlFinalPort=8011 | ||
mlFinalDbName=data-hub-FINAL-custom-tokens-test-database | ||
mlFinalForestsPerHost=4 | ||
mlFinalAuth=digest | ||
|
||
mlTraceAppserverName=data-hub-TRACING-custom-tokens-test-database | ||
mlTracePort=8012 | ||
mlTraceDbName=data-hub-TRACING-custom-tokens-test-database | ||
mlTraceForestsPerHost=1 | ||
mlTraceAuth=digest | ||
|
||
mlJobAppserverName=data-hub-JOBS-custom-tokens-test-database | ||
mlJobPort=8013 | ||
mlJobDbName=data-hub-JOBS-custom-tokens-test-database | ||
mlJobForestsPerHost=1 | ||
mlJobAuth=digest | ||
|
||
mlModulesDbName=data-hub-MODULES | ||
mlModulesForestsPerHost=1 | ||
|
||
mlTriggersDbName=data-hub-TRIGGERS | ||
mlTriggersForestsPerHost=1 | ||
|
||
mlSchemasDbName=data-hub-SCHEMAS | ||
mlSchemasForestsPerHost=1 | ||
|
||
# You can override this to specify an alternate folder for your | ||
# custom forest info. Defaults to user-config/forests/ | ||
# mlCustomForestPath=forests | ||
|
||
# The name of the Role to create for Hub Access | ||
mlHubUserRole=data-hub-role | ||
mlHubUserName=data-hub-user | ||
# this password is autogenerated for you via the 'gradle hubInit' task | ||
mlHubUserPassword=b$I7'3Ya|&;Ohw.ZzsDY | ||
|
||
# Custom properties defined here | ||
TEST_DATABASE_NAME=custom-tokens-test-database | ||
TEST_SERVER_NAME=custom-tokens-test-database-server | ||
TEST_SERVER_PORT=8014 | ||
TEST_TRACE_AUTH=digest |