Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 893992d

Browse files
committed
#13 Finish issue-13
1 parent 0bde90f commit 893992d

File tree

6 files changed

+79
-18
lines changed

6 files changed

+79
-18
lines changed

CHANGELOG.mdown

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# ml-gradle releases
22

3+
## 2.5.1
4+
5+
* [#13](https://github.com/rjrudin/ml-javaclient-util/issues/13) Added support for loading from any directory in source path
6+
37
## 2.5
48

59
* Added classes from ml-xcc-util
@@ -28,3 +32,23 @@
2832
## 2.1
2933

3034
* Repackaged
35+
36+
## Old changelog
37+
38+
## 2.0 - ML8 compatibility
39+
40+
## 2.0.1 - BasicConfig now assumes 8000 as the XDBC port
41+
42+
## 2.0.2 - XccAssetLoader added to DefaultModulesLoader
43+
44+
## 2.0.3 - Targeting Java 1.7
45+
46+
## 2.0.4 - Depending on com.marklogic:java-client-api:3.0.2
47+
48+
## 2.0.5 - Now supports *.sjs transforms
49+
50+
## 2.0.6 - #8 now supports loading rest-properties.json file
51+
52+
## 2.0.7 - #8 Fix for not loading rest-properties.json when it's not been modified
53+
54+
## 2.0.8 - Added TestServerModulesFinder

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ if (project.hasProperty("myBintrayUser")) {
5656
licenses = ['Apache-2.0']
5757
vcsUrl = 'https://github.com/rjrudin/' + project.name + '.git'
5858
version {
59-
name = "2.5"
59+
name = "2.5.1"
6060
released = new Date()
6161
}
6262
}

gradle.properties

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
11
group=com.marklogic
22
publishUrl=file:../gh-pages-marklogic-java/releases
33
javadocsDir=../gh-pages-marklogic-java/javadocs
4-
5-
# 2.0 - ML8 compatibility
6-
# 2.0.1 - BasicConfig now assumes 8000 as the XDBC port
7-
# 2.0.2 - XccAssetLoader added to DefaultModulesLoader
8-
# 2.0.3 - Targeting Java 1.7
9-
# 2.0.4 - Depending on com.marklogic:java-client-api:3.0.2
10-
# 2.0.5 - Now supports *.sjs transforms
11-
# 2.0.6 - #8 now supports loading rest-properties.json file
12-
# 2.0.7 - #8 Fix for not loading rest-properties.json when it's not been modified
13-
# 2.0.8 - Added TestServerModulesFinder
14-
version=2.5
4+
version=2.5.1

src/main/java/com/marklogic/client/modulesloader/impl/BaseModulesFinder.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.File;
44
import java.io.FilenameFilter;
55
import java.util.ArrayList;
6+
import java.util.Arrays;
67
import java.util.List;
78

89
import com.marklogic.client.helper.FilenameUtil;
@@ -18,6 +19,14 @@ public abstract class BaseModulesFinder implements ModulesFinder {
1819
private FilenameFilter transformFilenameFilter = new TransformFilenameFilter();
1920
private FilenameFilter namespaceFilenameFilter = new NamespaceFilenameFilter();
2021

22+
/**
23+
* Whether to treat paths that aren't recognized by this class (i.e. not services, options, namespaces, or
24+
* transforms) as asset paths that will then be loaded as asset modules.
25+
*/
26+
private boolean includeUnrecognizedPathsAsAssetPaths = true;
27+
28+
private String extPath = "ext";
29+
private String rootPath = "root";
2130
private String servicesPath = "services";
2231
private String optionsPath = "options";
2332
private String namespacesPath = "namespaces";
@@ -59,9 +68,24 @@ protected void addAssetDirectories(Modules modules, File baseDir) {
5968
if (dir.exists()) {
6069
dirs.add(dir);
6170
}
71+
72+
if (includeUnrecognizedPathsAsAssetPaths) {
73+
List<String> recognizedPaths = getRecognizedPaths();
74+
for (File f : baseDir.listFiles()) {
75+
if (f.isDirectory() && !recognizedPaths.contains(f.getName())) {
76+
dirs.add(f);
77+
}
78+
}
79+
}
80+
6281
modules.setAssetDirectories(dirs);
6382
}
6483

84+
protected List<String> getRecognizedPaths() {
85+
return Arrays
86+
.asList(new String[] { extPath, rootPath, optionsPath, servicesPath, transformsPath, namespacesPath });
87+
}
88+
6589
protected void addOptions(Modules modules, File baseDir) {
6690
File queryOptionsBaseDir = new File(baseDir, optionsPath);
6791
List<File> queryOptions = new ArrayList<>();
@@ -129,6 +153,22 @@ public void setNamespacesPath(String namespacesPath) {
129153
public void setTransformsPath(String transformsPath) {
130154
this.transformsPath = transformsPath;
131155
}
156+
157+
public boolean isIncludeUnrecognizedPathsAsAssetPaths() {
158+
return includeUnrecognizedPathsAsAssetPaths;
159+
}
160+
161+
public void setIncludeUnrecognizedPathsAsAssetPaths(boolean includeUnrecognizedPathsAsAssetPaths) {
162+
this.includeUnrecognizedPathsAsAssetPaths = includeUnrecognizedPathsAsAssetPaths;
163+
}
164+
165+
public void setExtPath(String extPath) {
166+
this.extPath = extPath;
167+
}
168+
169+
public void setRootPath(String rootPath) {
170+
this.rootPath = rootPath;
171+
}
132172
}
133173

134174
class AssetFilenameFilter implements FilenameFilter {

src/test/java/com/marklogic/client/modulesloader/impl/DefaultModulesFinderTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import com.marklogic.client.modulesloader.Modules;
1212
import com.marklogic.client.modulesloader.ModulesFinder;
13-
import com.marklogic.client.modulesloader.impl.DefaultModulesFinder;
1413

1514
public class DefaultModulesFinderTest extends Assert {
1615

@@ -20,15 +19,16 @@ public class DefaultModulesFinderTest extends Assert {
2019
public void baseDirWithExtensionsOfEachKind() throws IOException {
2120
Modules modules = sut.findModules(getBaseDir("sample-base-dir"));
2221
assertEquals(1, modules.getOptions().size());
23-
assertEquals("Only recognized XQuery files should be included; the XML file should be ignored", 2, modules
24-
.getServices().size());
25-
assertEquals("Only recognized XSL files should be included; the XML file should be ignored", 4, modules
26-
.getTransforms().size());
22+
assertEquals("Only recognized XQuery files should be included; the XML file should be ignored", 2,
23+
modules.getServices().size());
24+
assertEquals("Only recognized XSL files should be included; the XML file should be ignored", 4,
25+
modules.getTransforms().size());
2726

2827
List<File> dirs = modules.getAssetDirectories();
29-
assertEquals(2, dirs.size());
28+
assertEquals(3, dirs.size());
3029
assertEquals("ext", dirs.get(0).getName());
3130
assertEquals("root", dirs.get(1).getName());
31+
assertEquals("include-this-too", dirs.get(2).getName());
3232

3333
assertEquals(
3434
"Namespace files don't have to fit any filename format; the body of the file should be the namespace URI",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
xquery version "1.0-ml";
2+
3+
module namespace module1 = "urn:sample:module1";
4+
5+
declare function sample() {
6+
"Hello module1"
7+
};

0 commit comments

Comments
 (0)