Skip to content

Commit 3ce91d2

Browse files
committed
Merge branch 'dev'
2 parents c245212 + ddd4fb8 commit 3ce91d2

File tree

18 files changed

+222
-28
lines changed

18 files changed

+222
-28
lines changed

examples/jsdoc-project/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.gradle
2+
.idea
3+
build
4+
node_modules

examples/jsdoc-project/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Overview
2+
3+
Example of how to use [jsdoc](http://usejsdoc.org/) in MarkLogic project
4+
5+
This project uses the [JSDoc Gradle Plugin](https://github.com/liferay/liferay-portal/tree/master/modules/sdk/gradle-plugins-jsdoc) to run the jsdoc task
6+
7+
8+
## Usage
9+
10+
All of the configuration is captured in the __build.gradle__ file and the __jsdoc.json__ file. To test this, clone this repoitory and execute the command below in this directory
11+
12+
```
13+
gradle generateJsDoc
14+
```
15+
16+
This will generate jsdoc for the code in __src/main/ml-modules/lib__
17+
18+
The html documentation will be generated in __build/docs/jsdoc__
19+
20+
## Customize
21+
22+
To customise the jsdoc output, you can modify the __jsdoc.json__ file. Refer to the http://usejsdoc.org/about-configuring-jsdoc.html site for details on how to configure this.
23+
24+
To customise the jsdoc task generator, please customize the __generateJsDoc__ task in the __build.gradle__ file. Refer to the [JSDoc Gradle Plugin](https://github.com/liferay/liferay-portal/tree/master/modules/sdk/gradle-plugins-jsdoc) site for details on how to configure this.
25+
26+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
buildscript {
2+
repositories {
3+
mavenCentral()
4+
}
5+
6+
dependencies {
7+
classpath 'commons-io:commons-io:2.6'
8+
}
9+
}
10+
11+
plugins {
12+
id "com.marklogic.ml-gradle" version "3.11.0"
13+
id "com.liferay.app.jsdoc" version "2.0.19"
14+
}
15+
16+
17+
task generateJsDoc(type:com.liferay.gradle.plugins.jsdoc.JSDocTask) {
18+
configuration = project.resources.text.fromFile(file("jsdoc.json"))
19+
destinationDir = "build/docs/jsdoc"
20+
sourceDirs = file("src/main/ml-modules/lib")
21+
}

examples/jsdoc-project/jsdoc.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"plugins": [],
3+
"recurseDepth": 10,
4+
"source": {
5+
"includePattern": ".+\\.s?js(doc|x)?$",
6+
"excludePattern": "(^|\\/|\\\\)_"
7+
},
8+
"sourceType": "module",
9+
"tags": {
10+
"allowUnknownTags": true,
11+
"dictionaries": ["jsdoc","closure"]
12+
},
13+
"templates": {
14+
"cleverLinks": false,
15+
"monospaceLinks": false
16+
}
17+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Sample Module
3+
*
4+
* @module "/sample.sjs"
5+
*/
6+
module.exports = {
7+
/**
8+
* Returns "Hello " plus the str parameter
9+
*
10+
* @example
11+
* const sampleLib = require("/sample.sjs")
12+
* // returns "Hello World"
13+
* sampleLib.hello("World")
14+
*
15+
* @param {string} str the string to say hello to
16+
*/
17+
hello: function(str) {
18+
return `Hello ${str}`
19+
}
20+
}

examples/sample-project/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ dependencies {
5858
testCompile "com.marklogic:ml-junit:3.0.0"
5959
testCompile "com.jayway.restassured:rest-assured:2.4.1"
6060

61+
// Required for Java 11
62+
testRuntime "javax.xml.bind:jaxb-api:2.3.1"
63+
testRuntime "com.sun.xml.bind:jaxb-core:2.3.0.1"
64+
testRuntime "com.sun.xml.bind:jaxb-impl:2.3.2"
65+
6166
// corb jar available from jcenter
6267
corb "com.marklogic:marklogic-corb:2.3.2"
6368
}

gradle.properties

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

5-
mlAppDeployerDependency=com.marklogic:ml-app-deployer:3.11.0
5+
mlAppDeployerDependency=com.marklogic:ml-app-deployer:3.12.0
66
mlcpUtilDependency=com.marklogic:mlcp-util:0.9.0
7-
mlDataMovementDependency=com.marklogic:marklogic-data-movement-components:1.1
7+
mlDataMovementDependency=com.marklogic:marklogic-data-movement-components:1.2.0
88
mlUnitTestDependency=com.marklogic:marklogic-unit-test-client:0.12.0

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.1-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ class MarkLogicPlugin implements Plugin<Project> {
135135
project.task("mlClearSchemasDatabase", type: ClearSchemasDatabaseTask, group: dbGroup, description: "Deletes all documents in the schemas database. " +
136136
"Note that this includes those created via the deployment of resources such as temporal collections and view schemas. You may want to use mlDeleteUserSchemas instead.")
137137
project.task("mlClearTriggersDatabase", type: ClearTriggersDatabaseTask, group: dbGroup, description: "Deletes all documents in the triggers database")
138+
project.task("mlDeleteDatabase", type: DeleteDatabaseTask, group: dbGroup, description: "Delete a database along with all of its forests and any replicas; requires -Pconfirm=true to be set so this isn't accidentally executed")
138139
project.task("mlDeployDatabases", type: DeployDatabasesTask, group: dbGroup, dependsOn: "mlPrepareRestApiDependencies", description: "Deploy each database, updating it if it exists, in the configuration directory")
139140
project.task("mlMergeContentDatabase", type: MergeContentDatabaseTask, group: dbGroup, description: "Merge the database named by mlAppConfig.contentDatabaseName")
140141
project.task("mlMergeDatabase", type: MergeDatabaseTask, group: dbGroup, description: "Merge the database named by the project property dbName; e.g. gradle mlMergeDatabase -PdbName=my-database")
@@ -344,8 +345,17 @@ class MarkLogicPlugin implements Plugin<Project> {
344345
project.extensions.add("mlAdminConfig", adminConfig)
345346

346347
ProjectPropertySource propertySource = new ProjectPropertySource(project);
348+
347349
DefaultAppConfigFactory appConfigFactory = new DefaultAppConfigFactory(propertySource)
350+
// The ConfigDir objects constructed by AppConfig must all be relative to the project directory
351+
// when using Java 11. In case this causes problems, a user can disable this via the below property
352+
if (project.hasProperty("mlIgnoreProjectDir") && "true".equals(project.property("mlIgnoreProjectDir"))) {
353+
println "The Gradle projectDir will not be used to resolve file paths"
354+
} else {
355+
appConfigFactory.setProjectDir(project.getProjectDir())
356+
}
348357
project.extensions.add("mlAppConfigFactory", appConfigFactory)
358+
349359
AppConfig appConfig = appConfigFactory.newAppConfig()
350360
project.extensions.add("mlAppConfig", appConfig)
351361

src/main/groovy/com/marklogic/gradle/task/MarkLogicTask.groovy

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,29 @@ class MarkLogicTask extends DefaultTask {
4444
project.hasProperty("mlAdminPassword") ? project.property("mlAdminPassword") : project.property("mlPassword")
4545
}
4646

47+
DatabaseClient newClient() {
48+
newClient(null)
49+
}
50+
4751
/**
48-
* If the "database" property is set, then the DatabaseClient that's returned will use the App-Services port
49-
* (defaults to 8000) to connect to the given database. Otherwise, the DatabaseClient will try to connect to the
50-
* REST API server defined by mlRestPort.
52+
* If the "database" property is set or is passed as a parameter, then the DatabaseClient that's returned will use
53+
* the App-Services port (defaults to 8000) to connect to the given database. Otherwise, the DatabaseClient will
54+
* try to connect to the REST API server defined by mlRestPort.
5155
* @return
5256
*/
53-
DatabaseClient newClient() {
54-
if (project.hasProperty("database")) {
57+
DatabaseClient newClient(String database) {
58+
if (database != null){
59+
println "Connecting via the App-Services port to database: " + database
60+
return getAppConfig().newAppServicesDatabaseClient(database)
61+
}
62+
else if (project.hasProperty("database")) {
5563
println "Connecting via the App-Services port to database: " + project.property("database")
5664
return getAppConfig().newAppServicesDatabaseClient(project.property("database"))
5765
}
5866
else {
5967
getAppConfig().newDatabaseClient()
6068
}
61-
}
69+
}
6270

6371
void deployWithCommandListProperty(String propertyName) {
6472
deployWithCommands(getProject().property(propertyName))

0 commit comments

Comments
 (0)