diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 459d75f90..57ade6530 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,10 +41,13 @@ Individual tests can be run in the following manner (replace `GraphsTest` with t ./gradlew marklogic-client-api:test --tests GraphsTest -Tests for the ml-development-tools Gradle plugin can be run via: +Tests for the `ml-development-tools` Gradle plugin can be run via: ./gradlew ml-development-tools:test You can also undeploy the test application if you do not wish to keep it around on your MarkLogic instance: ./gradlew mlUndeploy -i -Pconfirm=true + +To test the `ml-development-tools` Gradle plugin, see the README.md file located at +`ml-development-tools/src/test/example-project`. diff --git a/ml-development-tools/src/test/example-project/README.md b/ml-development-tools/src/test/example-project/README.md new file mode 100644 index 000000000..a230fb5c1 --- /dev/null +++ b/ml-development-tools/src/test/example-project/README.md @@ -0,0 +1,6 @@ +This is a simple project for testing out the ml-development-tools Gradle plugin. + +To try this out, first run `./gradlew publishToMavenLocal` from the root directory of your clone of this +repository. Then update the `build.gradle` file in this directory to reference the version number of the +plugin you published. You can then try each of the tasks in the `build.gradle` file to verify that Data Services +Java classes are generated correctly. diff --git a/ml-development-tools/src/test/example-project/build.gradle b/ml-development-tools/src/test/example-project/build.gradle new file mode 100644 index 000000000..3dc3c3622 --- /dev/null +++ b/ml-development-tools/src/test/example-project/build.gradle @@ -0,0 +1,35 @@ +buildscript { + repositories { + mavenLocal() + mavenCentral() + } + dependencies { + classpath "com.marklogic:ml-development-tools:6.3-SNAPSHOT" + } +} + +plugins { + id 'java' +} + +apply plugin: "com.marklogic.ml-development-tools" + + +group 'org.example' +version '1.0-SNAPSHOT' + +repositories { + mavenCentral() +} + +dependencies { + implementation 'com.marklogic:marklogic-client-api:6.3-SNAPSHOT' +} + +task testFullPath(type: com.marklogic.client.tools.gradle.EndpointProxiesGenTask) { + serviceDeclarationFile = "/Users/rrudin/workspace/java-client-api/example-project/src/main/ml-modules/root/inventory/service.json" +} + +task testProjectPath(type: com.marklogic.client.tools.gradle.EndpointProxiesGenTask) { + serviceDeclarationFile = "src/main/ml-modules/root/inventory/service.json" +} diff --git a/ml-development-tools/src/test/example-project/settings.gradle b/ml-development-tools/src/test/example-project/settings.gradle new file mode 100644 index 000000000..e69de29bb diff --git a/ml-development-tools/src/test/example-project/src/main/ml-modules/root/inventory/lookup.api b/ml-development-tools/src/test/example-project/src/main/ml-modules/root/inventory/lookup.api new file mode 100644 index 000000000..48dd4d5d3 --- /dev/null +++ b/ml-development-tools/src/test/example-project/src/main/ml-modules/root/inventory/lookup.api @@ -0,0 +1,16 @@ +{ + "functionName": "lookup", + "params": [ + { + "name": "productCode", + "datatype": "string" + }, + { + "name": "customerId", + "datatype": "unsignedLong" + } + ], + "return": { + "datatype": "jsonDocument" + } +} \ No newline at end of file diff --git a/ml-development-tools/src/test/example-project/src/main/ml-modules/root/inventory/lookup.sjs b/ml-development-tools/src/test/example-project/src/main/ml-modules/root/inventory/lookup.sjs new file mode 100644 index 000000000..1a61e9cc9 --- /dev/null +++ b/ml-development-tools/src/test/example-project/src/main/ml-modules/root/inventory/lookup.sjs @@ -0,0 +1,8 @@ +'use strict'; +// declareUpdate(); // Note: uncomment if changing the database state + +var productCode; // instanceof xs.string +var customerId; // instanceof xs.unsignedLong + +// Doesn't matter what happens next, this file just needs to exist so that +// Data Services Java classes can be generated from it. diff --git a/ml-development-tools/src/test/example-project/src/main/ml-modules/root/inventory/service.json b/ml-development-tools/src/test/example-project/src/main/ml-modules/root/inventory/service.json new file mode 100644 index 000000000..87ab8d7dd --- /dev/null +++ b/ml-development-tools/src/test/example-project/src/main/ml-modules/root/inventory/service.json @@ -0,0 +1,4 @@ +{ + "endpointDirectory" : "/inventory/", + "$javaClass" : "org.example.inventory.DynamicPricer" +} diff --git a/ml-development-tools/src/test/example-project/src/main/service.json b/ml-development-tools/src/test/example-project/src/main/service.json new file mode 100644 index 000000000..87ab8d7dd --- /dev/null +++ b/ml-development-tools/src/test/example-project/src/main/service.json @@ -0,0 +1,4 @@ +{ + "endpointDirectory" : "/inventory/", + "$javaClass" : "org.example.inventory.DynamicPricer" +}