File tree Expand file tree Collapse file tree 4 files changed +36
-13
lines changed
examples/unit-test-project
src/main/groovy/com/marklogic/gradle/task/client Expand file tree Collapse file tree 4 files changed +36
-13
lines changed Original file line number Diff line number Diff line change 1- mlGradleVersion =3.15.2
1+ mlGradleVersion =3.16.3
22marklogicUnitTestVersion =1.0.beta
33
44mlHost =localhost
Original file line number Diff line number Diff line change 1+ package com.marklogic.gradle.task.client
2+
3+ import com.marklogic.gradle.task.MarkLogicTask
4+
5+ class AbstractModuleCreationTask extends MarkLogicTask {
6+
7+ /**
8+ * Select the first modules path that is a valid location for creating a new module. Intent is to filter out
9+ * paths containing "mlRestApi" or "mlBundle" as those almost certainly point to directories where bundles have been
10+ * unzipped to, and we don't want to create new modules in those directories.
11+ *
12+ * @return
13+ */
14+ String selectModulesPath () {
15+ String path
16+ List<String > modulePaths = getAppConfig(). getModulePaths()
17+ for (String modulePath : modulePaths) {
18+ if (modulePath != null && ! modulePath. contains(" mlRestApi" ) && ! modulePath. contains(" mlBundle" )) {
19+ path = modulePath
20+ break
21+ }
22+ }
23+
24+ // Should never get here, but need to pick a path if we do
25+ if (path == null ) {
26+ path = modulePaths. get(modulePaths. size() - 1 )
27+ }
28+
29+ return path
30+ }
31+ }
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import org.gradle.api.tasks.TaskAction
44
55import com.marklogic.gradle.task.MarkLogicTask
66
7- class CreateResourceTask extends MarkLogicTask {
7+ class CreateResourceTask extends AbstractModuleCreationTask {
88
99 final static String SJS_RESOURCE_TEMPLATE =
1010''' function get(context, params) {
@@ -92,11 +92,7 @@ declare function delete(
9292 if (getProject(). hasProperty(propName)) {
9393 String servicesPath = servicesDir
9494 if (! servicesPath) {
95- List<String > modulePaths = getAppConfig(). getModulePaths()
96- if (modulePaths != null && ! modulePaths. isEmpty()) {
97- // Use the last path so modules aren't written to e.g. mlBundle paths
98- servicesPath = modulePaths. get(modulePaths. size() - 1 ) + " /services"
99- }
95+ servicesPath = selectModulesPath() + " /services"
10096 }
10197
10298 String name = getProject(). getProperties(). get(propName)
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ package com.marklogic.gradle.task.client
33import com.marklogic.gradle.task.MarkLogicTask
44import org.gradle.api.tasks.TaskAction
55
6- class CreateTransformTask extends MarkLogicTask {
6+ class CreateTransformTask extends AbstractModuleCreationTask {
77
88 final static String XQUERY_TEMPLATE = ''' xquery version "1.0-ml";
99
@@ -54,11 +54,7 @@ exports.transform = transform;
5454 if (getProject(). hasProperty(propName)) {
5555 String transformsPath = transformsDir
5656 if (! transformsPath) {
57- List<String > modulePaths = getAppConfig(). getModulePaths()
58- if (modulePaths != null && ! modulePaths. isEmpty()) {
59- // Use the last path so modules aren't written to e.g. mlBundle paths
60- transformsPath = modulePaths. get(modulePaths. size() - 1 ) + " /transforms"
61- }
57+ transformsPath = selectModulesPath() + " /transforms"
6258 }
6359
6460 String name = getProject(). getProperties(). get(propName)
You can’t perform that action at this time.
0 commit comments