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

Commit 2a7c415

Browse files
author
Rob Rudin
committed
#130 Module timestamps path can be overriden now
1 parent cc0725b commit 2a7c415

File tree

6 files changed

+46
-3
lines changed

6 files changed

+46
-3
lines changed

src/main/java/com/marklogic/appdeployer/AppConfig.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public class AppConfig {
8686
private boolean staticCheckAssets = false;
8787
private boolean staticCheckLibraryAssets = false;
8888
private boolean bulkLoadAssets = true;
89+
private String moduleTimestampsPath;
8990

9091
private String schemasPath;
9192
private ConfigDir configDir;
@@ -688,4 +689,11 @@ public boolean isGenerateSearchOptions() {
688689
return generateSearchOptions;
689690
}
690691

692+
public String getModuleTimestampsPath() {
693+
return moduleTimestampsPath;
694+
}
695+
696+
public void setModuleTimestampsPath(String moduleTimestampsPath) {
697+
this.moduleTimestampsPath = moduleTimestampsPath;
698+
}
691699
}

src/main/java/com/marklogic/appdeployer/DefaultAppConfigFactory.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,12 @@ public AppConfig newAppConfig() {
246246
c.setModulePaths(list);
247247
}
248248

249+
prop = getProperty("mlModuleTimestampsPath");
250+
if (prop != null) {
251+
logger.info("Module timestamps path: " + prop);
252+
c.setModuleTimestampsPath(prop);
253+
}
254+
249255
/**
250256
* Whether or not to load asset modules in bulk - i.e. in one transaction. Defaults to true.
251257
*/

src/main/java/com/marklogic/appdeployer/command/modules/LoadModulesCommand.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.marklogic.client.DatabaseClient;
66
import com.marklogic.client.modulesloader.ModulesLoader;
77
import com.marklogic.client.modulesloader.impl.DefaultModulesLoader;
8+
import com.marklogic.client.modulesloader.impl.PropertiesModuleManager;
89
import com.marklogic.client.modulesloader.impl.TestServerModulesFinder;
910
import com.marklogic.appdeployer.AppConfig;
1011
import com.marklogic.appdeployer.command.AbstractCommand;
@@ -32,6 +33,10 @@ public LoadModulesCommand() {
3233
public void initializeDefaultModulesLoader(CommandContext context) {
3334
logger.info("Initializing instance of DefaultModulesLoader");
3435
DefaultModulesLoader l = new DefaultModulesLoader(context.getAppConfig().newXccAssetLoader());
36+
String path = context.getAppConfig().getModuleTimestampsPath();
37+
if (path != null) {
38+
l.setModulesManager(new PropertiesModuleManager(new File(path)));
39+
}
3540
l.setStaticChecker(context.getAppConfig().newStaticChecker());
3641
this.modulesLoader = l;
3742
}

src/main/java/com/marklogic/appdeployer/util/ModulesWatcher.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
import com.marklogic.client.DatabaseClient;
77
import com.marklogic.client.helper.LoggingObject;
88
import com.marklogic.client.modulesloader.ModulesFinder;
9-
import com.marklogic.client.modulesloader.ModulesLoader;
109
import com.marklogic.client.modulesloader.impl.DefaultModulesFinder;
1110
import com.marklogic.client.modulesloader.impl.DefaultModulesLoader;
11+
import com.marklogic.client.modulesloader.impl.PropertiesModuleManager;
1212
import com.marklogic.client.modulesloader.impl.XccAssetLoader;
1313
import com.marklogic.appdeployer.AppConfig;
1414
import com.marklogic.appdeployer.DefaultAppConfigFactory;
@@ -39,13 +39,17 @@ public static void startFromSystemProps() {
3939
public void run() {
4040
XccAssetLoader xal = appConfig.newXccAssetLoader();
4141
DefaultModulesLoader loader = new DefaultModulesLoader(xal);
42+
String path = appConfig.getModuleTimestampsPath();
43+
if (path != null) {
44+
loader.setModulesManager(new PropertiesModuleManager(new File(path)));
45+
}
4246
loader.setStaticChecker(appConfig.newStaticChecker());
4347
DatabaseClient client = appConfig.newDatabaseClient();
4448
List<String> paths = appConfig.getModulePaths();
4549
ModulesFinder finder = new DefaultModulesFinder();
4650
while (true) {
47-
for (String path : paths) {
48-
loader.loadModules(new File(path), finder, client);
51+
for (String modulesPath : paths) {
52+
loader.loadModules(new File(modulesPath), finder, client);
4953
}
5054
try {
5155
Thread.sleep(sleepTime);

src/test/java/com/marklogic/appdeployer/DefaultAppConfigFactoryTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public void allProperties() {
6363
p.setProperty("mlReplaceTokensInModules", "false");
6464
p.setProperty("mlUseRoxyTokenPrefix", "false");
6565
p.setProperty("mlModulePaths", "path1,path2,path3");
66+
p.setProperty("mlModuleTimestampsPath", "custom/timestamps/path.properties");
6667

6768
p.setProperty("mlModelsPath", "ml/models");
6869
p.setProperty("mlInstanceConverterPath", "ext/my/path");
@@ -108,6 +109,8 @@ public void allProperties() {
108109
assertEquals("path1", paths.get(0));
109110
assertEquals("path2", paths.get(1));
110111
assertEquals("path3", paths.get(2));
112+
113+
assertEquals("custom/timestamps/path.properties", config.getModuleTimestampsPath());
111114
}
112115

113116
/**

src/test/java/com/marklogic/appdeployer/command/modules/LoadModulesTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import java.io.File;
44

5+
import com.marklogic.appdeployer.command.CommandContext;
6+
import com.marklogic.client.modulesloader.impl.DefaultModulesLoader;
57
import com.marklogic.junit.Fragment;
68
import org.junit.After;
79
import org.junit.Before;
@@ -52,6 +54,21 @@ public void loadModulesWithStaticCheck() {
5254
}
5355
}
5456

57+
@Test
58+
public void customModuleTimestampsPath() {
59+
String path = "build/custom-path.properties";
60+
File customFile = new File(path);
61+
customFile.mkdirs();
62+
if (customFile.exists()) {
63+
customFile.delete();
64+
}
65+
66+
appConfig.setModuleTimestampsPath("build/custom-path.properties");
67+
initializeAppDeployer(new DeployRestApiServersCommand(true), new LoadModulesCommand());
68+
appDeployer.deploy(appConfig);
69+
assertTrue("The custom file should have been created when the modules were loaded", customFile.exists());
70+
}
71+
5572
@Test
5673
public void loadModulesFromMultiplePaths() {
5774
appConfig.getModulePaths().add("src/test/resources/sample-app/build/mlRestApi/some-library/ml-modules");

0 commit comments

Comments
 (0)